Home | History | Annotate | only in /src/sys/arch/powerpc
History log of /src/sys/arch/powerpc
RevisionDateAuthorComments
 1.10 30-Apr-2008  garbled branches: 1.10.26;
Convert prep to use the new unified mkbootimage rather than it's own. This
mkbootimage can be shared by prep, rs6000, and bebox.

TODO: Convert bebox to use this. Needs someone to test.
 1.9 04-Mar-2008  mrg branches: 1.9.2; 1.9.4;
insert a .WAIT between include and include/foo subdirs, so that
include/ is created before include/foo.

fixes -j builds on ofppc for me.
 1.8 03-Feb-2003  matt branches: 1.8.18; 1.8.80; 1.8.100; 1.8.104;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.7 13-Jun-2001  simonb branches: 1.7.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.6 12-Jun-1998  cgd branches: 1.6.26;
Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.5 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.4 11-Oct-1997  mycroft Nuke NOOBJ.
 1.3 11-Oct-1997  mycroft Update all the tags goo, and use bsd.subdir.mk.
 1.2 07-May-1997  mycroft branches: 1.2.4;
Don't use _SUBDIRUSE outside of bsd.subdir.mk.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.26.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.7.8.1 13-Jun-2001  simonb file Makefile was added on branch nathanw_sa on 2001-06-13 06:01:47 +0000
 1.8.104.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.104.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.100.1 24-Mar-2008  keiichi sync with head.
 1.8.80.1 23-Mar-2008  matt sync with HEAD
 1.8.18.1 17-Mar-2008  yamt sync with head.
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.10.26.1 07-Jan-2011  matt Descend into the booke include diretory
 1.1 04-Apr-2011  dyoung branches: 1.1.2; 1.1.6;
Add a couple of make(1) include files that provide lists of source
files needed for tags computation in evbppc, evbarm, cats, and other
architectures.
 1.1.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 04-Apr-2011  jruoho file Makefile.inc was added on branch jruoho-x86intr on 2011-06-06 09:06:25 +0000
 1.1.2.2 21-Apr-2011  rmind sync with head
 1.1.2.1 04-Apr-2011  rmind file Makefile.inc was added on branch rmind-uvmplock on 2011-04-21 01:41:18 +0000
 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.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().
 1.13 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.12 18-Mar-1998  bouyer Add commented out "options FFS_EI"
 1.11 02-Mar-1998  drochner Change MBR partition type for NetBSD to 0xa9, like the i386 port.
Provide compatibility via COMPAT_386BSD_MBRPART.
 1.10 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.9 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.8 01-Dec-1997  kleink Add COMPAT_13.
 1.7 20-Nov-1997  fair add pseudo-device rnd, commented out
 1.6 17-Nov-1997  lukem * add commented out DDB_HISTORY_SIZE=100 if DDB exists in config file
* fix up use of 'options<SPACE><TAB>'
 1.5 16-Apr-1997  thorpej branches: 1.5.8;
Update for current PowerPC code, some from Wolfgang.
 1.4 31-Jan-1997  thorpej Adopt for new file system and root spec grammar.
 1.3 16-Oct-1996  ws branches: 1.3.2;
Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.2 16-Oct-1996  ws Add EXEC_ stuff
 1.1 30-Sep-1996  ws PowerPC port
 1.3.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.5.8.1 20-Nov-1997  mellon Pull rev 1.7 up from trunk (fair)
 1.62 20-Mar-2024  christos Fix reproducible builds (Jan-Benedict Glaw)
 1.61 22-Sep-2018  rin - Determine KERN_AS automatically depending on whether OPT_MODULAR is
set or not, in the same way as libcompat.

- Specify OPT_MODULAR in the port Makefile instead of KERN_AS.

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

OK christos
 1.60 27-Feb-2016  joerg branches: 1.60.16; 1.60.18;
clang now supports normal soft float.
 1.59 24-Aug-2015  uebayasi Define ${LINKSCRIPT} in one place.
 1.58 15-Nov-2014  uebayasi branches: 1.58.2;
Use LINKSCRIPT.
 1.57 10-Aug-2014  joerg Put GCC/GAS specific options under ACTIVE_CC == "gcc".
 1.56 08-Aug-2014  joerg Don't set -mmultiple or -mno-string for PowerPC, the difference is too
small to really matter and it sometimes even increases the size.
 1.55 05-Aug-2014  apb Use ${TOOL_GZIP_N} instead of ${TOOL_GZIP} -n, and similarly
use ${TOOL_GZIP_N} -9 instead of ${TOOL_GZIP} -9n, etc.

This will pass -nT instead of just -n if the gzip program is
actually pigz.
 1.54 06-Mar-2014  matt branches: 1.54.2;
When building a DEBUG kernel, mdsetimage into the .gdb as well (so if it's
used with gxemul, it has the md image in it.)
 1.53 28-Feb-2014  matt Don't hardcode MACHINE_ARCH
 1.52 23-Aug-2013  matt Add a SYSTEM_DEP for the ramdisk on INSTALL kernels.
 1.51 10-Mar-2013  christos branches: 1.51.6;
Explicitly set KERN_AS (this could be done in /usr/src/sys/conf/Makefile.*)
so that modules work, on config files that did not set it explicitly. All
the files now use the standard logic, except the ones that set KERN_AS=obj
and Makefile.usermode which sets KERN_AS=library.
 1.50 21-Mar-2012  matt branches: 1.50.2;
For BookE kernels, use -mmultiple and -misel and enable -fstack-protector
 1.49 01-Feb-2012  matt branches: 1.49.2;
Make sure the walnut system_tail_extra is very last thing.
 1.48 30-Jun-2011  matt branches: 1.48.2; 1.48.6;
Get rid of local TOOL_GZIP definition that now bsd.own.mk does it for us.
 1.47 25-Jun-2011  matt Move some stuff from evbppc's Makefile.inc to powerpc's.
This avoids redundant objcopy's
 1.46 18-Jun-2011  matt Make a common genassym.cf (powerpc/genassym.cf) and then
only put specific stuff in foo/genassym.cf
 1.45 04-Jun-2011  matt Make sure the kernel is compiled with -msdata=none since it uses %r2 and %r13
for other uses.
 1.44 18-Jan-2011  matt branches: 1.44.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.43 15-Feb-2009  cube branches: 1.43.4; 1.43.6;
Convert the recently introduced awk command to retrieve the value of the
option MODULAR to using %MODULAR%. While it is now possible to only
request the new version in the affected Makefiles, it is made mandatory for
everybody because I just fixed a bug in config(1) that would not make it
fail in the case of a syntax error in the Makefile template.
 1.42 14-Feb-2009  apb Now that "options MODULAR" is handled via defflag, the Makefile
generated by config(1) in the kernel compile directory no longer
contains IDENT=-DMODULAR. Instead, there's an opt_modular.h file that
might or might not contain "#define MODULAR 1".

Adapt to this by adding an OPT_MODULAR variable to relevant Makefiles,
set via an awk script that parses opt_modular.h.
 1.41 13-Nov-2008  ad branches: 1.41.4;
LKM -> MODULAR
 1.40 07-Mar-2008  phx branches: 1.40.4; 1.40.10; 1.40.12; 1.40.22;
mem*.S no longer include assym.h
 1.39 03-Mar-2008  matt Make kernlib depend on assym.h
 1.38 01-Mar-2008  joerg mem*.S needs assym.h.
 1.37 08-Jan-2008  joerg branches: 1.37.2; 1.37.6;
lock_stubs.S needs assym.h.
 1.36 24-Nov-2005  dbj branches: 1.36.50; 1.36.56; 1.36.64;
. Have dbsym explicitly suggest increasing SYMTAB_SPACE when
an overflow occurs.
. Make this error a fatal build time error
. Move the support for dbsym into the MI Makefile.kern.inc,
conditional upon the SYMTAB_SPACE option being defined in
the kernel config file.
 1.35 02-Jun-2005  he branches: 1.35.2; 1.35.8;
Remove the hack to compile oea/pmap.c with -Wno-cast-qual, and instead
make use of the new __UNVOLATILE() macro in memset() usage.
 1.34 02-Jun-2005  he Put a band-aid over the cast qualification warnings for oea/pmap.c.
It cannot be compiled with -Wno-cast-qual due to a volatile pointer
being passed to memset(), and there's no easy way other than open-
coding memset() to fix this. So instead we cheat for now and add
-Wno-cast-qual to CFLAGS for this file. To be documented in doc/HACKS.
 1.33 31-May-2005  christos s/GENASSYM/GENASSYM_CONF/ so we can use "GENASSYM" as the program name.
 1.32 12-Feb-2005  matt When building kernel for OEA, allow unaligned accesses since OEA
processors will deal with them properly.
 1.31 09-Dec-2004  matt branches: 1.31.2; 1.31.4;
Add -Wa,-maltivec so that AltiVec instuctions will be recognized.
 1.30 04-Jun-2004  thorpej Add the %MAKEOPTIONSAPPEND token at the end of the file, after the
common Makefile.kern.inc has been included.
 1.29 06-Jan-2004  briggs branches: 1.29.4;
Change CPPFLAGS to -D${MACHINE}=${MACHINE} instead of just -D${MACHINE}
This makes it possible to define header files on the command line that
might include ${MACHINE} somewhere in the path. This might be used in
evbppc, for example, when defining PPC_PCI_MACHDEP_IMPL as, for example:

PPC_PCI_MACHDEP_IMPL="<arch/evbppc/sandpoint/pci_machdep.h>"

which will be included as

#include PPC_PCI_MACHDEP_IMPL

Prior to this change, the compile would fail trying to include
<arch/evbppc/1/pci_machdep.h>
 1.28 29-Sep-2003  simonb Add a dependancy on assym.h; helps "make -j N" kernel builds.
 1.27 24-Feb-2003  matt branches: 1.27.2;
Only define KERN_AS= object if IDENT has -DLKM.
 1.26 19-Feb-2003  matt Set KERN_AS=obj now that LKMs work. (otherwise when you loaded LKMs they
wouldn't have all the library routines available).
 1.25 01-Jan-2003  augustss Add NEED_SYMTAB to run dbsym.
 1.24 23-Aug-2002  scw Allow port-specific Makefiles to override the name and location
of locore.[So].
This is in preparation for arch/evbppc.
 1.23 19-May-2002  augustss Add NEED_BINARY, similar to NEED_SREC.
 1.22 18-Apr-2002  matt branches: 1.22.2;
Use a common genassym.cf for all the PPC_MPC6XX ports. Add a makeoptions to
std.foo to indicate the directory to get genassym.cf from. Add an intrframe
to <powerpc/frame.h> and make trap_subr.S use symbolic offsets into it.
 1.21 05-Jan-2002  dbj change apparent typo of MS_SFILES to MD_SFILES
This fixes some dependency problems with locore.S
 1.20 09-Dec-2001  atatat Roll the rest of the ports over to the new MI kernel build machinery.
Any problems reported by testers have been fixed, and massive
cross-compiling of kernels has shown that any problems that remain
with actually building kernels are not related to this.
 1.19 26-Oct-2001  jmc branches: 1.19.2;
Change defaults for kernel compiles. Default all to USETOOLS?=no and have
the etc Makefile override that by putting USETOOLS into $.MAKEOVERRIDES
This way the default for kernel compiles is still to use the installed
toolchain instead of depending on $TOOLDIR. $TOOLDIR can be used by
simply adding USETOOLS=yes to the command line as usual.

Adjust each ports template to set the default no setting and also pull in
bsd.own.mk if they weren't already to ensure they'll build correctly
with the new toolchain setup.
 1.18 23-Oct-2001  thorpej branches: 1.18.2;
Set MACHINE_ARCH explicitly in Makefiles for which it is constant.
Also, since config(8) now explcitly sets MACHINE, there is no need
to do it here in the Makefile.
 1.17 23-Oct-2001  thorpej Use MACHINE, not TARGET_MACHINE.
 1.16 21-Oct-2001  thorpej Use <bsd.own.mk> so that the right thing happens when building a
kernel w/ USE_NEW_TOOLCHAIN.
 1.15 26-Aug-2001  simonb Include ${THISPPC}/conf/Makefile.${TARGET_MACHINE}.inc if it exists (ala
mips' Makefile.mips).
 1.14 26-Aug-2001  matt Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.13 28-May-1998  sakamoto branches: 1.13.4;
Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.12 12-Apr-1998  tv Add -Wno-main conditional on compiler being gcc 2.8 or egcs. (This adds
a HAVE_GCC28 check-variable that can now be used to add other gcc-2.8
flags in cases where they may be useful, or to remove gcc 2.7.2 "bug
workaround" flags.)
 1.11 12-Nov-1997  thorpej Make sure CPP, AR, AS, and RANLIB are defined.
 1.10 12-Nov-1997  thorpej Define LORDER, NM, and TSORT here, like we do the rest of the tools.
 1.9 30-Sep-1997  christos branches: 1.9.2;
PR/4162: Chris Jones: make cleandir does not work properly; it does not
remove the object files and the .depend file in the kernel build directory.
 1.8 12-Jul-1997  leo branches: 1.8.2;
Generate assym.h dependencies when making 'depend'.
 1.7 19-Apr-1997  thorpej Fix a pasto
 1.6 16-Apr-1997  thorpej - Use genassym.sh to facilitate cross-compiling.
- Various clean/catch-up.
 1.5 14-Mar-1997  mycroft Define the `cleankernel' target consistently with other ports.
 1.4 04-Feb-1997  perry Nuke some options GENERIC residue.
 1.3 04-Feb-1997  perry Nuke some GENERIC residue.
 1.2 01-Dec-1996  jonathan * Replace explicit -O2 in CFLAGS with COPTS macro. Default COPTS?= -O2.
Lets users over-ride with makeoptions COPTS="..." in kernel config files.

Leave `mandatory' flags (like -msoft-float which on m68k enforces no
FP in kernel) in CFLAGS.
 1.1 30-Sep-1996  ws PowerPC port
 1.8.2.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.2.1 12-Nov-1997  thorpej Pull up "make sure tools are defined" changes from trunk.
 1.13.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.13.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.18.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.19.2.7 03-Jan-2003  thorpej Sync with HEAD.
 1.19.2.6 27-Aug-2002  nathanw Catch up to -current.
 1.19.2.5 20-Jun-2002  nathanw Catch up to -current.
 1.19.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.19.2.3 11-Jan-2002  nathanw More catchup.
 1.19.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.19.2.1 26-Oct-2001  nathanw file Makefile.powerpc was added on branch nathanw_sa on 2002-01-08 00:27:08 +0000
 1.22.2.2 31-Aug-2002  gehenna catch up with -current.
 1.22.2.1 30-May-2002  gehenna Catch up with -current.
 1.27.2.7 11-Dec-2005  christos Sync with head.
 1.27.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.27.2.5 15-Feb-2005  skrll Sync with HEAD.
 1.27.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.27.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.27.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.27.2.1 03-Aug-2004  skrll Sync with HEAD
 1.29.4.1 06-Feb-2005  jmc Pull up patch (requested by martti in ticket #1086)
Move ipf to sys/dist/ipf and sync w. trunk
 1.31.4.1 12-Feb-2005  yamt sync with head.
 1.31.2.1 29-Apr-2005  kent sync with -current
 1.35.8.1 29-Nov-2005  yamt sync with head.
 1.35.2.3 17-Mar-2008  yamt sync with head.
 1.35.2.2 21-Jan-2008  yamt sync with head
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.36.64.1 08-Jan-2008  bouyer Sync with HEAD
 1.36.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.36.50.2 23-Mar-2008  matt sync with HEAD
 1.36.50.1 09-Jan-2008  matt sync with HEAD
 1.37.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.37.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.37.2.1 24-Mar-2008  keiichi sync with head.
 1.40.22.2 26-Jul-2011  matt Merge MKUBOOTIMAGE support from -HEAD
 1.40.22.1 07-Jan-2011  matt Add booke support.
 1.40.12.2 03-Mar-2009  skrll Sync with HEAD.
 1.40.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.40.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.40.4.1 04-May-2009  yamt sync with head.
 1.41.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.43.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.43.4.2 12-Jun-2011  rmind sync with head
 1.43.4.1 05-Mar-2011  rmind sync with head
 1.44.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.48.6.2 05-Apr-2012  mrg sync to latest -current.
 1.48.6.1 18-Feb-2012  mrg merge to -current.
 1.48.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.48.2.1 17-Apr-2012  yamt sync with head
 1.49.2.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #250):
sys/arch/powerpc/conf/Makefile.powerpc: revision 1.50
For BookE kernels, use -mmultiple and -misel and enable -fstack-protector
 1.50.2.3 03-Dec-2017  jdolecek update from HEAD
 1.50.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.2.1 23-Jun-2013  tls resync from head
 1.51.6.2 18-May-2014  rmind sync with head
 1.51.6.1 28-Aug-2013  rmind sync with head
 1.54.2.1 10-Aug-2014  tls Rebase.
 1.58.2.2 19-Mar-2016  skrll Sync with HEAD
 1.58.2.1 22-Sep-2015  skrll Sync with HEAD
 1.60.18.1 10-Jun-2019  christos Sync with HEAD
 1.60.16.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.8 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.7 22-Jul-2012  matt 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.6 02-Aug-2011  matt branches: 1.6.2;
Change device name of pq3cfi to cfi.
Add cfi to P2020DS
Add ddrc
 1.5 25-Jul-2011  matt nflash is dead. remove it.
 1.4 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 02-May-2011  matt Add nandfcm device glue
 1.2 18-Jan-2011  matt 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 09-Mar-2010  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add PPC BookE files.
 1.1.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.5 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.8.4 02-Aug-2011  matt Change pq3cfi to cfi
 1.1.8.3 26-Jul-2011  matt Add pq3cfi device
 1.1.8.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.1.8.1 09-Mar-2010  matt file files.booke was added on branch matt-nb5-pq3 on 2011-01-07 01:26:18 +0000
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 09-Mar-2010  uebayasi file files.booke was added on branch uebayasi-xip on 2010-04-30 14:39:41 +0000
 1.1.4.2 31-May-2011  rmind sync with head
 1.1.4.1 05-Mar-2011  rmind sync with head
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file files.booke was added on branch yamt-nfs-mp on 2010-03-11 15:02:49 +0000
 1.6.2.1 30-Oct-2012  yamt sync with head
 1.9 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.8 20-Feb-2008  drochner branches: 1.8.10; 1.8.24; 1.8.30; 1.8.32;
Since files.wscons et al. are included by ~all ports anyway, include
them in the mi "files" file, and remove include statements from md files.
These shouldn't pull in additional kernel code when not in use, so it
shouldn't do any harm except a risk of namespace collisions which
should be easy to fix.
 1.7 10-Apr-2007  macallan branches: 1.7.14;
include files.wsfb
 1.6 19-Sep-2006  simonb branches: 1.6.4; 1.6.8; 1.6.10;
Fix white-space nit.
 1.5 18-Sep-2006  gdamore Conversion of evbppc to generic TODR. ok freza@
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 06-Oct-2003  shige branches: 1.3.4; 1.3.18;
Add Real time clock support code.
 1.2 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.1 23-Sep-2003  shige Add IBM405GPx specific kernel configuration file.
 1.3.18.3 27-Feb-2008  yamt sync with head.
 1.3.18.2 03-Sep-2007  yamt sync with head.
 1.3.18.1 30-Dec-2006  yamt sync with head.
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 06-Oct-2003  skrll file files.ibm405gp was added on branch ktrace-lwp on 2004-08-03 10:39:22 +0000
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.6.10.1 11-Jul-2007  mjf Sync with head.
 1.6.8.1 10-Apr-2007  ad Sync with head.
 1.6.4.1 15-Apr-2007  yamt sync with head.
 1.7.14.1 23-Mar-2008  matt sync with HEAD
 1.8.32.1 30-May-2010  rmind sync with head
 1.8.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.24.1 24-Oct-2010  jym Sync with HEAD
 1.8.10.1 11-Aug-2010  yamt sync with head.
 1.15 21-Nov-2013  kiyohara Support Synopsys DesigneWave OTG on PowerPC 405EX.
 1.14 22-Jun-2011  matt branches: 1.14.2; 1.14.12; 1.14.16;
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.13 20-Jun-2011  matt Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.12 06-Nov-2010  uebayasi branches: 1.12.6;
Add IBM405GPr "External Bus" driver.
 1.11 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.10 13-Mar-2006  shige branches: 1.10.68; 1.10.88; 1.10.90;
IBM4xx on-chip GPIO controller apllying MI GPIO framework.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10;
merge ktrace-lwp.
 1.8 13-Oct-2005  jmc Rename gpio to ppcgpio to resolve naming conflicts w. gpio framework
 1.7 23-Jan-2005  shige branches: 1.7.8;
Add gpio module.
 1.6 17-Jan-2005  shige Add board properties database code.
 1.5 06-Oct-2003  scw branches: 1.5.6; 1.5.8;
MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.4 23-Sep-2003  shige Add on-chip IIC driver.
Add some definitions for IIC driver.
 1.3 23-Nov-2002  thorpej branches: 1.3.6;
Put interface attributes on the device, not another attribute with
the same name as the device.
 1.2 23-Aug-2002  scw branches: 1.2.2; 1.2.4; 1.2.6;
Add "ecc at plb" device.
Add an "irq" locator to the plb device.
This gets rid of the original hack where ecc support was wedged into
the cpu driver.
 1.1 13-Aug-2002  simonb Move 4xx devices to their own config include file so they can be used
elsewhere.
 1.2.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.6.1 23-Aug-2002  jdolecek file files.ibm4xx was added on branch kqueue on 2002-09-06 08:39:00 +0000
 1.2.4.2 31-Aug-2002  gehenna catch up with -current.
 1.2.4.1 23-Aug-2002  gehenna file files.ibm4xx was added on branch gehenna-devsw on 2002-08-31 13:45:41 +0000
 1.2.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.2.2.1 23-Aug-2002  nathanw file files.ibm4xx was added on branch nathanw_sa on 2002-08-27 23:45:04 +0000
 1.3.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.4 24-Jan-2005  skrll Sync with HEAD.
 1.3.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.6.1 03-Aug-2004  skrll Sync with HEAD
 1.5.8.1 29-Apr-2005  kent sync with -current
 1.5.6.1 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.7.8.1 21-Jun-2006  yamt sync with head.
 1.9.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.9.8.1 01-Apr-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.90.2 05-Mar-2011  rmind sync with head
 1.10.90.1 30-May-2010  rmind sync with head
 1.10.88.6 09-Nov-2010  uebayasi Sync with HEAD.
 1.10.88.5 09-Nov-2010  uebayasi Sync with HEAD.
 1.10.88.4 19-Aug-2010  uebayasi Define FlashROM addresses in board specific code.
 1.10.88.3 11-Aug-2010  uebayasi Implement flash(4) glue at exb(4).
 1.10.88.2 11-Aug-2010  uebayasi Implement 405GPr's "External Bus" as exb(4).
 1.10.88.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.68.1 11-Aug-2010  yamt sync with head.
 1.12.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.16.1 18-May-2014  rmind sync with head
 1.14.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 15-Nov-2000  matt branches: 1.5.40; 1.5.82; 1.5.90; 1.5.100; 1.5.102; 1.5.104; 1.5.106;
back out my change powerpc/conf/files.ofw. Enable the inclusion of
dev/ofw/files.ofw on macppc. Add openfirm to ofppc/conf.c
 1.4 14-Nov-2000  matt Add support for /dev/openfirm.
Add OF_nextprop support.
 1.3 15-Feb-1999  hubertf RCS ID police
 1.2 29-May-1998  sakamoto revert. ofppc->powerpc
 1.1 29-May-1998  sakamoto Revert OpenFirmware files to powerpc directory.
OpenFirmware files are used by ofppc/macppc.
 1.5.106.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.104.1 18-Oct-2007  yamt sync with head.
 1.5.102.1 06-Nov-2007  matt sync with HEAD
 1.5.100.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.90.1 24-Sep-2007  macallan add an option for OFWOEA specific debug output
 1.5.82.1 23-Oct-2007  ad Sync with head.
 1.5.40.1 27-Oct-2007  yamt sync with head.
 1.102 30-May-2022  rin Introduce PPC_NO_UNALIGNED flag to indicate that CPU cannot handle
unaligned memory access, and emulation should be provided to userland.
 1.101 07-May-2022  rin Try to fix PV tracking support.

* For oea (with real PV tracking support):

Define __HAVE_PMAP_PV_TRACK. Otherwise, pmap_pv_init() is not called by
uvm_init().

* For booke and ibm4xx (without PV tracking support):

For MODULAR kernel and modules, define __HAVE_PMAP_PV_TRACK together with
PMAP_PV_TRACK_ONLY_STUBS, so that modules can be shared with oea.

Note that PMAP_PV_TRACK_ONLY_STUBS can be used even for oea,
as a compile-time option to strip real PV tracking support.
 1.100 17-Feb-2022  macallan include pmap_pvt.c in bridge mode as well
 1.99 16-Feb-2022  riastradh powerpc: Implement pv-tracking for unmanaged pages.

Needed for drm.
 1.98 05-Mar-2021  rin For Explora 451, call calc_delayconst() before pckbc_cnattach(), which
depends on delay() and DELAY().

Unfortunately, proplib(9) API is not available for MD codes, that are
called before consinit() (since pool(9) is not initialized yet).

Therefore, hard-code CPU frequency to calc_delayconst() in case
"processor-frequency" is not initialized.
 1.97 21-Oct-2020  christos branches: 1.97.2;
make process_machdep.c included always since it provides register i/o used by
sys_process_getlwpstatus.c which is always included.
 1.96 20-Oct-2020  christos harmonize process_machdep.c inclusion.
 1.95 10-Sep-2020  rin Introduce PMAP_TLBDEBUG option for ibm4xx: clear only TLBHI[V] bit when
TLB entry is invalidated, instead of clearing entire TLBHI register.
 1.94 30-Jun-2020  maxv Make copystr() a MI C function, part of libkern and shared on all
architectures.

Notes:

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

Could test on amd64 only, but should be fine.
 1.93 20-Feb-2020  rin Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)
 1.92 06-Apr-2019  thorpej branches: 1.92.4; 1.92.6;
Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.91 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.90 01-Jun-2018  macallan branches: 1.90.2;
add clock speed control for 970MP CPUs
 1.89 04-Mar-2014  matt branches: 1.89.28;
compat16 -> compat_16
 1.88 28-Feb-2014  matt sigcode is dependant on compat_16
 1.87 17-Nov-2013  alnsn Enable sljit and bpfjit on powerpc.
 1.86 19-Sep-2013  christos remove unused OPENPIC flags.
 1.85 20-Oct-2012  kiyohara branches: 1.85.2;
Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.84 02-Oct-2012  christos move common tlb stuff to uvm
 1.83 29-Mar-2012  matt branches: 1.83.2;
Add PMAP_MINIMALTLB defflag
 1.82 29-Jun-2011  matt branches: 1.82.2; 1.82.6; 1.82.8;
Add VERBOSE_INITPPC flag
 1.81 18-Jun-2011  matt Unconditionally build fixup.c
 1.80 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.79 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.78 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.77 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.76 02-May-2011  matt branches: 1.76.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.75 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.74 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.73 18-Jan-2011  matt branches: 1.73.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.72 09-Mar-2010  matt branches: 1.72.2; 1.72.4;
Add PPC_BOOKE cputype and booke files.
 1.71 11-Dec-2008  pooka branches: 1.71.4;
Since oea pmap.c is #included many times, put kernel_pmap_ptr into
its own source module to avoid multiple initialized data definitions.
 1.70 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.69 05-Feb-2008  garbled branches: 1.69.6; 1.69.10; 1.69.16; 1.69.18; 1.69.28;
Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.68 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.67 25-Jan-2008  joerg Refactor in_cksum/in4_cksum/in6_cksum implementations:
- All three functions are included in the kernel by default.
They call a backend function cpu_in_cksum after possibly
computing the checksum of the pseudo header.
- cpu_in_cksum is the core to implement the one-complement sum.
The default implementation is moderate fast on most platforms
and provides a 32bit accumulator with 16bit addends for L32 platforms
and a 64bit accumulator with 32bit addends for L64 platforms.
It handles edge cases like very large mbuf chains (could happen with
native IPv6 in the future) and provides a good base for new native
implementations.
- Modify i386 and amd64 assembly to use the new interface.

This disables the MD implementations on !x86 until the conversion is
done. For Alpha, the portable version is faster.
 1.66 07-Jan-2008  ad Build kobj_machdep.c if MODULAR.
 1.65 17-Oct-2007  garbled branches: 1.65.2; 1.65.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.64 07-Jul-2007  tsutsui branches: 1.64.8; 1.64.10; 1.64.12; 1.64.14;
Remove leftover netns stuff.
 1.63 09-Feb-2007  ad branches: 1.63.6; 1.63.8; 1.63.14;
Merge newlock2 to head.
 1.62 05-Aug-2006  sanjayl branches: 1.62.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.61 11-Dec-2005  christos branches: 1.61.4; 1.61.8;
merge ktrace-lwp.
 1.60 02-Jun-2005  he branches: 1.60.2;
Remove the hack to compile oea/pmap.c with -Wno-cast-qual, and instead
make use of the new __UNVOLATILE() macro in memset() usage.
 1.59 02-Jun-2005  he Put a band-aid over the cast qualification warnings for oea/pmap.c.
It cannot be compiled with -Wno-cast-qual due to a volatile pointer
being passed to memset(), and there's no easy way other than open-
coding memset() to fix this. So instead we cheat for now and add
-Wno-cast-qual to CFLAGS for this file. To be documented in doc/HACKS.
 1.58 03-Jul-2004  manu Move all the MD bits of commpage to a new file.
Map the comm page as RW in kernel (we want to modify it but not to execute it),
and RX in userland (no need to modify it but we want to execute it
 1.57 18-Apr-2004  matt Add entry for netns/ns_cksum.c
 1.56 17-Mar-2004  aymeric defparam PMAP_MEMLIMIT
 1.55 19-Nov-2003  scw Include arch/powerpc/ibm4xx/intr.c only if a particular board actually
uses the generic 4xx interrupt implementation.
There are some 4xx boards with entirely different interrupt controllers.
 1.54 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.53 12-Aug-2003  matt Remove SPILLSTK leftovers.
 1.52 11-Aug-2003  matt Add PTEGCOUNT defparam for opt_pmap.h
 1.51 03-Aug-2003  matt Add PPC_OEA64 and netbsd32_sigcode.S
 1.50 18-Jul-2003  matt Elimindate MD setrunqueue/remrunqueue (which were out-of-date compared to
the canonical versions in kern_synch.c). Define __HAVE_BIGENDIAN_BITOPS
so the canonical versions will be used but will store priorities in the
desired (MSB) order for PowerPC (which allows the use of the cntlzw (count
leading zeroes, word) instruction in locore_subr.S to find the proper
priority).
 1.49 08-May-2003  christos branches: 1.49.2;
rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.48 17-Mar-2003  matt Add CLOCKBASE to opt_ppcparam.h.
 1.47 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.46 26-Feb-2003  jklos Added L3CR_CONFIG to the parameter list for 745x L3 cache configuration.
 1.45 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.44 02-Feb-2003  matt Remove OLDPMAP support.
 1.43 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.42 25-Nov-2002  manu Added an empty shell for signal delivery. Now we just have to fill the
machine dependant bits.
 1.41 17-Nov-2002  manu As we use one FreeBSD file for COMPAT_DARWIN, we must include file.freebsd
 1.40 12-Nov-2002  manu The kernel now builds with COMPAT_DARWIN.
 1.39 03-Nov-2002  manu Added support for Darwin's PowerPC-only system calls:
ppccalls, with system call numbers starting at 0x6000
fasttraps, with system call numbers starting at 0x7FF0

Because the Mach system call dispatching code has grown a bit
too much, introduce an inline function to handle it (mach_syscall_dispatch).

While we are there, remove the Mach and Linux includes from
arch/powerpc/powerpc/syscall.c and push them into
arch/powerpc/powerpc/{mach|linux}_syscall.c
 1.38 30-Oct-2002  manu Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.37 30-Oct-2002  manu Prepare syscall.c for COMPAT_MACH support. linux_syscall_intern is
moved to a Linux specific file, child_return is moved to trap.c,
and we introduce a EMULNAME macro co that syscall.c can be included to
define the system call handler for another emulation.
 1.36 30-Oct-2002  manu Moved binary compatibility options from arch directory to cpu directory
 1.35 18-Aug-2002  matt defflag PMAPDEBUG, PMAPCHECK, and PMAPCOUNTERS into opt_pmap.h
 1.34 24-Jul-2002  chs reimplement copy{in,out}str() similarly to copy{in,out}()
(instead of the old way of calling [fs]ubyte() in a loop).
 1.33 17-Jul-2002  matt Add a common file to do pmap_zero_page/pmap_copy_page/pmap_pageidlezero and
pmap_syncicache. This file uses a ppc feature in a sick and twisted way
to avoid mapping the physical pages used by those routines. It performs
the operations with the MMU disabled but PPC exception save and retstore
the machine state and are invoked with the MMU disabled, this doesn't have
an adverse effect on the system.

Currently only enable for MPC6xx and !OLDPMAP.
 1.32 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.31 14-Mar-2002  eeh branches: 1.31.4;
Some files have been moved into powerpc/ibm4xx.
 1.30 09-Mar-2002  chs switch all mpc6xx powerpc ports to NEWPMAP by default.
the old pmap is still available with the OLDPMAP option.
 1.29 06-Jan-2002  dbj add support for kgdb over zs
 1.28 07-Dec-2001  bjh21 Change L2CR_CONFIG from defflag to defparam, since it takes an argument.
 1.27 28-Nov-2001  lukem - convert usage of "defopt" to "defflag" where the relevant option does
not support a value (e.g., it's to be used as "options FOO" instead of
"options FOO=xxx"). options that take a value were converted to
defparam recently.
- minor whitespace & formatting cleanups
 1.26 20-Nov-2001  lukem - replace "defopt" with "defparam" for options which must take a value,
as config(8) will warn for value-less defparam options
- minor whitespace/formatting cleanup
- consolidate opt_tcp_recvspace.h and opt_tcp_sendspace.h into opt_tcp_space.h
 1.25 20-Nov-2001  lukem cleanup:
options SPACE TAB
makeoptions TAB
psuedo-device TAB
remove trailing whitespace
replace multiple spaces -> tabs
options "FOO" -> options FOO
options "FOO=bar" -> options FOO=bar
options "FOO=\"bar\"" -> options FOO="\"bar\""
 1.24 30-Aug-2001  briggs branches: 1.24.6;
Create an opt_openpic.h and add both OPENPIC and OPENPIC_SERIAL_MODE to it.
 1.23 26-Aug-2001  matt Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.22 20-Jun-2001  briggs branches: 1.22.2;
Build for kgdb as well as for ddb (mutually exclusive).
 1.21 17-Jun-2001  tsubai Forgot to commit this -- move file .../bus_dma.c line to files.${machine}.
 1.20 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.19 10-Jun-2001  tsubai Make the new pmap optional. Use the old (stable!) pmap by default.
 1.18 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.17 24-Feb-2001  matt branches: 1.17.2;
Add powerpc/powerpc/powerpc_machdep.c
 1.16 04-Feb-2001  briggs defopt openpic
 1.15 02-Feb-2001  briggs Split OpenPIC support into powerpc so ports only need minimal custom
configuration. openpic_init() now takes a single argument that is the
base of the OpenPIC register space.
 1.14 25-Nov-2000  matt Add placeholder for AltiVec support file.
 1.13 14-Feb-2000  thorpej Allow arch-specific code to specify in4_cksum() like it can specify
in_cksum().
 1.12 17-Nov-1999  kleink Move signal management code common to all PowerPC platforms (sendsig(),
sigreturn(), sigcode) to a single place in the shared powerpc directory.
(The struct sigcontext etc. definitions were already being shared.)
 1.11 15-Feb-1999  hubertf branches: 1.11.8; 1.11.14;
RCS ID police
 1.10 18-Sep-1998  sakamoto powerpc/bcopy.c is unnecessary.
 1.9 13-Sep-1998  thorpej Make signal delivery work again.
 1.8 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.7 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.6 23-Feb-1998  mycroft Slight rearrangement.
 1.5 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.4 05-Jan-1998  perry RCSID Police.
 1.3 16-Apr-1997  thorpej - Pull in new ofwmagic.S and soft_spl.c files
- firepowerbugs -> firmworksbugs
 1.2 16-Oct-1996  ws Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.1 30-Sep-1996  ws PowerPC port
 1.11.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.8.4 12-Mar-2001  bouyer Sync with HEAD.
 1.11.8.3 11-Feb-2001  bouyer Sync with HEAD.
 1.11.8.2 08-Dec-2000  bouyer Sync with HEAD.
 1.11.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.17.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.22.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.22.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.22.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.22.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.22.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.24.6.9 11-Dec-2002  thorpej Sync with HEAD.
 1.24.6.8 11-Nov-2002  nathanw Catch up to -current
 1.24.6.7 27-Aug-2002  nathanw Catch up to -current.
 1.24.6.6 01-Aug-2002  nathanw Catch up to -current.
 1.24.6.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.24.6.4 28-Feb-2002  nathanw Catch up to -current.
 1.24.6.3 11-Jan-2002  nathanw More catchup.
 1.24.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.24.6.1 30-Aug-2001  nathanw file files.powerpc was added on branch nathanw_sa on 2002-01-08 00:27:08 +0000
 1.31.4.3 31-Aug-2002  gehenna catch up with -current.
 1.31.4.2 21-Jul-2002  gehenna catch up with -current.
 1.31.4.1 16-Jul-2002  gehenna catch up with -current.
 1.49.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.49.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.49.2.1 03-Aug-2004  skrll Sync with HEAD
 1.60.2.7 11-Feb-2008  yamt sync with head.
 1.60.2.6 04-Feb-2008  yamt sync with head.
 1.60.2.5 21-Jan-2008  yamt sync with head
 1.60.2.4 27-Oct-2007  yamt sync with head.
 1.60.2.3 03-Sep-2007  yamt sync with head.
 1.60.2.2 26-Feb-2007  yamt sync with head.
 1.60.2.1 30-Dec-2006  yamt sync with head.
 1.61.8.1 11-Aug-2006  yamt sync with head
 1.61.4.1 09-Sep-2006  rpaulo sync with head
 1.62.4.1 28-Jan-2007  ad powerpc changes.
 1.63.14.3 03-Oct-2007  garbled Sync with HEAD
 1.63.14.2 15-Aug-2007  macallan add a config option to control the number of ranges we can bus_space_map()
per bus, also bump it from 8 to 20 so all PCI devices in my iBook work
again.
 1.63.14.1 02-Aug-2007  macallan sync with HEAD
 1.63.8.1 11-Jul-2007  mjf Sync with head.
 1.63.6.2 23-Oct-2007  ad Sync with head.
 1.63.6.1 15-Jul-2007  ad Sync with head.
 1.64.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.64.12.1 18-Oct-2007  yamt sync with head.
 1.64.10.3 23-Mar-2008  matt sync with HEAD
 1.64.10.2 09-Jan-2008  matt sync with HEAD
 1.64.10.1 06-Nov-2007  matt sync with HEAD
 1.64.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.65.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.65.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.69.28.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.69.28.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.69.28.1 07-Jan-2011  matt Add booke support.
 1.69.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.69.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.69.10.2 11-Mar-2010  yamt sync with head
 1.69.10.1 04-May-2009  yamt sync with head.
 1.69.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.71.4.5 30-Oct-2010  uebayasi xmd_machdep.c is gone.
 1.71.4.4 25-Aug-2010  uebayasi Indent.
 1.71.4.3 19-Aug-2010  uebayasi Initial addition of xmd(4), XIP memory disk.
 1.71.4.2 11-Aug-2010  uebayasi Support bus_space_physload(9) and friends.
 1.71.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.72.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.72.2.4 12-Jun-2011  rmind sync with head
 1.72.2.3 31-May-2011  rmind sync with head
 1.72.2.2 05-Mar-2011  rmind sync with head
 1.72.2.1 18-Mar-2010  rmind Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.

Work and depression still in progress.
 1.73.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.76.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.82.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.82.6.1 05-Apr-2012  mrg sync to latest -current.
 1.82.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.82.2.2 30-Oct-2012  yamt sync with head
 1.82.2.1 17-Apr-2012  yamt sync with head
 1.83.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.83.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.85.2.1 18-May-2014  rmind sync with head
 1.89.28.2 28-Jul-2018  pgoyette Sync with HEAD
 1.89.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.90.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.90.2.1 10-Jun-2019  christos Sync with HEAD
 1.92.6.1 29-Feb-2020  ad Sync with head.
 1.92.4.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #730):

sys/arch/powerpc/conf/files.powerpc: revision 1.93
sys/arch/powerpc/include/pio.h: revision 1.8
sys/arch/powerpc/pic/intr.c: revision 1.27
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.50
sys/arch/powerpc/powerpc/pio_subr.S: revision 1.17

Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)

-

eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.97.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 14-Jan-2007  aymeric branches: 1.1.2; 1.1.6;
Basic support for RTAS (CHRP's Run-Time Abstraction Services).
Tested on the Efika; now it knows what time it is.
rtas can attach to mainbus. Not added to any kernel config file yet.
 1.1.6.2 26-Feb-2007  yamt sync with head.
 1.1.6.1 14-Jan-2007  yamt file files.rtas was added on branch yamt-lazymbuf on 2007-02-26 09:07:51 +0000
 1.1.2.2 01-Feb-2007  ad Sync with head.
 1.1.2.1 14-Jan-2007  ad file files.rtas was added on branch newlock2 on 2007-02-01 08:48:10 +0000
 1.4 24-Aug-2015  uebayasi Don't mention stab and DWARF sections, because these (poorly mtaintained)
lists only help to make them harder to read.

If those sections are found in inputs, they simply appear in outputs as
orphaned sections, sorted by section types and attributes.
 1.3 21-Aug-2015  uebayasi I bet setting search-directory for ld.so is useless in any kernel.
 1.2 20-Aug-2015  uebayasi Indent with 2 spaces.
 1.1 29-Mar-2012  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.22;
Add ldscript which aligns .data to a 1MB boundary. (used for testing)
 1.1.22.1 22-Sep-2015  skrll Sync with HEAD
 1.1.8.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 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.1.6.1 29-Mar-2012  riz file kern-mb.ldscript was added on branch netbsd-6 on 2012-05-09 22:42:31 +0000
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 29-Mar-2012  yamt file kern-mb.ldscript was added on branch yamt-pagecache on 2012-04-17 00:06:46 +0000
 1.1.2.2 05-Apr-2012  mrg sync to latest -current.
 1.1.2.1 29-Mar-2012  mrg file kern-mb.ldscript was added on branch jmcneill-usbmp on 2012-04-05 21:33:18 +0000
 1.9 24-Aug-2015  uebayasi Don't mention stab and DWARF sections, because these (poorly mtaintained)
lists only help to make them harder to read.

If those sections are found in inputs, they simply appear in outputs as
orphaned sections, sorted by section types and attributes.
 1.8 21-Aug-2015  uebayasi I bet setting search-directory for ld.so is useless in any kernel.
 1.7 20-Aug-2015  uebayasi Indent with 2 spaces.
 1.6 19-Jan-2014  mrg branches: 1.6.6;
make this look more like the latest elf32ppc.x. tested on pegasosII.
 1.5 16-Nov-2013  mrg make sure that .text.startup and .text.unlikely end up in the
text section. GCC 4.8 ofppc kernels now boot, though they are
unable to load the symbol table correctly.

also tested with GCC 4.5 and ofppc (pegasosII.)
 1.4 12-Feb-2011  matt branches: 1.4.2; 1.4.6; 1.4.16; 1.4.20;
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.3 23-Jan-2011  matt Add support for __read_mostly and __cacheline_aligned (using 32 bytes as
the cacheline as its the most prevalent sized used even though IBM970 has
a 128 byte cacheline).
 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 kern.ldscript 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.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.4.20.1 18-May-2014  rmind sync with head
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 12-Feb-2011  rmind file kern.ldscript was added on branch rmind-uvmplock on 2011-03-05 20:51:35 +0000
 1.6.6.1 22-Sep-2015  skrll Sync with HEAD
 1.4 24-Aug-2015  uebayasi Don't mention stab and DWARF sections, because these (poorly mtaintained)
lists only help to make them harder to read.

If those sections are found in inputs, they simply appear in outputs as
orphaned sections, sorted by section types and attributes.
 1.3 21-Aug-2015  uebayasi I bet setting search-directory for ld.so is useless in any kernel.
 1.2 20-Aug-2015  uebayasi Indent with 2 spaces.
 1.1 19-Apr-2014  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; 1.1.12;
ldscript for ppc64 kernels
 1.1.12.1 22-Sep-2015  skrll Sync with HEAD
 1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 19-Apr-2014  tls file kern64.ldscript was added on branch tls-maxphys on 2014-08-20 00:03:19 +0000
 1.1.6.2 10-Aug-2014  tls Rebase.
 1.1.6.1 19-Apr-2014  tls file kern64.ldscript was added on branch tls-earlyentropy on 2014-08-10 06:54:05 +0000
 1.1.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.1 19-Apr-2014  yamt file kern64.ldscript was added on branch yamt-pagecache on 2014-05-22 11:40:03 +0000
 1.1.2.2 18-May-2014  rmind sync with head
 1.1.2.1 19-Apr-2014  rmind file kern64.ldscript was added on branch rmind-smpnet on 2014-05-18 17:45:22 +0000
 1.17 29-Jun-2021  nia Remove uscanner(4) driver

This exists for compatibility with a Linux interface which was apparently
deprecated in Linux 2.6. There are various mailing list threads going
back to 2004 where the usefulness of this driver is discussed, but
the conclusion is that scanner software has all moved to using ugen(4)
instead, and enabling this driver will not help you scan things.
 1.16 04-Apr-2020  jdolecek branches: 1.16.8;
mark nsmb major obsolete
 1.15 29-Jan-2020  maya remove urio(4), a driver for the Rio500 MP3 player.

At this point it is highly unlikely this 1999 device still has users,
but it still comes up in the context of maxv's USB-fuzzing (and any device
could pretend to be a urio(4)), so it's best to get rid of it.

Renamed all major entries to obsolete, as was done in previous removals.

This still requires an update to sanitizers, but they're located in
"external", perhaps it should be first committed upstream?

Proposed on tech-kern a month ago.
 1.14 28-Jan-2019  dholland branches: 1.14.6;
Systematize handling of removed drivers.

- Every driver that was removed and whose number hasn't already been
reused is now listed with a commented-out "obsolete" line.
- The format of these has been systematized. Future format changes can
probably be safely done with a script.
- This does not include a few cases of assignments that only lasted a
couple days, or stuff from before major reorgs. Some of these may
be included nonetheless, because there was a lot of ground to cover
and therefore not a lot of time to dig into history in detail.

Note that the obsolete listings do not mean the major numbers can
never be reused; that's up to portmasters and/or core. It does mean
that they won't be reused by accident, however, which in some cases
(depending on the driver, how widely used it was, its family of device
nodes, their default permissions, etc.) can be quite dangerous.

Note that some of the things now explicitly listed as obsolete are
really ancient history. My scan went back as far as when the majors
files were added. (But not before that.)
 1.13 27-Jan-2019  dholland Restore satlink's majors entries commented out and marked obsolete.
Otherwise they might accidentally get reused later and cause a
security problem.
 1.12 27-Jan-2019  maxv Remove the satlink driver. It was disabled everywhere, had no man page and
no use either. Spotted by thorpej in PR/21345, ok christos.
 1.11 23-Sep-2018  maxv Remove ISDN from the kernel. It has remained unmaintained for a long time,
is of poor quality, and is now an obstacle to MP-ification. It was removed
ten years ago from FreeBSD for the same reason.

This retires a big user of the mbuf API, and will ease maintenance of the
kernel.
 1.10 08-Dec-2016  nat branches: 1.10.14; 1.10.16;
Add a synthesized pc beeper and keyboard bell for platforms with an audio
device.
 1.9 23-Apr-2015  pgoyette branches: 1.9.2;
Update device dependency information - the sysmon major device now depends on the sysmon module itself, not on the individual components.
 1.8 30-Jun-2011  wiz branches: 1.8.12; 1.8.30;
dependant -> dependent
 1.7 01-Mar-2011  phx Revert the major number for satmgr(4) back to 100 and allocate it from
majors.powerpc, as suggested by matt@.
 1.6 29-May-2010  phx branches: 1.6.2; 1.6.4;
sysmon_power is needed to be able to use powerd(8).
 1.5 06-Mar-2010  plunky branches: 1.5.2;
use a MI major number for uhso(4) driver
(requested by mrg)
 1.4 06-Mar-2010  plunky add major device for usho(4) driver
 1.3 12-Nov-2008  ad branches: 1.3.6;
Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.2 31-Dec-2007  ad branches: 1.2.2; 1.2.4; 1.2.10; 1.2.14; 1.2.20; 1.2.22;
Remove systrace. Ok core@.
 1.1 10-Dec-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
Add a new majors.powerpc. This was cobbled together from the majors
files of all the different powerpc ports (except amigappc). It should be
compatible with sandpoint and macppc. It is compatible with evbppc minus
one device (gtmpsc).

To convert a port to use this file rather than a local one, delete your
majors file, and edit your files.port to point to this instead. (I will
follow up with a MAKEDEV fix to support this)
 1.1.10.2 26-Dec-2007  ad Sync with head.
 1.1.10.1 10-Dec-2007  ad file majors.powerpc was added on branch vmlocking2 on 2007-12-26 19:17:17 +0000
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 10-Dec-2007  mjf file majors.powerpc was added on branch mjf-devfs on 2008-02-18 21:04:57 +0000
 1.1.6.3 02-Jan-2008  bouyer Sync with HEAD
 1.1.6.2 13-Dec-2007  bouyer Sync with HEAD
 1.1.6.1 10-Dec-2007  bouyer file majors.powerpc was added on branch bouyer-xeni386 on 2007-12-13 21:54:52 +0000
 1.1.2.2 11-Dec-2007  yamt sync with head.
 1.1.2.1 10-Dec-2007  yamt file majors.powerpc was added on branch yamt-kmem on 2007-12-11 15:20:39 +0000
 1.2.22.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.20.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.14.2 11-Aug-2010  yamt sync with head.
 1.2.14.1 04-May-2009  yamt sync with head.
 1.2.10.1 17-Jan-2009  mjf Sync with HEAD.
 1.2.4.2 21-Jan-2008  yamt sync with head
 1.2.4.1 31-Dec-2007  yamt file majors.powerpc was added on branch yamt-lazymbuf on 2008-01-21 09:38:20 +0000
 1.2.2.2 09-Jan-2008  matt sync with HEAD
 1.2.2.1 31-Dec-2007  matt file majors.powerpc was added on branch matt-armv6 on 2008-01-09 01:47:46 +0000
 1.3.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.5.2.2 05-Mar-2011  rmind sync with head
 1.5.2.1 30-May-2010  rmind sync with head
 1.6.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.30.2 05-Feb-2017  skrll Sync with HEAD
 1.8.30.1 06-Jun-2015  skrll Sync with HEAD
 1.8.12.1 03-Dec-2017  jdolecek update from HEAD
 1.9.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.16.1 10-Jun-2019  christos Sync with HEAD
 1.10.14.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.14.6.1 29-Feb-2020  ad Sync with head.
 1.16.8.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 13-Jun-2001  simonb branches: 1.1.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file files.fpu was added on branch nathanw_sa on 2001-06-13 06:01:47 +0000
 1.7 06-Sep-2022  rin Fix priority for NaN propagation: frA > frB > frC.
 1.6 01-Sep-2022  rin Do not raise SNaN exception for QNaN.
 1.5 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_add.c was added on branch nathanw_sa on 2001-06-13 06:01:47 +0000
 1.4 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_arith.h was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.8 08-Sep-2022  rin fpu_compare(): Assign r by using return value from fpu_sub(),
instead of directly using &fe->fe_f3. NFC; only for clarity.
 1.7 08-Sep-2022  rin fpu_compare(): Fix inverted logic and comment it out for now.

VXVC is raised for SNaN if VE == 0.

As we still do not support enabled exception bits, comment out
this if statement for consistency at the moment.
 1.6 04-Sep-2022  rin Fix logic for FI, FR, and FPRF fields of FPSCR.

They are not sticky bits and updated by arithmetic and round
insns at the same time.

Comparison insns update only FPCC sub-field of FPRF.

For other insns, these field are left untouched.

Also, for single-precision insns, exception bits should be set by
the first fpu_implode(), which rounds the value to float.
 1.5 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_compare.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.9 06-Sep-2022  rin Fix priority for NaN propagation: frA > frB > frC.
 1.8 04-Sep-2022  rin Trailing white-space/TAB.
 1.7 01-Sep-2022  rin Do not raise SNaN exception for QNaN.
 1.6 15-Jul-2020  rin Do not raise divide-by-zero exception when dividend is zero.
 1.5 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_div.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.60 20-Sep-2022  rin Typo in comment. No binary changes.
 1.59 20-Sep-2022  rin stfs{,x}{,u}: Switch to conversion algorithm specified by Power ISA.

The ISA specifies algorithm for most bit patterns in double format, that
are not representable in float. I believe that sane people do not rely on
such a specification detail, but *REAL* programmers may utilize it ;)

Instead of complicating fpu_explode(), single-purpose helper function,
fpu_to_single(), is introduced. See comment therein for more details.
 1.58 15-Sep-2022  rin fnm{add,sub}{,s}: Do not negate NaN.
 1.57 15-Sep-2022  rin fpu_execute(): Use FR() macro. No binary changes.
 1.56 09-Sep-2022  rin G/C ``notyet''; OPC_load_st_62 == std{,u} are integer insns.
No binary changes.
 1.55 07-Sep-2022  rin Fix mnemonics for fm{add,sub}. NFC except for evcnt(9) names.
 1.54 05-Sep-2022  rin static-fy fpu_execute().
 1.53 04-Sep-2022  rin Trailing white-space/TAB.
 1.52 04-Sep-2022  rin Simplify; no need to override ``type'' here. NFC.
 1.51 04-Sep-2022  rin Update FR and FI (and undefined FPRF) for ``round to integer'' insns.
 1.50 04-Sep-2022  rin Fix logic for FI, FR, and FPRF fields of FPSCR.

They are not sticky bits and updated by arithmetic and round
insns at the same time.

Comparison insns update only FPCC sub-field of FPRF.

For other insns, these field are left untouched.

Also, for single-precision insns, exception bits should be set by
the first fpu_implode(), which rounds the value to float.
 1.49 03-Sep-2022  rin Localize addr and buf. NFC.
 1.48 03-Sep-2022  rin Fix weird logic. NFC.

Set both type and size to double by default, and change both to
single if required.
 1.47 03-Sep-2022  rin Do not use ``cond'' for two purposes: flag and bit field.
For the latter, use ``bits'' instead. Switch ``cond'' to int.
NFC.
 1.46 02-Sep-2022  rin Fix fres and frsqrte.
- Pass correct fp to succeeding fpu_implode().
- fres calculates 1 / frB; not 1 / sqrt(frB).
 1.45 02-Sep-2022  rin Make fpu_explode() and fpu_implode() take uint64_t and uint64_t *,
instead of register number, respectively. NFC.
 1.44 01-Sep-2022  rin Set FPSCR[FPRF] for calculated result, for all instructions
that are documented to update this field.

Exceptions are fcti{w,d}{,z}; FPSCR[FPRF] becomes undefined,
according to Power ISA. We do not overwrite this field for
these insns at the moment.
 1.43 30-Aug-2022  rin Fix fcti{w,d}{,z}.

- Treat 64-bit integer correctly for fctid{,z}.
- Respect round mode specified by FPSCR[RN].

XXX
- Set FPSCR[FR] and [FI] appropriately.
- Also set FPSCR[FPRF]?
- fctid{,z} traps on powerpc32 (confirmed on 603e and G4).
 1.42 30-Aug-2022  rin Fix fsel; frB is chosen when frA is negative or NaN.

For fpu_emu.c rev 1.41 or prior, wrong register was chosen for
NaN with sign bit being cleared.
 1.41 30-Aug-2022  rin Fix mcrfs; Clear copied exception bits, and do not raise any exception.
 1.40 30-Aug-2022  rin Misc clean up for mtfsf{,i}. NFC.
 1.39 30-Aug-2022  rin Fix mtfsb[01]; these can clear/set any FPSCR bits other than FEX and VX.
 1.38 30-Aug-2022  rin Fix logic for FPSCR[FEX].

It is logical OR (similar to FPSCR[VX]) of raised exception bits for
enabled exceptions.
 1.37 30-Aug-2022  rin Revert rev 1.29:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/fpu/fpu_emu.c#rev1.29

> FPSCR[FEX] is not a sticky bit; it is always cleared when read from
> userland via mffs on real hardware.

This turned out to be wrong. FEX is actually observed for 603e.
 1.36 27-Jul-2022  rin Correct stale comment. Thanks rillig@ for pointed out. NFC.
 1.35 26-Jul-2022  rin Fix copy-paste in comment. No binary changes.
 1.34 26-Jul-2022  rin Fix inverted logic; cr was completely broken by FPU insn with Rc == 1.

Why haven't we noticed this so far...
 1.33 15-Jul-2020  rin Now, FPU emulation for booke and ibm4xx works fine at a level where
all the related ATF tests pass correctly. However, there still remain
problems:

- FEX and VX bits for FPSCR cannot be modified by mcrfs, mtfsf{,i},
and mtfsb[01].
- Invalid operations should be treated differently depending on
FPSCR[VE].

Therefore, comment them in order not to be forgotten.

No binary changes.
 1.32 15-Jul-2020  rin Try to fix FPSCR bits in the end of emulation:

- FPSCR[FEX] is not a sticky bit.
- Turn on FPSCR[FEX] if the emulated instruction causes invalid operation,
and invalid operation exception is not masked out.
- FPSCR[VX] is not a sticky bit, however it should be set when at least
one of FPSCR[VXfoo] bits (they are sticky!) is set.
- FPSCR[FX] is a sticky bit, and it should be set if FPSCR is modified by
instructions other than mtfsf{,i}.
 1.31 15-Jul-2020  rin Set ksi_code correctly via fpu_get_fault_code() for SIGFPE.
 1.30 15-Jul-2020  rin Do not raise SIGFPE unless MSR[FE0] or MSR[FE1] is set via fenv(3).
 1.29 15-Jul-2020  rin FPSCR[FEX] is not a sticky bit; it is always cleared when read from
userland via mffs on real hardware.
 1.28 15-Jul-2020  rin PR port-powerpc/55425

Fix emulation for mtfsf; source register is frB here.

Now, userland processes successfully change rounding mode, by which
FPU-optimized code in OpenSSL works just fine as far as I can see.
 1.27 15-Jul-2020  rin For trap instruction, ksi_code should be TRAP_BRKPT not TRAP_TRACE.
 1.26 15-Jul-2020  rin Do not set ksi->ksi_addr twice. No functional changes.
 1.25 15-Jul-2020  rin Remove old workaround foe cache problem on ibm4xx.
The problem seems gone already.
 1.24 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.23 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.22 27-Jun-2020  rin fpu_dumpfpn(): Add KASSERT to check argument != NULL.
 1.21 27-Jun-2020  rin fpu_dumpfpn(): Add missing \n in printf() format.
 1.20 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.19 28-Dec-2016  rin PR port-powerpc/51368: powerpc FPU emulation fails for single precision
floating point arithmetic

For single precision instruction, calculate first in double precision,
and then round it. With this fix, single precision arithmetic gets sane
on ibm4xx and booke.

Taken from FreeBSD commit r258250:
https://svnweb.freebsd.org/base?view=revision&revision=258250

Ok matt and simonb.
 1.18 15-Dec-2016  rin Fix build without DDB.
 1.17 12-Aug-2014  joerg branches: 1.17.2; 1.17.4;
Avoid unncessary use of double in the kernel. With this change,
a LLVM build kernel fully works on TWRP1025.
 1.16 23-Jul-2012  matt branches: 1.16.2; 1.16.14; 1.16.18;
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.15 18-Jan-2011  matt branches: 1.15.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.14 11-Dec-2005  christos branches: 1.14.100; 1.14.104; 1.14.106;
merge ktrace-lwp.
 1.13 03-Jun-2005  scw Appease -Wcast-qual
 1.12 15-Sep-2004  scw It helps to call fpu_sqrt() when dealing with the frsqrte instruction.
 1.11 30-Mar-2004  simonb Make the "cond" variable an unsigned variable. Stops sign extension
problems when we shift it left and right while creating the new value
for the condition register.

Fixes problems reported by Juergen Hannken-Illjes in toolchain/24938.
 1.10 27-Oct-2003  simonb branches: 1.10.2;
Fix a bogus uninitialised warning.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 07-Feb-2003  thorpej branches: 1.7.2;
Fix some printf formats.
 1.6 25-Nov-2002  thorpej Avoid strict-alias warnings.
 1.5 25-Nov-2002  thorpej Remove an unnecessary token-paste, as pointed out by GCC 3.3.
 1.4 24-Nov-2002  thorpej Instrument FP emulation traps.
 1.3 22-Jul-2001  wiz branches: 1.3.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.2 22-Jun-2001  simonb branches: 1.2.2;
Make this compile when DEBUG isn't defined.
 1.1 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.2.2.1 03-Aug-2001  lukem update to -current
 1.3.6.2 11-Dec-2002  thorpej Sync with HEAD.
 1.3.6.1 22-Jul-2001  thorpej file fpu_emu.c was added on branch nathanw_sa on 2002-12-11 06:11:37 +0000
 1.7.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 30-Mar-2004  jmc Pullup rev 1.11 (requested by simonb in ticket #18)

Make the "cond" variable an unsigned variable. PR#24938
 1.14.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.104.1 07-Jan-2011  matt Adapt to new trapframe.
 1.14.100.1 05-Mar-2011  rmind sync with head
 1.15.6.1 30-Oct-2012  yamt sync with head
 1.16.18.1 18-Jan-2017  skrll Sync with netbsd-5
 1.16.14.2 03-Jan-2017  snj Pull up following revision(s) (requested by rin in ticket #1342):
sys/arch/powerpc/fpu/fpu_emu.c: revision 1.18
Fix build without DDB.
 1.16.14.1 03-Jan-2017  snj Pull up following revision(s) (requested by rin in ticket #1341):
sys/arch/powerpc/fpu/fpu_emu.c: revision 1.19
sys/arch/powerpc/fpu/fpu_explode.c: revision 1.7
- add missing default from FreeBSD
- remove duplicate panic pointed out by matt
--
PR port-powerpc/51368: powerpc FPU emulation fails for single precision
floating point arithmetic
For single precision instruction, calculate first in double precision,
and then round it. With this fix, single precision arithmetic gets sane
on ibm4xx and booke.
Taken from FreeBSD commit r258250:
https://svnweb.freebsd.org/base?view=revision&revision=258250
Ok matt and simonb.
 1.16.2.1 03-Dec-2017  jdolecek update from HEAD
 1.17.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.2.1 05-Feb-2017  skrll Sync with HEAD
 1.12 07-Sep-2022  rin Turn fpu_sub() macro into static inline function for clarity.
No binary changes.
 1.11 06-Sep-2022  rin fpu_sub(): Do not invert sign bit of NaN.

Taken from FreeBSD:
https://cgit.freebsd.org/src/commit/lib/libc/sparc64/fpu?h=releng/12.3&id=8ff9d52cd08cbf31efde4052d3593a5680eaa2a5
 1.10 05-Sep-2022  rin Clean up fpu_extern.h; only a function public to external is fpu_emulate().

Other functions are private to fpu_*.c and therefore live in fpu_emu.h.

Also, drop needless forward struct declarations.

NFC.
 1.9 04-Sep-2022  rin Fix logic for FI, FR, and FPRF fields of FPSCR.

They are not sticky bits and updated by arithmetic and round
insns at the same time.

Comparison insns update only FPCC sub-field of FPRF.

For other insns, these field are left untouched.

Also, for single-precision insns, exception bits should be set by
the first fpu_implode(), which rounds the value to float.
 1.8 02-Sep-2022  rin Make fpu_explode() and fpu_implode() take uint64_t and uint64_t *,
instead of register number, respectively. NFC.
 1.7 01-Sep-2022  rin Set FPSCR[FPRF] for calculated result, for all instructions
that are documented to update this field.

Exceptions are fcti{w,d}{,z}; FPSCR[FPRF] becomes undefined,
according to Power ISA. We do not overwrite this field for
these insns at the moment.
 1.6 30-Aug-2022  rin Fix fcti{w,d}{,z}.

- Treat 64-bit integer correctly for fctid{,z}.
- Respect round mode specified by FPSCR[RN].

XXX
- Set FPSCR[FR] and [FI] appropriately.
- Also set FPSCR[FPRF]?
- fctid{,z} traps on powerpc32 (confirmed on 603e and G4).
 1.5 30-Aug-2022  rin Move FTYPE_* definitions from instr.h to fpu_emu.h.

They are not defined by architecture, and used only for FPU emulation.
 1.4 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.3 11-Dec-2005  christos branches: 1.3.112;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_emu.h was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.3.112.1 30-Oct-2012  yamt sync with head
 1.14 07-Sep-2022  rin fpu_explode(): Fix sign for FTYPE_INT.

NFC for now; conversion for this type is used only for immediate 1.
 1.13 05-Sep-2022  rin static-fy fpu_[ixsd]tof(). NFC.
 1.12 02-Sep-2022  rin Make fpu_explode() and fpu_implode() take uint64_t and uint64_t *,
instead of register number, respectively. NFC.
 1.11 02-Sep-2022  rin Use hi and lo for higher and lower words, instead of i and j.
No binary changes.
 1.10 28-Aug-2022  rin u_int64_t --> uint64_t. No binary changes.
 1.9 27-Jun-2020  rin Remove extra newline in DPRINTF().
 1.8 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.7 28-Dec-2016  rin - add missing default from FreeBSD
- remove duplicate panic pointed out by matt
 1.6 11-Dec-2005  christos branches: 1.6.122; 1.6.140; 1.6.142; 1.6.146; 1.6.148;
merge ktrace-lwp.
 1.5 28-Oct-2003  chs make this compile again.
 1.4 27-Oct-2003  simonb Remove (the now non-compiling) support for 128bit FP emulation, which
isn't needed for PowerPC anyway.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_explode.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.6.148.1 18-Jan-2017  skrll Sync with netbsd-5
 1.6.146.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.142.1 05-Feb-2017  skrll Sync with HEAD
 1.6.140.1 03-Jan-2017  snj Pull up following revision(s) (requested by rin in ticket #1341):
sys/arch/powerpc/fpu/fpu_emu.c: revision 1.19
sys/arch/powerpc/fpu/fpu_explode.c: revision 1.7
- add missing default from FreeBSD
- remove duplicate panic pointed out by matt
--
PR port-powerpc/51368: powerpc FPU emulation fails for single precision
floating point arithmetic
For single precision instruction, calculate first in double precision,
and then round it. With this fix, single precision arithmetic gets sane
on ibm4xx and booke.
Taken from FreeBSD commit r258250:
https://svnweb.freebsd.org/base?view=revision&revision=258250
Ok matt and simonb.
 1.6.122.1 03-Dec-2017  jdolecek update from HEAD
 1.12 05-Sep-2022  rin Clean up fpu_extern.h; only a function public to external is fpu_emulate().

Other functions are private to fpu_*.c and therefore live in fpu_emu.h.

Also, drop needless forward struct declarations.

NFC.
 1.11 05-Sep-2022  rin static-fy fpu_execute().
 1.10 05-Sep-2022  rin static-fy fpu_[ixsd]tof(). NFC.
 1.9 02-Sep-2022  rin Make fpu_explode() and fpu_implode() take uint64_t and uint64_t *,
instead of register number, respectively. NFC.
 1.8 01-Sep-2022  rin static-fy fpu_fto[ixsd](). NFC.
 1.7 30-Aug-2022  rin Fix fcti{w,d}{,z}.

- Treat 64-bit integer correctly for fctid{,z}.
- Respect round mode specified by FPSCR[RN].

XXX
- Set FPSCR[FR] and [FI] appropriately.
- Also set FPSCR[FPRF]?
- fctid{,z} traps on powerpc32 (confirmed on 603e and G4).
 1.6 28-Aug-2022  rin u_int64_t --> uint64_t. No binary changes.
 1.5 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.4 28-Apr-2008  martin branches: 1.4.34;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.76; 1.3.78;
merge ktrace-lwp.
 1.2 27-Oct-2003  simonb Remove (the now non-compiling) support for 128bit FP emulation, which
isn't needed for PowerPC anyway.
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_extern.h was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.3.78.1 16-May-2008  yamt sync with head.
 1.3.76.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.34.1 30-Oct-2012  yamt sync with head
 1.24 14-Sep-2022  rin Fix logic for FPSCR[OX]; set FPSCR[FI] (and therefore FPSCR[XX]).
 1.23 14-Sep-2022  rin Fix logic for FPSCR[UX]:
- Correct FPSCR[FPRF] field when round to 0.0 or 0.0f.
- Simplify.
 1.22 04-Sep-2022  rin Simplify logic to remove needless goto. NFC.
 1.21 04-Sep-2022  rin Fix logic for FI, FR, and FPRF fields of FPSCR.

They are not sticky bits and updated by arithmetic and round
insns at the same time.

Comparison insns update only FPCC sub-field of FPRF.

For other insns, these field are left untouched.

Also, for single-precision insns, exception bits should be set by
the first fpu_implode(), which rounds the value to float.
 1.20 04-Sep-2022  rin Fix debug printf. Unbreak DEBUG build.
 1.19 04-Sep-2022  rin Remove extra break.
 1.18 02-Sep-2022  rin fpu_implode(): Clear lower word for float just for sure.
 1.17 02-Sep-2022  rin Make fpu_explode() and fpu_implode() take uint64_t and uint64_t *,
instead of register number, respectively. NFC.
 1.16 02-Sep-2022  rin Fix off-by-one error in exponent when round a double to the
largest normalized value; QNaN was wrongly generated here.
 1.15 02-Sep-2022  rin Make fpu_ftod() return uint64_t value. NFC.
 1.14 01-Sep-2022  rin Set FPSCR[FPRF] for calculated result, for all instructions
that are documented to update this field.

Exceptions are fcti{w,d}{,z}; FPSCR[FPRF] becomes undefined,
according to Power ISA. We do not overwrite this field for
these insns at the moment.
 1.13 01-Sep-2022  rin static-fy fpu_fto[ixsd](). NFC.
 1.12 01-Sep-2022  rin Further fix for fcti{w,d}{,z}.

- Treat {Q,S}NaN correctly.
- Set exception bits appropriately.
- Introduce round_int().
 1.11 01-Sep-2022  rin Remove stale comment.
 1.10 30-Aug-2022  rin Fix fcti{w,d}{,z}.

- Treat 64-bit integer correctly for fctid{,z}.
- Respect round mode specified by FPSCR[RN].

XXX
- Set FPSCR[FR] and [FI] appropriately.
- Also set FPSCR[FPRF]?
- fctid{,z} traps on powerpc32 (confirmed on 603e and G4).
 1.9 30-Aug-2022  rin Do not assert FPSCR[UX] when overflow.
 1.8 28-Aug-2022  rin u_int64_t --> uint64_t. No binary changes.
 1.7 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Jul-2005  simonb KNF nit.
 1.4 27-Oct-2003  simonb branches: 1.4.16;
Remove (the now non-compiling) support for 128bit FP emulation, which
isn't needed for PowerPC anyway.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_implode.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.8 06-Sep-2022  rin fpu_mul(): Do not multiply sign bits for NaN.
 1.7 06-Sep-2022  rin Fix priority for NaN propagation: frA > frB > frC.
 1.6 01-Sep-2022  rin Do not raise SNaN exception for QNaN.
 1.5 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_mul.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.14 06-Sep-2022  rin Style sync with other parts of this file, as well as FreeBSD:
https://cgit.freebsd.org/src/commit/sys/powerpc/fpu/fpu_sqrt.c?id=81dd9c5e69a2709ae3317dd383093e1c8a970d9e

NFC since q is initialized to zero just above.
 1.13 06-Sep-2022  rin Fix errors in calculation of intermediate mantissa bits > 95.

NFC since this does not affect the final results; we do not
support any extended-precision formats at the moment (never?).

Taken from FreeBSD:
https://cgit.freebsd.org/src/commit/sys/powerpc/fpu/fpu_sqrt.c?id=81dd9c5e69a2709ae3317dd383093e1c8a970d9e
except for stylistic changes that will be committed soon.
 1.12 06-Sep-2022  rin IEEE 754 and Power ISA require sqrt(+0) = +0 and sqrt(-0) = -0, not Inf.
 1.11 01-Sep-2022  rin Do not raise SNaN exception for QNaN.
 1.10 24-May-2022  andvar s/equivalant/equivalent/ in copy pasted comment.
 1.9 27-Jun-2020  rin Return +INF without exception for +INF, as required by the architecture.
Also, avoid NULL dereference for fpu_dumpfpn() aka DUMPFPN().

Taken from (remaining part of) FreeBSD Revision 343078:
https://svnweb.freebsd.org/base?view=revision&revision=343078
 1.8 27-Jun-2020  rin Fix typo in DPRINTF.
 1.7 27-Jun-2020  rin Set FPSCR[VXSQRT] for non-zero negative operand.

Taken from (a part of) FreeBSD Revision 343078:
https://svnweb.freebsd.org/base?view=revision&revision=343078
 1.6 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.5 25-Feb-2014  martin Mark a temporary as __USEd
 1.4 11-Dec-2005  christos branches: 1.4.112; 1.4.122; 1.4.128;
merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_sqrt.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.4.128.1 18-May-2014  rmind sync with head
 1.4.122.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.112.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9 06-Sep-2022  rin FPU generates QNaN with all payload bits being cleared.
 1.8 04-Sep-2022  rin Unconditionally include <sys/systm.h> for KASSERT{,MSG}().
Fix (!DIAGNOSTIC && !DEBUG) build.
 1.7 02-Sep-2022  rin fpu_subr.c: Convert #ifdef DIAGNOSTIC panic() --> KASSERT{,MSG}().
 1.6 01-Sep-2022  rin Do not raise SNaN exception for QNaN.
 1.5 27-Jun-2020  rin Sort headers. No functional changes intended.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file fpu_subr.c was added on branch nathanw_sa on 2001-06-13 06:01:48 +0000
 1.8 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.7 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 07-Oct-2006  tsutsui branches: 1.6.4;
Fix an obvious typo. Patch from seebs in PR port-powerpc/33107.
 1.5 11-Dec-2005  christos branches: 1.5.20; 1.5.22;
merge ktrace-lwp.
 1.4 03-Aug-2003  eeh branches: 1.4.16;
Use %r<n> for register names.
 1.3 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.2 19-Dec-2002  thorpej branches: 1.2.2;
Merge the IBM 4xx into the common powerpc/locore_subr.S, and
eliminate all the duplicated context switch related code in
the IBM 4xx port.
 1.1 23-Aug-2002  scw branches: 1.1.2; 1.1.4; 1.1.6;
Split off common 4xx locore code so it can be re-used by other 4xx ports.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 23-Aug-2002  jdolecek file 4xx_locore.S was added on branch kqueue on 2002-09-06 08:39:01 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 23-Aug-2002  gehenna file 4xx_locore.S was added on branch gehenna-devsw on 2002-08-31 13:45:42 +0000
 1.1.2.4 19-Dec-2002  thorpej Sync with HEAD.
 1.1.2.3 19-Dec-2002  thorpej lwz -> lbz when loading the LWP priority.
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 23-Aug-2002  nathanw file 4xx_locore.S was added on branch nathanw_sa on 2002-08-27 23:45:05 +0000
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.2 03-Sep-2007  yamt sync with head.
 1.4.16.1 30-Dec-2006  yamt sync with head.
 1.5.22.1 22-Oct-2006  yamt sync with head
 1.5.20.1 18-Nov-2006  ad Sync with head.
 1.6.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.10 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.9 12-Jul-2020  rin Fix comment.

ibm4xx does not use powerpc/powerpc/trap_subr.S, but
powerpc/ibm4xx/trap_subr.S.
 1.8 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.7 19-May-2011  kiyohara branches: 1.7.56; 1.7.60;
+ Load TLB-miss-address from SRR0, if ITMISS.
+ Remove a white space.
 1.6 18-Jan-2011  matt 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.5 11-Dec-2005  christos branches: 1.5.100; 1.5.104; 1.5.106;
merge ktrace-lwp.
 1.4 03-Aug-2003  eeh Use %r<n> for register names.
 1.3 11-Mar-2003  hannken branches: 1.3.2;
Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.2 11-Jul-2002  simonb Clean up some white space niggles.
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.8; 1.1.16;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.16.1 16-Jul-2002  gehenna catch up with -current.
 1.1.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.8.1 13-Jun-2001  nathanw file 4xx_trap_subr.S was added on branch nathanw_sa on 2002-08-01 02:43:00 +0000
 1.1.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.104.1 07-Jan-2011  matt Deal with new powerpc world.
 1.5.100.2 31-May-2011  rmind sync with head
 1.5.100.1 05-Mar-2011  rmind sync with head
 1.7.60.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.7.56.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 18-Mar-2005  shige Remove MD codes from arch/powerpc/ibm4xx.
 1.1 13-Jan-2005  shige branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10;
Add device_register machine-independent-glue.
 1.1.10.1 14-Sep-2005  tron Apply patch (requested by shige in ticket #763):
Synchronize OpenBlockS266 port with NetBSD-current for enhanced stability.
 1.1.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.4.3 01-Apr-2005  skrll Sync with HEAD.
 1.1.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.1 13-Jan-2005  skrll file autoconf.c was added on branch ktrace-lwp on 2005-01-17 19:30:09 +0000
 1.1.2.1 29-Apr-2005  kent sync with -current
 1.4 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.3 05-May-2006  thorpej branches: 1.3.98;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.2 11-Dec-2005  christos branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12;
merge ktrace-lwp.
 1.1 17-Jan-2005  shige branches: 1.1.2; 1.1.10; 1.1.12; 1.1.14;
Add openbios-board related modules.
- openbios.c
getting board data memory image from openbios.
setting all board data to board properties database.
- board_prop.c
initialize board properties database.
(set/get board properties [macros in ibm4xx/cpu.h])
 1.1.14.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.1.14.1 17-Jan-2005  riz file board_prop.c was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.1.12.1 21-Jun-2006  yamt sync with head.
 1.1.10.2 29-Apr-2005  kent sync with -current
 1.1.10.1 17-Jan-2005  kent file board_prop.c was added on branch kent-audio2 on 2005-04-29 11:28:19 +0000
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 17-Jan-2005  skrll file board_prop.c was added on branch ktrace-lwp on 2005-01-24 08:34:26 +0000
 1.2.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.10.1 11-May-2006  elad sync with head
 1.2.8.1 24-May-2006  yamt sync with head.
 1.2.6.1 01-Jun-2006  kardel Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.3.98.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.32 05-Mar-2021  rin For Explora 451, call calc_delayconst() before pckbc_cnattach(), which
depends on delay() and DELAY().

Unfortunately, proplib(9) API is not available for MD codes, that are
called before consinit() (since pool(9) is not initialized yet).

Therefore, hard-code CPU frequency to calc_delayconst() in case
"processor-frequency" is not initialized.
 1.31 18-Jan-2021  rin Invoke hardclock() and statclock() in the interrupt context.

Otherwise, entropy_enter() is used instead of entropy_enter_intr() in
statclock(), which results in KASSERT() failure.
 1.30 18-Jan-2021  rin Simplify and correct stale comment; nticks-th hardclock() had no longer
been special since rev 1.24:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/clock.c#rev1.24

No functional changes intended.
 1.29 06-Jul-2020  rin branches: 1.29.2;
Include missing opt_ppcarch.h.
 1.28 29-May-2020  rin For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.27 09-Jan-2012  kiyohara Reenable interrupt before was call pic_do_pending_int() by splx(), or KASSERT().
 1.26 20-Jun-2011  matt branches: 1.26.2; 1.26.6;
Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.25 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.24 18-Jan-2011  matt branches: 1.24.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.23 20-Dec-2010  matt branches: 1.23.2;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.22 25-Feb-2010  matt branches: 1.22.2;
Adapt to spr.h breakup.
 1.21 09-Jan-2008  simonb branches: 1.21.10; 1.21.30; 1.21.34;
Bump uvmexp.intrs when we get a clock or statclock interrupt.
 1.20 08-Jan-2008  joerg Mask is unsigned, add missing u.
 1.19 08-Jan-2008  joerg Finish conversion of ppc and evbppc to timecounter.
Tested by simonb@ on WALNUT.
 1.18 27-Sep-2006  freza branches: 1.18.28; 1.18.34; 1.18.42;
Make sure we mask statclock timer on ibm4xx systems. This avoids
pthread "related" panics like:

panic: remrunqueue: bit 18 not set
Stopped in pid 479.3 (exsprite) at netbsd:cpu_Debugger+0x10: lwz
r
0, r1, 0x14
db> bt
0x869abe00: at panic+0x1b4
0x869abe50: at remrunqueue+0x80
0x869abe60: at mi_switch+0x114
0x869abea0: at sa_unblock_userret+0x4e8
0x869abee0: at syscall_plain+0x224
0x869abf40: user SC trap #93 by 0x41949810: srr1=0xc030
r1=0x445fff40 cr=0x40000002 xer=0 ctr=0x41aae208 esr=0 pid=0x36

While there, cleanup IPL_ definitions somewhat and fix interrupt mask
calculation per spl(9).

OK by matt@
 1.17 30-Jun-2006  freza branches: 1.17.4; 1.17.6;
Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.16 05-May-2006  thorpej branches: 1.16.4;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.15 08-Mar-2006  lukem branches: 1.15.2;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.14 24-Dec-2005  perry branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10;
bare asm -> __asm
 1.13 23-Nov-2005  nonaka In decr_intr(), update lasttb only when clock interrupt is not masked.
(sync with macppc/macppc/clock.c: rev.1.11 -> 1.12)
 1.12 03-Jun-2005  scw branches: 1.12.2; 1.12.8;
Appease the -Wshadow and -Wcast-qual gods.
 1.11 19-Jan-2005  simonb A more accurate microtime() implementation. Avoids precision
errors when the clock frequency doesn't divide nicely in to 10^9.
 1.10 02-Sep-2004  scw branches: 1.10.4;
Apply suggested changes from PR port-powerpc/24830 arch/powerpc/ibm4xx:
Bad register constraints in copyin(), copyout(), copyinstr(), copyoutstr(),
and delay().
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 11-Mar-2003  hannken branches: 1.8.2;
Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.7 27-Aug-2002  scw Don't need <machine/walnut.h> here.
 1.6 23-Aug-2002  scw Don't frob cpu-specific DCR registers in common code.
 1.5 06-Aug-2002  chs move more inlines to cpu.h: mftb(), mftbl() and mfpvr().
(the mftb() in pmap.c only wanted the lower 32 bits, so that's now mftbl()).
 1.4 03-Aug-2002  simonb Sprinkle a small amount of KNF.
 1.3 11-Jul-2002  simonb Clean up some white space niggles.
 1.2 15-Mar-2002  eeh branches: 1.2.4; 1.2.6; 1.2.10;
Use properties instead of board_info.
 1.1 13-Mar-2002  eeh This should be pretty standard.
 1.2.10.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.10.1 15-Mar-2002  jdolecek file clock.c was added on branch kqueue on 2002-06-23 17:39:38 +0000
 1.2.6.2 31-Aug-2002  gehenna catch up with -current.
 1.2.6.1 16-Jul-2002  gehenna catch up with -current.
 1.2.4.5 27-Aug-2002  nathanw Catch up to -current.
 1.2.4.4 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.2.4.3 01-Aug-2002  nathanw Catch up to -current.
 1.2.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.1 15-Mar-2002  nathanw file clock.c was added on branch nathanw_sa on 2002-04-01 07:42:01 +0000
 1.8.2.7 11-Dec-2005  christos Sync with head.
 1.8.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.8.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.2 03-Sep-2004  skrll Sync with HEAD
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.12.8.1 29-Nov-2005  yamt sync with head.
 1.12.2.3 21-Jan-2008  yamt sync with head
 1.12.2.2 30-Dec-2006  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.14.10.2 11-May-2006  elad sync with head
 1.14.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.14.8.3 11-Aug-2006  yamt sync with head
 1.14.8.2 24-May-2006  yamt sync with head.
 1.14.8.1 13-Mar-2006  yamt sync with head.
 1.14.6.2 01-Jun-2006  kardel Sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.17.6.1 22-Oct-2006  yamt sync with head
 1.17.4.1 18-Nov-2006  ad Sync with head.
 1.18.42.2 10-Jan-2008  bouyer Sync with HEAD
 1.18.42.1 08-Jan-2008  bouyer Sync with HEAD
 1.18.34.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.28.2 23-Mar-2008  matt sync with HEAD
 1.18.28.1 09-Jan-2008  matt sync with HEAD
 1.21.34.1 07-Jan-2011  matt Deal with new powerpc world.
 1.21.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.21.10.1 11-Mar-2010  yamt sync with head
 1.22.2.1 05-Mar-2011  rmind sync with head
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.6.1 18-Feb-2012  mrg merge to -current.
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.29.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.24 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.23 05-Oct-2022  rin copy{in,out}str: As a tiny optimization, drop redundant mtpid.

No regression for ATF on 405. 403 seems to work fine.
 1.22 04-Oct-2022  rin copy{in,out}str: Consistently use tmp as scratch register. NFC.
 1.21 04-Oct-2022  rin copy{in,out}str: "insn[TAB]operands;" for inline asm codes.
 1.20 04-Oct-2022  rin copy{in,out}str: Style sync with copy{in,out}. No binary changes.
 1.19 04-Oct-2022  rin copy{in,out}{,str}: Drop needless dcbst.

Data cache is purely physical for 40[53] with 16KB pages, and therefore
no need to flush cache before context switch.

This significantly improves copy{in,out} against small data; for example,
bytebench on DHT becomes:

-Pipe Throughput 12440.0 8826.1 7.1
+Pipe Throughput 12440.0 18364.8 14.8

No performance/ATF regression observed on 405. 403 boots successfully
into multiuser mode, and builds some packages.
 1.18 03-Oct-2022  rin copy{in,out}str: Add cr0 and ctr to list of clobbered registers.
 1.17 03-Oct-2022  rin copy{in,out}str: Consistently use uaddr instead of udaddr.
Note that we use kaddr, not kdaddr, for kernel data address.
 1.16 03-Oct-2022  rin copy{in,out}str: Tidy up inline asm's:
- Use %[foo], %[bar], ... instead of %0, %1, ...
- One instruction per line.
- Paragraph grouped instructions.
- Fix wrong comments.
No binary changes.
 1.15 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.14 19-Jun-2020  rin Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.
 1.13 05-Mar-2020  rin Cosmetic changes. No binary changes.
 1.12 05-Mar-2020  rin Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.
 1.11 05-Mar-2020  rin copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.
 1.10 05-Mar-2020  rin copy{in,out}str: sync style with booke.

- early return in case of len == 0
- *done = 0 on fault
 1.9 20-Mar-2010  chs branches: 1.9.60; 1.9.64;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.8 24-Dec-2005  perry branches: 1.8.78; 1.8.98; 1.8.100;
bare asm -> __asm
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 02-Sep-2004  scw branches: 1.6.12;
Apply suggested changes from PR port-powerpc/24830 arch/powerpc/ibm4xx:
Bad register constraints in copyin(), copyout(), copyinstr(), copyoutstr(),
and delay().
 1.5 20-Oct-2003  simonb Remove some numeric asm labels that aren't used.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 02-Feb-2003  matt branches: 1.3.2;
Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.2 11-Jul-2002  simonb Clean up some white space niggles.
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.8; 1.1.16;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.16.1 16-Jul-2002  gehenna catch up with -current.
 1.1.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.1.8.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.1.8.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.1.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.1.8.1 13-Jun-2001  briggs file copyinstr.c was added on branch nathanw_sa on 2001-11-05 19:46:15 +0000
 1.1.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Sep-2004  skrll Sync with HEAD
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.12.1 21-Jun-2006  yamt sync with head.
 1.8.100.1 30-May-2010  rmind sync with head
 1.8.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.78.1 11-Aug-2010  yamt sync with head.
 1.9.64.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #772):

sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.11
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.11

copy{in,out}str: sync style with booke.
- early return in case of len == 0
- *done = 0 on fault

copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.

Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.

Cosmetic changes. No binary changes.
 1.9.60.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.24 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.23 05-Oct-2022  rin copy{in,out}str: As a tiny optimization, drop redundant mtpid.

No regression for ATF on 405. 403 seems to work fine.
 1.22 04-Oct-2022  rin copy{in,out}str: Consistently use tmp as scratch register. NFC.
 1.21 04-Oct-2022  rin copy{in,out}str: "insn[TAB]operands;" for inline asm codes.
 1.20 04-Oct-2022  rin copy{in,out}str: Style sync with copy{in,out}. No binary changes.
 1.19 04-Oct-2022  rin copy{in,out}{,str}: Drop needless dcbst.

Data cache is purely physical for 40[53] with 16KB pages, and therefore
no need to flush cache before context switch.

This significantly improves copy{in,out} against small data; for example,
bytebench on DHT becomes:

-Pipe Throughput 12440.0 8826.1 7.1
+Pipe Throughput 12440.0 18364.8 14.8

No performance/ATF regression observed on 405. 403 boots successfully
into multiuser mode, and builds some packages.
 1.18 03-Oct-2022  rin copy{in,out}str: Add cr0 and ctr to list of clobbered registers.
 1.17 03-Oct-2022  rin copy{in,out}str: Consistently use uaddr instead of udaddr.
Note that we use kaddr, not kdaddr, for kernel data address.
 1.16 03-Oct-2022  rin copy{in,out}str: Tidy up inline asm's:
- Use %[foo], %[bar], ... instead of %0, %1, ...
- One instruction per line.
- Paragraph grouped instructions.
- Fix wrong comments.
No binary changes.
 1.15 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.14 19-Jun-2020  rin Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.
 1.13 05-Mar-2020  rin Cosmetic changes. No binary changes.
 1.12 05-Mar-2020  rin Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.
 1.11 05-Mar-2020  rin copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.
 1.10 05-Mar-2020  rin copy{in,out}str: sync style with booke.

- early return in case of len == 0
- *done = 0 on fault
 1.9 20-Mar-2010  chs branches: 1.9.60; 1.9.64;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.8 24-Dec-2005  perry branches: 1.8.78; 1.8.98; 1.8.100;
bare asm -> __asm
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 02-Sep-2004  scw branches: 1.6.12;
Apply suggested changes from PR port-powerpc/24830 arch/powerpc/ibm4xx:
Bad register constraints in copyin(), copyout(), copyinstr(), copyoutstr(),
and delay().
 1.5 20-Oct-2003  simonb Remove some numeric asm labels that aren't used.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 02-Feb-2003  matt branches: 1.3.2;
Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.2 11-Jul-2002  simonb Clean up some white space niggles.
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.8; 1.1.16;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.16.1 16-Jul-2002  gehenna catch up with -current.
 1.1.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.1.8.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.1.8.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.1.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.1.8.1 13-Jun-2001  briggs file copyoutstr.c was added on branch nathanw_sa on 2001-11-05 19:46:15 +0000
 1.1.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Sep-2004  skrll Sync with HEAD
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.12.1 21-Jun-2006  yamt sync with head.
 1.8.100.1 30-May-2010  rmind sync with head
 1.8.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.78.1 11-Aug-2010  yamt sync with head.
 1.9.64.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #772):

sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.11
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.11

copy{in,out}str: sync style with booke.
- early return in case of len == 0
- *done = 0 on fault

copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.

Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.

Cosmetic changes. No binary changes.
 1.9.60.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.39 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.38 30-Mar-2021  simonb Fix nearly 20 year old type - cache sizes are 2048 bytes, not 2848 bytes.
 1.37 30-Mar-2021  rin According to "PPC405GP Embedded Processor User’s Manual",
405GP has 16KB instruction cache, not 8KB.
 1.36 05-Mar-2021  rin branches: 1.36.2;
Show PVR as 8-digit hex.
 1.35 05-Mar-2021  rin Add 403 family processors other than 403GCX.
 1.34 05-Mar-2020  rin branches: 1.34.4;
Cosmetic change. No binary changes.
 1.33 24-Mar-2014  christos branches: 1.33.30; 1.33.34;
use cpu_{g,s}etmodel
 1.32 21-Jun-2011  matt branches: 1.32.2; 1.32.12; 1.32.16;
Reap the ci_ev_soft* evcnts since every variant implements __HAVE_FAST_SOFTINTS
 1.31 18-Jun-2011  matt Constify cputab.
 1.30 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.29 05-Jun-2011  matt struct device * -> device_t, struct cfdata * -> cfdata_t
CFATTACH_DECL(*, sizeof(struct device), -> CFATTACH_DECL_NEW(&, 0
 1.28 18-Mar-2010  kiyohara branches: 1.28.2; 1.28.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.27 18-Mar-2009  cegger branches: 1.27.2; 1.27.4;
Ansify function definitions w/o arguments. Generated with sed.
 1.26 19-Nov-2007  ad branches: 1.26.18; 1.26.26; 1.26.32;
Set curlwp for the boot CPU before entering main().
 1.25 31-Aug-2006  freza branches: 1.25.12; 1.25.30; 1.25.32; 1.25.36; 1.25.38;
* add PVR values for Xilinx 405 cores
* don't try to decode vendor-specific PVR, print raw value instead.
* panic() if we see cache wasn't probed, we'd crash later anyway.
* rework the way PVR gets translated to core name.
* while there, normalize printf format ("%s: ...", device_xname(self), ...).

OK by matt@
 1.24 30-Jun-2006  freza Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.23 05-May-2006  thorpej branches: 1.23.4;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.22 24-Dec-2005  perry branches: 1.22.4; 1.22.6; 1.22.8; 1.22.10; 1.22.12;
bare asm -> __asm
 1.21 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.20 11-Dec-2005  christos merge ktrace-lwp.
 1.19 03-Jun-2005  scw branches: 1.19.2;
Appease -Wshadow and -Wcast-qual
 1.18 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.17 23-Sep-2003  shige Add global cpu_model variable.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 13-Jun-2003  simonb branches: 1.15.2;
Sprinkle some TABs to line up the columns in the cputab models array.
 1.14 13-Jun-2003  msaitoh Add support IBM 405GPr
 1.13 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.12 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.11 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.10 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.9 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.7 23-Aug-2002  scw Add "ecc at plb" device.
Add an "irq" locator to the plb device.
This gets rid of the original hack where ecc support was wedged into
the cpu driver.
 1.6 23-Aug-2002  simonb Show the IRQ we attach the ECC handler to.
 1.5 23-Aug-2002  scw Install the ECC error interrupt handler at the level specified by
a "4xx-ecc-irq" property.
If the property isn't defined, assume the hardware has no ECC support.
This should, ideally, be a config file option.
 1.4 12-Aug-2002  simonb Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.3 11-Jul-2002  simonb Clean up some white space niggles.
 1.2 15-Mar-2002  eeh branches: 1.2.2; 1.2.6; 1.2.8;
Use properties instead of board_info.
 1.1 13-Mar-2002  eeh Add cache_info to cpu_info which provides details about D$ and I$
sizes and line sizes. This is needed for cache flusing, clearing
memory, and several other operations. This information is accessible
from userland through a new CPU_CACHEINFO sysctl.
 1.2.8.2 31-Aug-2002  gehenna catch up with -current.
 1.2.8.1 16-Jul-2002  gehenna catch up with -current.
 1.2.6.6 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.5 27-Aug-2002  nathanw Catch up to -current.
 1.2.6.4 13-Aug-2002  nathanw Catch up to -current.
 1.2.6.3 01-Aug-2002  nathanw Catch up to -current.
 1.2.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.6.1 15-Mar-2002  nathanw file cpu.c was added on branch nathanw_sa on 2002-04-01 07:42:01 +0000
 1.2.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.2.1 15-Mar-2002  jdolecek file cpu.c was added on branch kqueue on 2002-03-16 15:59:15 +0000
 1.15.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.3 07-Dec-2007  yamt sync with head
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.22.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.22.10.1 11-May-2006  elad sync with head
 1.22.8.3 03-Sep-2006  yamt sync with head.
 1.22.8.2 11-Aug-2006  yamt sync with head
 1.22.8.1 24-May-2006  yamt sync with head.
 1.22.6.1 01-Jun-2006  kardel Sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.23.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.25.38.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.36.1 21-Nov-2007  bouyer Sync with HEAD
 1.25.32.1 09-Jan-2008  matt sync with HEAD
 1.25.30.1 21-Nov-2007  joerg Sync with HEAD.
 1.25.12.1 03-Dec-2007  ad Sync with HEAD.
 1.26.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.26.18.2 11-Aug-2010  yamt sync with head.
 1.26.18.1 04-May-2009  yamt sync with head.
 1.27.4.2 12-Jun-2011  rmind sync with head
 1.27.4.1 30-May-2010  rmind sync with head
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.28.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.16.1 18-May-2014  rmind sync with head
 1.32.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.34.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #774):

sys/arch/powerpc/ibm4xx/cpu.c: revision 1.34
sys/arch/powerpc/ibm4xx/pic_uic.c: revision 1.5

Cosmetic change. No binary changes.

Remove unused macros.
 1.33.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.36.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.24 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.23 20-Jun-2011  matt branches: 1.23.52; 1.23.54;
Don't include *pmap.h in assembly files. Get the needed definitions
from "assym.h".
 1.22 20-Jun-2011  matt Make struct cpu_info the same size if building MODULAR
kernels or compiling a module.
 1.21 18-Jun-2011  matt Make a common genassym.cf (powerpc/genassym.cf) and then
only put specific stuff in foo/genassym.cf
 1.20 18-Jun-2011  matt Add things needed for __HAVE_FAST_SOFTINTRS
 1.19 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.18 18-Jan-2011  matt branches: 1.18.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.17 20-Mar-2010  chs branches: 1.17.2;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.16 10-Dec-2009  rmind branches: 1.16.2; 1.16.4;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.15 23-Feb-2008  matt branches: 1.15.4; 1.15.26;
Add MTX_* and RW_* definitions
 1.14 17-Oct-2007  garbled branches: 1.14.12; 1.14.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.13 18-May-2007  rjs branches: 1.13.10;
Fix for yamt-idlelwp merge.
 1.12 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.11 11-Dec-2005  christos branches: 1.11.26; 1.11.30; 1.11.32; 1.11.38;
merge ktrace-lwp.
 1.10 19-Jan-2005  matt branches: 1.10.8;
Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.9 26-Nov-2003  simonb branches: 1.9.8;
Need offset of ci_curpm in struct cpu_info on 4xx as well.
 1.8 27-Aug-2003  matt Move SFRAMELEN to frame.h and use it in vm_machdep.c. In setfunc, setup
callframe linkages correctly. Restore use of ldptr to locore_subr.S
[pthreads and gdb no longer crash/hang the system]
 1.7 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.6 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.5 11-Aug-2003  chs catch up with changes elsewhere.
 1.4 04-Aug-2003  matt Add SFRAME_USER_SR (even though the 4XX doesn't have one).
 1.3 03-Aug-2003  matt Add each register in trapframe, switchframe, and faultbuf.
 1.2 16-Jul-2003  simonb SZ_BOARD_CFG_DATA is not used anywhere, remove it.
 1.1 04-Mar-2003  matt branches: 1.1.2;
Re-arrange things in evbppc & powerpc to support OEA-based eval boards
in evbppc. OEA-based board(s) to be added later.
 1.1.2.4 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.8.1 29-Apr-2005  kent sync with -current
 1.10.8.2 27-Feb-2008  yamt sync with head.
 1.10.8.1 03-Sep-2007  yamt sync with head.
 1.11.38.2 02-Aug-2007  macallan sync with HEAD
 1.11.38.1 22-May-2007  matt Update to HEAD.
 1.11.32.1 11-Jul-2007  mjf Sync with head.
 1.11.30.1 27-May-2007  ad Sync with head.
 1.11.26.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.13.10.2 23-Mar-2008  matt sync with HEAD
 1.13.10.1 06-Nov-2007  matt sync with HEAD
 1.14.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.12.1 24-Mar-2008  keiichi sync with head.
 1.15.26.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.15.26.1 07-Jan-2011  matt Deal with new powerpc world.
 1.15.4.2 11-Aug-2010  yamt sync with head.
 1.15.4.1 11-Mar-2010  yamt sync with head
 1.16.4.3 12-Jun-2011  rmind sync with head
 1.16.4.2 05-Mar-2011  rmind sync with head
 1.16.4.1 30-May-2010  rmind sync with head
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.54.1 10-Jun-2019  christos Sync with HEAD
 1.23.52.1 28-Jul-2018  pgoyette Sync with HEAD
 1.6 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.5 11-Dec-2005  christos branches: 1.5.110;
merge ktrace-lwp.
 1.4 18-Jan-2005  shige Arrange some machine-dependent code.
- ibm40x_machdep.c: ibm40x specific
. ibm40x_memsize_init
. mem_regions
. other functions are moved to machdep.c or ibm4xx_machdep.c.
- ibm4xx_machdep.c: ibm4xx specific
. ibm4xx_init (moved from ibm40x_machdep.c)
. ibm4xx_install_extint (moved from ibm40x_machdep.c)
. ibm4xx_cpu_startup (moved from ibm40x_machdep.c:ibm4xx_startup)
. ibm4xx_dumpsys
 1.3 17-Jan-2005  shige Remove openbios dependent code from ibm4xx/ibm40x dependent module.
 1.2 30-Dec-2003  pk branches: 1.2.4; 1.2.8; 1.2.10;
Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

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

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
 1.1 23-Sep-2003  shige Add IBM40x specific machdep functions.
 1.2.10.1 29-Apr-2005  kent sync with -current
 1.2.8.1 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.2.4.5 24-Jan-2005  skrll Sync with HEAD.
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 30-Dec-2003  skrll file ibm40x_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.5.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2 24-Sep-2003  shige Delete this file because filename includes uppercase letters.
 1.1 23-Sep-2003  shige Copy IBM4xxGPx specific autoconf code from evbppc/walnut/autoconf.c.
 1.17 29-Mar-2021  rin Set com(4) frequency in ibm4xx_device_register() in order to dedup codes.
 1.16 29-Mar-2021  rin Centralize cpu_rootconf().
 1.15 18-Jun-2011  matt branches: 1.15.66; 1.15.68;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.14 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.13 18-Mar-2010  kiyohara branches: 1.13.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.12 22-Jan-2010  martin branches: 1.12.2; 1.12.4;
Unify the name of the device property to hold a MAC address - there was
no clear majority for either "mac-addr" vs. "mac-address", but a quick
gallup poll among developers selected the latter.
 1.11 22-Feb-2007  thorpej branches: 1.11.46;
TRUE -> true, FALSE -> false
 1.10 05-May-2006  thorpej branches: 1.10.14;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.9 28-Mar-2006  thorpej Use opb_instance instead of dv->dv_unit when checking if we should set
the mac-addr property.
 1.8 28-Feb-2006  simonb branches: 1.8.2; 1.8.4; 1.8.6;
Fix fallout from obviously untested device_is_a() rototill.
 1.7 26-Feb-2006  thorpej Use device_is_a()
 1.6 23-Feb-2006  thorpej Use device_parent().
 1.5 21-Feb-2006  thorpej Add an "instance" member to opb_attach_args and use it when fetching
the mac-address property from board_info. port-powerpc/32862
 1.4 18-Feb-2006  thorpej - Don't expose dev_propdb directly -- provide devprop_*() wrappers instead.
- Rework the ARMADILLO / epe device properties interaction so that it actually
associates the MAC address property with the epe device instance.
 1.3 11-Dec-2005  christos branches: 1.3.2; 1.3.4; 1.3.6;
merge ktrace-lwp.
 1.2 17-Jan-2005  shige branches: 1.2.2; 1.2.10; 1.2.12;
Remove openbios dependent code from ibm4xx/ibm40x dependent module.
 1.1 13-Jan-2005  shige branches: 1.1.2;
Add device_register function for all ibm4xx machine.
 1.1.2.1 29-Apr-2005  kent sync with -current
 1.2.12.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.2.12.1 17-Jan-2005  riz file ibm4xx_autoconf.c was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.2.10.2 26-Feb-2007  yamt sync with head.
 1.2.10.1 21-Jun-2006  yamt sync with head.
 1.2.2.3 24-Jan-2005  skrll Sync with HEAD.
 1.2.2.2 17-Jan-2005  skrll Sync with HEAD.
 1.2.2.1 17-Jan-2005  skrll file ibm4xx_autoconf.c was added on branch ktrace-lwp on 2005-01-17 19:30:09 +0000
 1.3.6.2 01-Jun-2006  kardel Sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.2 01-Mar-2006  yamt sync with head.
 1.3.2.1 18-Feb-2006  yamt sync with head.
 1.8.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.8.4.2 11-May-2006  elad sync with head
 1.8.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.8.2.2 24-May-2006  yamt sync with head.
 1.8.2.1 01-Apr-2006  yamt sync with head.
 1.10.14.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.11.46.2 11-Aug-2010  yamt sync with head.
 1.11.46.1 11-Mar-2010  yamt sync with head
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.13.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15.68.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.39 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.38 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.37 30-Mar-2021  rin Use ``for (;;)'' for infinite loop, as required by style.
No binary changes.
 1.36 30-Mar-2021  rin Centralize cpu_reboot().
 1.35 06-Mar-2021  rin branches: 1.35.2;
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.34 18-Jan-2021  rin white space --> tab
 1.33 06-Jan-2021  rin Sort headers. No functional changes intended.
 1.32 06-Jul-2020  rin branches: 1.32.2;
Set cpu_psluserset, cpu_pslusermod, cpu_pslusermask for MODULAR.
 1.31 06-Jul-2020  rin Drop unused opt_compat_netbsd.h include.
 1.30 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.29 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.28 31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.27 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.26 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.25 26-Dec-2016  rin branches: 1.25.14; 1.25.16;
Assert that the size of a trap handler does not exceed its room.

XXX
The debug exception is critical for ibm4xx. Since rev 1.24, we use the critical
trap hundler for it. Sorry for the wrong commit log for rev 1.24.
 1.24 26-Dec-2016  rin No need to have same trap handlers in trap_subr.S.
No functional changes.
 1.23 26-Dec-2016  rin We cannot have DDB and IPKDB at the same time.
 1.22 22-Dec-2016  cherry switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.21 16-Dec-2016  rin Fix typo: s/IPKBD/IPKDB/
 1.20 16-Dec-2016  rin Fix comments. No functional changes.
 1.19 15-Dec-2016  rin Fix build without DDB.
 1.18 12-Dec-2011  kiyohara branches: 1.18.6; 1.18.24; 1.18.28;
Remove white-spaces.
Indents.
 1.17 20-Jun-2011  matt branches: 1.17.2; 1.17.6;
Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.16 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.15 18-Jan-2011  matt branches: 1.15.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.14 17-Jan-2011  matt branches: 1.14.2;
Add a #include <machine/pcb.h>
 1.13 25-Feb-2010  matt branches: 1.13.2;
Adapt to spr.h breakup.
 1.12 27-Nov-2009  rmind branches: 1.12.2;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.11 26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.10 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.9 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.8 02-Jul-2008  ad branches: 1.8.18;
Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@.
 1.7 04-Mar-2007  christos branches: 1.7.40; 1.7.44; 1.7.46; 1.7.48;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.5 24-Dec-2005  perry branches: 1.5.26;
bare asm -> __asm
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 25-Apr-2005  lukem branches: 1.3.2; 1.3.4; 1.3.6;
Move the MI printing of `copyright' to the MD cpu_startup() code
where the printing of `version' is already performed.
This has the benefit of allowing the copyright to be available
via dmesg(8) on platforms which need the `msgbuf' to be setup
in cpu_startup() before printed output is remembered.
 1.2 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.1 18-Jan-2005  shige branches: 1.1.2; 1.1.4;
Arrange some machine-dependent code.
- ibm40x_machdep.c: ibm40x specific
. ibm40x_memsize_init
. mem_regions
. other functions are moved to machdep.c or ibm4xx_machdep.c.
- ibm4xx_machdep.c: ibm4xx specific
. ibm4xx_init (moved from ibm40x_machdep.c)
. ibm4xx_install_extint (moved from ibm40x_machdep.c)
. ibm4xx_cpu_startup (moved from ibm40x_machdep.c:ibm4xx_startup)
. ibm4xx_dumpsys
 1.1.4.1 28-Jan-2005  yamt convert arch/powerpc to new apis.
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 01-Apr-2005  skrll Sync with HEAD.
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 18-Jan-2005  skrll file ibm4xx_machdep.c was added on branch ktrace-lwp on 2005-01-24 08:34:26 +0000
 1.3.6.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.3.6.1 25-Apr-2005  riz file ibm4xx_machdep.c was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.3.4.3 03-Sep-2007  yamt sync with head.
 1.3.4.2 26-Feb-2007  yamt sync with head.
 1.3.4.1 21-Jun-2006  yamt sync with head.
 1.3.2.2 29-Apr-2005  kent sync with -current
 1.3.2.1 25-Apr-2005  kent file ibm4xx_machdep.c was added on branch kent-audio2 on 2005-04-29 11:28:19 +0000
 1.5.26.2 12-Mar-2007  rmind Sync with HEAD.
 1.5.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.7.48.1 03-Jul-2008  simonb Sync with head.
 1.7.46.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.44.2 11-Mar-2010  yamt sync with head
 1.7.44.1 04-May-2009  yamt sync with head.
 1.7.40.1 02-Jul-2008  mjf Sync with HEAD.
 1.8.18.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.8.18.1 07-Jan-2011  matt Deal with new powerpc world.
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.13.2.1 05-Mar-2011  rmind sync with head
 1.14.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.6.1 18-Feb-2012  mrg merge to -current.
 1.17.2.1 17-Apr-2012  yamt sync with head
 1.18.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.24.1 05-Feb-2017  skrll Sync with HEAD
 1.18.6.1 03-Dec-2017  jdolecek update from HEAD
 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 28-Jul-2018  pgoyette Sync with HEAD
 1.32.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.35.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 15-May-2006  shige Move cpu_configure to evbppc/*.c.
(Remove ibm4xxgpx_autoconf.c)
I'm sorry for my wrong thinking.
 1.5 24-Dec-2005  perry branches: 1.5.4; 1.5.6; 1.5.8; 1.5.12;
bare asm -> __asm
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 13-Jan-2005  shige branches: 1.3.10;
Remove device_register, cpu_rootconf functions.
These functions are moved to ibm4xx/autoconf.c.
 1.2 23-Oct-2004  thorpej Centralize the declaration of booted_device and booted_partition.
 1.1 24-Sep-2003  shige branches: 1.1.4; 1.1.6;
Copy IBM4xxGPx specific autoconf code from evbppc/walnut/autoconf.c.
 1.1.6.1 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.1.4.6 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.5 02-Nov-2004  skrll Sync with HEAD.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 24-Sep-2003  skrll file ibm4xxgpx_autoconf.c was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.3.10.1 21-Jun-2006  yamt sync with head.
 1.5.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.8.1 24-May-2006  yamt sync with head.
 1.5.6.1 01-Jun-2006  kardel Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.26 20-Jun-2011  matt Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.25 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.24 20-Dec-2010  matt branches: 1.24.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.23 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.22 25-Feb-2010  matt branches: 1.22.2;
Adapt to spr.h breakup.
 1.21 04-Jan-2009  tsutsui branches: 1.21.4;
Account ci->ci_idepth on calling handlers in ext_intr() as well as
powerpc/pic/intr.c:pic_handle_intr(). Closes PR port-evbppc/40288.

Should be pulled up to netbsd-5.
 1.20 02-Jan-2008  ad branches: 1.20.6; 1.20.10; 1.20.18; 1.20.20;
Merge vmlocking2 to head.
 1.19 03-Dec-2007  ad branches: 1.19.2; 1.19.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.18 17-Oct-2007  garbled branches: 1.18.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.17 24-Jul-2007  hannken branches: 1.17.4; 1.17.6;
Handle IST_LEVEL interrupts better. Disable interrupt while it is
processed and enable afterwards. Up to now IST_LEVEL interrupts always
fired again during processing leaving unnecessary pending interrupts.

Tested on EXPLORA451.

Ok: Simon Burge <simonb@netbsd.org>
 1.16 15-Feb-2007  ad branches: 1.16.6; 1.16.14; 1.16.16; 1.16.18;
Make these compile again.
 1.15 02-Dec-2006  freza Welcome to evbppc/virtex -- port to Xilinx Virtex series FPGA's with embedded
ibm405d5 core.

OK by Simon Burge
 1.14 27-Sep-2006  freza Make sure we mask statclock timer on ibm4xx systems. This avoids
pthread "related" panics like:

panic: remrunqueue: bit 18 not set
Stopped in pid 479.3 (exsprite) at netbsd:cpu_Debugger+0x10: lwz
r
0, r1, 0x14
db> bt
0x869abe00: at panic+0x1b4
0x869abe50: at remrunqueue+0x80
0x869abe60: at mi_switch+0x114
0x869abea0: at sa_unblock_userret+0x4e8
0x869abee0: at syscall_plain+0x224
0x869abf40: user SC trap #93 by 0x41949810: srr1=0xc030
r1=0x445fff40 cr=0x40000002 xer=0 ctr=0x41aae208 esr=0 pid=0x36

While there, cleanup IPL_ definitions somewhat and fix interrupt mask
calculation per spl(9).

OK by matt@
 1.13 10-Jul-2006  freza branches: 1.13.4; 1.13.6;
Fix recent ibm4xx/intr.c rework:

- Recalculate masks _after_ new interrupt handler is enqueued, otherwise
the very last one won't ever be enabled (from hannken@)

- We can't use splhigh() to protect intr_calculatemasks() since it would
use soon-to-be-invalid mask. Instead, fiddle PSL_EE directly as we do
in other places.

Reviewed and tested (evbppc/explora) by hannken@
 1.12 30-Jun-2006  freza Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.11 13-Jun-2006  freza branches: 1.11.2;
Merge multiple definitions of cntlzw() ("count leading zeros")
instruction-wrapper to <powerpc/cpu.h>.

OK by briggs@
 1.10 24-Dec-2005  perry branches: 1.10.4; 1.10.8; 1.10.14;
bare asm -> __asm
 1.9 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 03-Jun-2005  scw branches: 1.7.2;
Appease -Wcast-qual
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 16-Jun-2003  thorpej branches: 1.5.2;
Rename IPL_IMP -> IPL_VM.
 1.4 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.3 11-Jul-2002  simonb Clean up some white space niggles.
 1.2 13-May-2002  matt branches: 1.2.2;
Remove redundant declarations.
 1.1 13-Mar-2002  eeh branches: 1.1.2; 1.1.6;
Generalized IBM UIC driver.
 1.1.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.1.6.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.6.1 13-Mar-2002  nathanw file intr.c was added on branch nathanw_sa on 2002-04-01 07:42:01 +0000
 1.1.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.1 13-Mar-2002  jdolecek file intr.c was added on branch kqueue on 2002-03-16 15:59:15 +0000
 1.2.2.1 16-Jul-2002  gehenna catch up with -current.
 1.5.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.2.6 21-Jan-2008  yamt sync with head
 1.7.2.5 07-Dec-2007  yamt sync with head
 1.7.2.4 03-Sep-2007  yamt sync with head.
 1.7.2.3 26-Feb-2007  yamt sync with head.
 1.7.2.2 30-Dec-2006  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.10.14.1 19-Jun-2006  chap Sync with head.
 1.10.8.2 11-Aug-2006  yamt sync with head
 1.10.8.1 26-Jun-2006  yamt sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.13.6.2 10-Dec-2006  yamt sync with head.
 1.13.6.1 22-Oct-2006  yamt sync with head
 1.13.4.2 12-Jan-2007  ad Sync with head.
 1.13.4.1 18-Nov-2006  ad Sync with head.
 1.16.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.16.16.1 07-Aug-2007  matt Sync with HEAD.
 1.16.14.2 03-Oct-2007  garbled Sync with HEAD
 1.16.14.1 02-Aug-2007  macallan sync with HEAD
 1.16.6.3 03-Dec-2007  ad Sync with HEAD.
 1.16.6.2 03-Dec-2007  ad Sync with HEAD.
 1.16.6.1 20-Aug-2007  ad Sync with HEAD.
 1.17.6.2 09-Jan-2008  matt sync with HEAD
 1.17.6.1 06-Nov-2007  matt sync with HEAD
 1.17.4.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.18.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.18.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.19.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.19.2.1 27-Dec-2007  ad locking changes for macppc. Please test.
 1.20.20.1 14-Jan-2009  snj branches: 1.20.20.1.8;
Pull up following revision(s) (requested by tsutsui in ticket #246):
sys/arch/powerpc/ibm4xx/intr.c: revision 1.21
Account ci->ci_idepth on calling handlers in ext_intr() as well as
powerpc/pic/intr.c:pic_handle_intr(). Closes PR port-evbppc/40288.
Should be pulled up to netbsd-5.
 1.20.20.1.8.1 07-Jan-2011  matt Deal with new powerpc world.
 1.20.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.10.3 11-Aug-2010  yamt sync with head.
 1.20.10.2 11-Mar-2010  yamt sync with head
 1.20.10.1 04-May-2009  yamt sync with head.
 1.20.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.21.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.22.2.2 05-Mar-2011  rmind sync with head
 1.22.2.1 30-May-2010  rmind sync with head
 1.24.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3 18-Mar-2005  shige Remove MD codes from arch/powerpc/ibm4xx.
 1.2 21-Jan-2005  shige branches: 1.2.2; 1.2.4; 1.2.8;
Add consinit() and md_consinit funcptr to ibm4xx/machdep.c.
Rename consinit() to obs405_consinit() at evbppc/obs405/consinit.c.

Set md_consinit to obs405_consinit() at initppc().
Consinit fuction calls a function stored at md_consinit pointer.
 1.1 18-Jan-2005  shige Add ibm4xx family common module.
- machine-dependent global variables
- cpu_startup glue
- softnet/softserial (copy from ibm40x_machdep.c)
 1.2.8.1 14-Sep-2005  tron Apply patch (requested by shige in ticket #763):
Synchronize OpenBlockS266 port with NetBSD-current for enhanced stability.
 1.2.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.2.3 01-Apr-2005  skrll Sync with HEAD.
 1.2.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.2.2.1 21-Jan-2005  skrll file machdep.c was added on branch ktrace-lwp on 2005-01-24 08:34:26 +0000
 1.3 12-Aug-2002  simonb Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.2 11-Jul-2002  simonb Clean up some white space niggles.
 1.1 13-Mar-2002  eeh branches: 1.1.2; 1.1.6; 1.1.8;
Generic mainbus driver.
 1.1.8.2 31-Aug-2002  gehenna catch up with -current.
 1.1.8.1 16-Jul-2002  gehenna catch up with -current.
 1.1.6.4 13-Aug-2002  nathanw Catch up to -current.
 1.1.6.3 01-Aug-2002  nathanw Catch up to -current.
 1.1.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.6.1 13-Mar-2002  nathanw file mainbus.c was added on branch nathanw_sa on 2002-04-01 07:42:02 +0000
 1.1.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.1 13-Mar-2002  jdolecek file mainbus.c was added on branch kqueue on 2002-03-16 15:59:15 +0000
 1.9 05-Mar-2021  rin Fix hard freeze in pic_handle_intr() for PPC_IBM403.

Not clearly documented in reference manual, but DCR_EXISR register is
not updated immediately after some bits are cleared by mtdcr, no matter
whether sync (= eieio) and/or isync are issued.

Therefore, we have to manage our own status mask in the interrupt handler.
This is what we did in obsoleted powerpc/ibm4xx/intr.c.

With this change, my Explora 451 works just fine with serial console!
Fix for framebuffer console will be committed soon.
 1.8 27-Feb-2021  rin Switch to intr_establish_xname().
 1.7 06-Jul-2020  rin branches: 1.7.2;
Include missing opt_ppcarch.h and opt_uic.h.
 1.6 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.5 05-Mar-2020  rin Remove unused macros.
 1.4 19-Nov-2013  kiyohara branches: 1.4.30; 1.4.34;
Fix IPL for cascading pic to HIGH.
 1.3 01-Feb-2012  matt branches: 1.3.6; 1.3.10;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.2 13-Dec-2011  kiyohara Fix the mistake in level and type.
 1.1 20-Jun-2011  matt branches: 1.1.2; 1.1.4; 1.1.8;
Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.1.8.1 18-Feb-2012  mrg merge to -current.
 1.1.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.1 17-Apr-2012  yamt sync with head
 1.1.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.1 20-Jun-2011  cherry file pic_uic.c was added on branch cherry-xenmp on 2011-06-23 14:19:29 +0000
 1.3.10.1 18-May-2014  rmind sync with head
 1.3.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.34.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #774):

sys/arch/powerpc/ibm4xx/cpu.c: revision 1.34
sys/arch/powerpc/ibm4xx/pic_uic.c: revision 1.5

Cosmetic change. No binary changes.

Remove unused macros.
 1.4.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.110 01-Feb-2024  andvar s/againt/against/ in comment.
 1.109 05-Oct-2022  rin ppc4xx_tlb_enter: One more style sync. No binary changes.

Use hi and lo instead of th and tl for TLBHI and TLBLO, respectively,
as done for other functions in pmap.c.
 1.108 05-Oct-2022  rin Use %[foo], %[bar], ... instead of %0, %1, ... for asm codes.
Unify variable names if possible. No binary changes.
 1.107 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.106 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.105 08-Sep-2021  rin pte_enter() and pmap_enter_pv(): return zero for success, and
non-zero value for failure, as normally expected.
 1.104 05-Sep-2021  rin Now, ctx_flush() never fails. So, make this function void.
 1.103 05-Sep-2021  rin pmap_enter_pv(): At the moment, this function is always called with
pmap_initialized. So, convert test for this condition to KASSERT.
 1.102 05-Sep-2021  rin pmap_enter_pv(): No need to initialize npv to NULL.

No functional changes intended.
 1.101 05-Sep-2021  rin pmap_testout(): Use pmap_{protect,remove}() for va to (va + PAGE_SIZE),
instead of (va + 1).

No functional changes for the current implementation. Also, this affects
only when the function is manually called from DDB on DEBUG kernel.
 1.100 05-Sep-2021  rin if (cond) panic() or Debugger() in #ifdef DIAGNOSTIC ---> KASSERT(!cond)

There is no regression observed during a full ATF run.
 1.99 04-Sep-2021  rin Style. No binary changes.

Also, remove old #if-0'ed code block copied from oea (and therefore
will never be enabled).
 1.98 15-Apr-2021  rin Use uvm_km_alloc(9) with UVM_KMF_NOWAIT flag in pte_enter(), in order not to
sleep in pmap_enter(9) and pmap_kenter_pa(9), which can result in dead lock.

In most cases, pmap_enter(9) is used with PMAP_CANFAIL flag. In this case,
if pte_enter() fails due to uvm_km_alloc(9), we can safely return ENOMEM.
UVM layer will take care of it.

uvm_km_alloc(9) fails for pmap_enter(9) without PMAP_CANFAIL or for
pmap_kenter_pa(9), we have no choice but to panic there.

However, my testbeds for 403 and 405 survive more than a week at least
without hitting this panic.
 1.97 14-Apr-2021  rin Style fixes:

- Add "static inline" to pte_enter(), to match with its declaration.
- Remove parentheses from return.
- Use NULL instead of 0 for pointer initialization.

No binary changes.
 1.96 30-Mar-2021  rin G/C misleading <evbppc/tlb.h>. Use <powerpc/ibm4xx/tlb.h> directly.
 1.95 10-Sep-2020  rin branches: 1.95.2; 1.95.4;
Tiny cosmetic fix for previous. No functional changes.
 1.94 10-Sep-2020  rin Real fix for pmap_procwr(), attempted in revs 1.85 and 1.87:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.87

ibm4xx has VIPT icache and operations in pmap_procwr() should be done with
DMMU enabled (write back dcache into memory and invalidate icache).

When p == curproc, this is trivial. However, p != curproc needs a special
care; we cannot rely upon TLB miss handler in user context. Therefore,
extract pa and operate against it.

Note that va below VM_MIN_KERNEL_ADDRESS (== 2GB at the moment) is reserved
for direct mapping.

Tested by gdb with WIP software single stepping for ibm4xx.
 1.93 10-Sep-2020  rin Introduce PMAP_TLBDEBUG option for ibm4xx: clear only TLBHI[V] bit when
TLB entry is invalidated, instead of clearing entire TLBHI register.
 1.92 10-Sep-2020  rin pmap_kenter_pa: Remove comment which says ``Have to remove any existing
mapping first.'' Contrary to this comment, pmap_kremove(9) has never
been called there since rev 1.1, and we don't for other ports also.
 1.91 10-Sep-2020  rin Introduce PV_VA() macro to extract va from pv->pv_va by clearing
PV_WIRED flag, and use it where appropriate.

There should be no functional changes. Only for safety in future.
 1.90 06-Jul-2020  rin Include missing opt_ddb.h.
 1.89 29-Jun-2020  rin Remove evcnt(9) counter for tlbhit; there's no way to observe TLB hits
from kernel, and it just counted intersection b/w tlbmiss and tlbenter.
 1.88 19-Jun-2020  rin Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.
 1.87 19-Jun-2020  rin Oops, commit log was missing. It should be:

Revert rev 1.85:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85

Not clearly documented in reference manual, but the previous code seems
correct; the operations must be carried out with DMMU disabled. Otherwise,
WIP software single step for userland does not work correctly (stalled
indefinitely at pmap_procwr()).

XXX
pullup to netbsd-9
 1.86 19-Jun-2020  rin *** empty log message ***
 1.85 05-Mar-2020  rin Fix pmap_procwr().

While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.
 1.84 05-Mar-2020  rin Retire tlbpid_t (u_short):

- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).

XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.
 1.83 05-Mar-2020  rin pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.
 1.82 05-Mar-2020  rin ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.
 1.81 05-Mar-2020  rin Misc non-critical fixes.

- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style
 1.80 21-Feb-2020  rin In ppc4xx_tlb_find_victim(), mark kernel stack page TLBF_REF instead of
TLBF_USED. This should be originally intended behavior of this code
segment, because

- TLBF_USED is already checked just before, so marking this page
TLBF_USED is no-op.
- TLBF_REF flag exempts that page from being flushed from TLB in next
scan, when kernel stack may be still there with high probability.
 1.79 20-Feb-2020  rin Clear ti_ctx when flushing a TLB entry for clarity.
 1.78 20-Feb-2020  rin Fix off-by-one error for ctx (ASID).

Note that NUM_CTX = 256 = 0 stands for disabling protection by ASID.
 1.77 20-Feb-2020  rin Fix NULL dereference; "pap" argument of pmap_extract(9) can be NULL.
 1.76 24-Dec-2016  cherry branches: 1.76.16; 1.76.20; 1.76.22;
Conform API use of uvm_hotplug(9) to documented behaviour:

When testing for an invalid uvm_physseg_t,
compare with UVM_PHYSSEG_TYPE_INVALID which is implementation agnostic.
 1.75 24-Dec-2016  cherry introduce evbppc pmap to the uvm_hotplug(9) API

Should fix build.
 1.74 23-Dec-2016  cherry "Make NetBSD great again!"

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

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

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

uvm_setpagesize() is now subsumed within this funciton.
 1.72 27-Jan-2012  para branches: 1.72.6; 1.72.24; 1.72.28;
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.71 09-Jan-2012  kiyohara Move spl from ppc4xx_tlb_enter() to pmap_enter(). Don't call splx() on
I/DTLBMISS.
 1.70 30-Jun-2011  matt branches: 1.70.2; 1.70.6;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.69 21-Jun-2011  matt Switch to using dcache_wbinv_page
 1.68 20-Jun-2011  matt Get rid of extern inline.
Cleanup includes.
Rearrange pv_entry so that are pointers are first.
 1.67 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.66 07-Feb-2011  matt branches: 1.66.2;
Use EVCNT_ATTACH_STATIC
 1.65 14-Jan-2011  rmind branches: 1.65.2; 1.65.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.64 10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.63 06-Nov-2010  uebayasi Merge from uebayasi-xip:
 1.60.2.5 14-Aug-2010  uebayasi Teach TLB miss handler (pmap_tlbmiss()) to map "Expansion ROM" area as
PA == VA. Now we don't need to reserve a TLB entry for it.
 1.62 25-Feb-2010  matt branches: 1.62.2;
Adapt to spr.h breakup.
 1.61 25-Feb-2010  skrll s/cpu_fork/cpu_lwp_fork/ in comment
 1.60 21-Nov-2009  rmind branches: 1.60.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.59 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.58 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.57 18-Aug-2009  thorpej Add a real API for testing if a page is a managed page, and adjust callers
to stop relying on vm_physseg_find() for this purpose.
 1.56 11-Aug-2009  matt Remove all declarations of physmem from sys/arch. Add an include of
<sys/systm.h> to the one file that did not already contain it.
This now means that physmem can be changed by updating systm.h and uvm_page.c
(excluding fixing printfs)
 1.55 11-May-2009  he Follow up the changed prototype of pmap_enter(), flag from int to u_int.
 1.54 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.53 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.52 10-Dec-2008  pooka branches: 1.52.2;
Make kernel_pmap_ptr a const. Requested by steve_martin.
 1.51 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

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

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.50 17-Oct-2007  garbled branches: 1.50.16; 1.50.20; 1.50.26; 1.50.28; 1.50.40;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.49 24-Jul-2007  hannken branches: 1.49.6;
Use PR_NOWAIT in in pmap_enter_pv() and take care of PMAP_CANFAIL. Built
after powerpc/oea/pmap.c. Now a LOCKDEBUG kernel runs on EXPLORA451.

Ok: Simon Burge <simonb@netbsd.org>
 1.48 12-Mar-2007  ad branches: 1.48.8; 1.48.10; 1.48.12;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.47 04-Mar-2007  christos branches: 1.47.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.45 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.44 29-Nov-2006  freza branches: 1.44.4;
Instead of mapping whole RAM with reserved TLB entries, map just enough
to ensure trap code will work (that is 0 upto ${endkernel}) and leave the
rest to pmap_tlbmiss(). Mapping whole physmem into the kernel wired way
too many TLB entries, see

http://mail-index.netbsd.org/port-powerpc/2006/10/27/0000.html

for performance analysis. While there, be a bit more descriptive in
pmap_tlbmiss() comment and use macro instead of numeric constant.

OK by Simon Burge
 1.43 16-Oct-2006  kiyohara * convert ibm4xx-based evbppc from reserved-TLB entry allocation to recently
introduced ppc4xx_tlb_reserve() API.
 1.42 31-Aug-2006  freza branches: 1.42.2; 1.42.4;
* ppc4xx_tlb_reserve(): allocate "reserved" TLB entries dynamically
* ppc4xx_tlb_mapiodev(): resolve pa to va from reserved TLB entries

OK by matt@

XXX we'll keep TLB_NRESERVED defined until we fix explora to use new API
 1.41 12-Jul-2006  simonb Remove unused ppc4xx_tlb_unpin() function.
 1.40 04-Jul-2006  simonb Remove some unused variables.
 1.39 24-Dec-2005  perry branches: 1.39.4; 1.39.8; 1.39.16;
bare asm -> __asm
 1.38 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.37 11-Dec-2005  christos merge ktrace-lwp.
 1.36 03-Jun-2005  scw branches: 1.36.2;
Appease the -Wshadow and -Wcast-qual gods.
 1.35 07-Apr-2005  yamt pmap_testout: fix too many arguments for pmap_kenter_pa.
from Shoichi Miyake. PR/29914.
 1.34 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.33 02-Mar-2005  chs fix two bugs with wiring:
(1) in pmap_enter_pv(), we would always mark the header entry wired, even if
the new entry wasn't put there. noticed by Juergen Hannken-Illjes.
(2) in pmap_unwire(), we would never examine the header entry.
noticed by me.

while I'm here, move the counter increment in the pmap_enter() path to be
next to the corresponding PV_WIRE() call so it's more obvious they match.
 1.32 25-Feb-2005  simonb KNF: put "if (...)" and following statement on separate lines.
 1.31 27-Jan-2005  simonb Fix a typo in a printf string.
 1.30 16-Jan-2005  chs branches: 1.30.2;
implement pmap_wired_count(). fix some places we would forget to splx().
move the parts of pte.h that were used into pmap.c (since they were really
pmap-internal details) and delete ibm4xx/pte.h. other misc cleanup.
 1.29 31-Jul-2004  simonb branches: 1.29.4;
Remove some debug printf()s.
Reorder an evcnt_attach_static().
 1.28 18-Dec-2003  pk Use uvm_km_zalloc(...) instead of uvm_km_alloc1(...,1).
 1.27 20-Oct-2003  simonb Need Data Relocate in the MSR for the dcbf in pmap_procwr().
From Matt Thomas.
 1.26 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.25 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.24 19-Jul-2003  simonb Remove an unused variable.
 1.23 15-Jul-2003  lukem __KERNEL_RCSID()
 1.22 03-Jul-2003  scw Fix resident page accounting for the kernel pmap.
 1.21 10-May-2003  thorpej branches: 1.21.2;
Back out the following chagne:
http://mail-index.netbsd.org/source-changes/2003/05/08/0068.html

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

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

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

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

This also eliminates use of VM_{MIN,MAX}_KERNEL_ADDRESS from MI code,
this giving MD code greater flexibility over the bounds of the managed
kernel virtual address space if a given port's specific platforms can
vary in this regard (this is especially true of the evb* ports).
 1.19 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.18 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.17 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.16 06-Jan-2003  wiz writable, not writeable.
 1.15 04-Jan-2003  thorpej Make this compile without DDB.
 1.14 24-Nov-2002  thorpej Use EVCNT_TYPE_TRAP.
 1.13 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.12 11-Jul-2002  simonb Clean up some white space niggles.
 1.11 28-Mar-2002  eeh branches: 1.11.2;
Follow the post-UBC semantics of resetting ref/mod collection inside of
pmap_clear_{reference,modify}().
 1.10 13-Mar-2002  eeh pmap improvements:

Remove the cache flush routines that have been moved to cpu.c

Make sure we clear out the unused PA bits in the TTE which causes breakage
on some MMU models.
 1.9 08-Mar-2002  thorpej Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map). Try to deal with this:

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

From art@openbsd.org.
 1.8 26-Nov-2001  thorpej Rename NOCACHE -> PPC_4XX_NOCACHE to avoid conflict with the namei
flag of the same name.

From Frank van der Linden <fvdl@wasabisystems.com>.
 1.7 26-Nov-2001  thorpej Reset the unused RPN bits in a TLBLO to 0, as specified by the PPC401B3
user's manual, page 8-40.

From Frank van der Linden <fvdl@wasabisystems.com>.
 1.6 06-Nov-2001  simonb In pmap_enter(), sync the instruction cache if VM_PROT_EXECUTE. Fixes
problems when executing programs where text is copied to a page without
a dma sync (like NFS data bcopy'd to a buffer cache page).

From discussion with Jason Thorpe and Eduardo Horvath.
 1.5 11-Sep-2001  eeh branches: 1.5.2; 1.5.4;
Implement pmap_growkernel().
 1.4 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.3 22-Jul-2001  wiz branches: 1.3.2;
Replace memcpy's of obviously overlapping regions with memmove.
Noted by Izumi Tsutsui.
 1.2 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.1 13-Jun-2001  simonb branches: 1.1.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 03-Aug-2001  lukem update to -current
 1.3.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.4.11 07-Jan-2003  thorpej Sync with head.
 1.5.4.10 11-Dec-2002  thorpej Sync with HEAD.
 1.5.4.9 18-Oct-2002  nathanw Catch up to -current.
 1.5.4.8 01-Aug-2002  nathanw Catch up to -current.
 1.5.4.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.5.4.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.5.4.5 17-Apr-2002  nathanw Catch up to -current.
 1.5.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.5.4.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.5.4.1 11-Sep-2001  briggs file pmap.c was added on branch nathanw_sa on 2001-11-05 19:46:16 +0000
 1.5.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.11.2.1 16-Jul-2002  gehenna catch up with -current.
 1.21.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.21.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.21.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.30.2.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.30.2.2 12-Feb-2005  yamt sync with head.
 1.30.2.1 28-Jan-2005  yamt convert arch/powerpc to new apis.
 1.36.2.4 03-Sep-2007  yamt sync with head.
 1.36.2.3 26-Feb-2007  yamt sync with head.
 1.36.2.2 30-Dec-2006  yamt sync with head.
 1.36.2.1 21-Jun-2006  yamt sync with head.
 1.39.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.39.8.2 03-Sep-2006  yamt sync with head.
 1.39.8.1 11-Aug-2006  yamt sync with head
 1.39.4.1 09-Sep-2006  rpaulo sync with head
 1.42.4.2 10-Dec-2006  yamt sync with head.
 1.42.4.1 22-Oct-2006  yamt sync with head
 1.42.2.2 12-Jan-2007  ad Sync with head.
 1.42.2.1 18-Nov-2006  ad Sync with head.
 1.44.4.3 24-Mar-2007  yamt sync with head.
 1.44.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.44.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.47.2.2 20-Aug-2007  ad Sync with HEAD.
 1.47.2.1 13-Mar-2007  ad Sync with head.
 1.48.12.1 15-Aug-2007  skrll Sync with HEAD.
 1.48.10.1 07-Aug-2007  matt Sync with HEAD.
 1.48.8.2 03-Oct-2007  garbled Sync with HEAD
 1.48.8.1 02-Aug-2007  macallan sync with HEAD
 1.49.6.1 06-Nov-2007  matt sync with HEAD
 1.50.40.1 07-Jan-2011  matt Deal with new powerpc world.
 1.50.28.2 28-Apr-2009  skrll Sync with HEAD.
 1.50.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.50.26.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.50.20.4 11-Mar-2010  yamt sync with head
 1.50.20.3 19-Aug-2009  yamt sync with head.
 1.50.20.2 16-May-2009  yamt sync with head
 1.50.20.1 04-May-2009  yamt sync with head.
 1.50.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.52.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.60.2.8 04-Nov-2010  uebayasi Split physical device segment pages from "managed" to "managed
device". Cache that information as a flag PG_DEVICE so that callers
don't need to walk physsegs everytime.

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

I think this is what I can do best now.
 1.60.2.7 31-Oct-2010  uebayasi We already have a flag PMAP_NOCACHE. s/PMAP_UNMANAGED/PMAN_NOCACHE/.
Pointed out by Chuck Silvers, thanks.
 1.60.2.6 30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.60.2.5 14-Aug-2010  uebayasi Teach TLB miss handler (pmap_tlbmiss()) to map "Expansion ROM" area as
PA == VA. Now we don't need to reserve a TLB entry for it.
 1.60.2.4 11-Aug-2010  uebayasi Support XIP; look up "device" vm_physseg for managed pages. Initialize
vm_physseg MD part.
 1.60.2.3 30-Apr-2010  uebayasi Sync with HEAD.
 1.60.2.2 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.60.2.1 27-Apr-2010  uebayasi Support PMAP_UNMANAGED in some pmaps.

(Others should be converted eventually, but no problem while managed
device page is not used.)
 1.62.2.1 05-Mar-2011  rmind sync with head
 1.65.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.65.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.66.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.70.6.1 18-Feb-2012  mrg merge to -current.
 1.70.2.1 17-Apr-2012  yamt sync with head
 1.72.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.72.24.1 05-Feb-2017  skrll Sync with HEAD
 1.72.6.1 03-Dec-2017  jdolecek update from HEAD
 1.76.22.1 29-Feb-2020  ad Sync with head.
 1.76.20.2 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #773):

sys/arch/powerpc/ibm4xx/pmap.c: revision 1.81
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.82
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.83
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.84
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.85
sys/arch/powerpc/include/ibm4xx/tlb.h: revision 1.6
sys/arch/powerpc/include/ibm4xx/pmap.h: revision 1.20

Misc non-critical fixes.
- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style

ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.

pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.

Retire tlbpid_t (u_short):
- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).
XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.

Fix pmap_procwr().
While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.
 1.76.20.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #731):

sys/arch/powerpc/ibm4xx/pmap.c: revision 1.80
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.77
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.78
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.79

Fix NULL dereference; "pap" argument of pmap_extract(9) can be NULL.

-

Fix off-by-one error for ctx (ASID).

-

Note that NUM_CTX = 256 = 0 stands for disabling protection by ASID.
Clear ti_ctx when flushing a TLB entry for clarity.

-

In ppc4xx_tlb_find_victim(), mark kernel stack page TLBF_REF instead of
TLBF_USED. This should be originally intended behavior of this code
segment, because
- TLBF_USED is already checked just before, so marking this page
TLBF_USED is no-op.
- TLBF_REF flag exempts that page from being flushed from TLB in next
scan, when kernel stack may be still there with high probability.
 1.76.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.95.4.2 17-Apr-2021  thorpej Sync with HEAD.
 1.95.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.95.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 17-Aug-2010  uebayasi branches: 1.1.2;
file pmap.c.work was initially added on branch uebayasi-xip.
 1.1.2.2 22-Oct-2010  uebayasi Merge botch.
 1.1.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.102 05-Oct-2023  ad Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
 1.101 05-Oct-2022  rin Minor style fixes to asm codes. No binary changes.
 1.100 04-Oct-2022  rin copy{in,out}{,str}: Drop needless dcbst.

Data cache is purely physical for 40[53] with 16KB pages, and therefore
no need to flush cache before context switch.

This significantly improves copy{in,out} against small data; for example,
bytebench on DHT becomes:

-Pipe Throughput 12440.0 8826.1 7.1
+Pipe Throughput 12440.0 18364.8 14.8

No performance/ATF regression observed on 405. 403 boots successfully
into multiuser mode, and builds some packages.
 1.99 12-Sep-2022  rin Work around clang 13.0.0 bug; copy{in,out}() are miscompiled with -O[12],
by which /sbin/init cannot be executed.
 1.98 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.97 12-Sep-2022  rin copy{in,out}(): Minor clean up:
- No need to supply count (== 0).
- %r0 can be used as %[ctx] and %[len].
 1.96 12-Sep-2022  rin copyin(): Remove one more needless mtpid. No regression for full ATF.
 1.95 11-Sep-2022  rin copyin(): Fix comment. No binary changes.
 1.94 11-Sep-2022  rin copy{in,out}(): Tiny optimizations for __asm codes.
No regressions for full ATF run.

- Use {l,st}swx instead of loop for remaining bytes.
- Drop needless "mtpid %[x]; isync;".
 1.93 11-Sep-2022  rin copy{in,out}(): Add missing clobber registers to __asm codes.
 1.92 11-Sep-2022  rin copy{in,out}(): Add missing ``if (count == 0) goto done;''.
 1.91 11-Sep-2022  rin copy{in,out}(): Consistently use %[tmp] as scratch register. NFC.
 1.90 11-Sep-2022  rin copyin(): Fix copy-paste in comment. No binary changes.
 1.89 11-Sep-2022  rin copy{in,out}(): Cosmetic changes to __asm codes. No binary changes.

- Editor-friendly indentation.
- One insn per line.
- Group insns with logical blocks.
 1.88 11-Sep-2022  rin s/udaddr/uaddr/g for consistency; we use kaddr for kernel data address.
No binary changes.
 1.87 30-May-2022  rin For IBM_PPC403, emulate unaligned memory access for userland process.
 1.86 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.85 15-Jul-2020  rin branches: 1.85.2;
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.84 15-Jul-2020  rin Treat trap instruction from userland correctly in EXC_PGM handler;
raise SIGTRAP with TRAP_BRKPT instead of SIGILL.
 1.83 06-Jul-2020  rin - Drop unused opt_altivec.h.
- Include missing opt_ppcarch.h.
 1.82 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.81 19-Jun-2020  rin Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.
 1.80 19-Jun-2020  rin Return correct signo and si_code to userland when page fault.
Taken from powerpc/trap.c. Found by tests in lib/libc/sys.
 1.79 19-Jun-2020  rin Return error code from uvm layer on fault, instead of hard-coded 1.
Found by some tests in tests/lib/libc/sys.
 1.78 21-Feb-2020  rin Do not try to recovery from data page fault in interrupt context;
catch up belatedly with powerpc/trap.c rev 1.49 and etc.:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.49
 1.77 21-Feb-2020  rin Tiny improvements to copyin() and copyout():

- Use lwz/stw instead of 4-byte lswi/stswi for 405 and later, which
support unaligned word load/store by hardware. In many cases, both
source and destination are aligned on word boundaries.

- Use dcbst instead of dcbf to flush cache. The former does not
invalidate the cache line. Copied data should be used soon after.
 1.76 21-Feb-2020  rin Cosmetic changes for assembler codes. No binary changes.
 1.75 21-Feb-2020  rin Comment out badaddr() and badaddr_read() on ibm4xx for now.

They are not used nor exposed externally in any header file; these
functions may have never been tested so far.

Enable them again when necessary.

Note that badaddr() for oea is used by macppc port, where it is
declared as an external function.
 1.74 20-Feb-2020  rin Oops, sort header again. My bad...
 1.73 20-Feb-2020  rin Convert mi_userret(9) into powerpc-specific userret().

This is necessary in order to support RAS.

There are some sanity checks in userret() as well.
 1.72 20-Feb-2020  rin Sort more headers...
 1.71 20-Feb-2020  rin Sort headers.
 1.70 07-Apr-2019  thorpej branches: 1.70.4; 1.70.6;
Detangle some of the PowerPC CPU configuration spaghetti.
 1.69 26-Dec-2016  rin branches: 1.69.16;
Remove wrong comment which was copy-and-pasted from somewhere.
 1.68 16-Dec-2016  rin Remove needless goto's. No functional changes.
 1.67 18-Oct-2014  snj branches: 1.67.2; 1.67.4;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.66 23-Aug-2013  matt Get rid of MDLWP_USED{FPU,VEC}
 1.65 23-Jul-2012  matt branches: 1.65.2; 1.65.4;
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.64 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.63 13-Dec-2011  kiyohara Remove white-spaces.
 1.62 21-Jun-2011  matt branches: 1.62.2; 1.62.6;
Switch to use new common cpu_ast routine.
 1.61 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.60 14-Jun-2011  matt Make startlwp and upcallret common instead of having 3 mostly identical copies.
 1.59 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.58 18-Jan-2011  matt branches: 1.58.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.57 20-Dec-2010  matt branches: 1.57.2;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.56 23-Apr-2010  rmind Remove lwp_uc_pool, replace it with kmem(9), plus add some consistency.
As discussed, a while ago, with ad@.
 1.55 20-Mar-2010  chs fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.54 25-Feb-2010  matt branches: 1.54.2;
Adapt to spr.h breakup.
 1.53 21-Nov-2009  rmind branches: 1.53.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.52 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.51 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.50 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.49 15-Oct-2008  wrstuden branches: 1.49.2; 1.49.8; 1.49.16;
Merge wrstuden-revivesa into HEAD.
 1.48 02-Jan-2008  ad branches: 1.48.6; 1.48.10; 1.48.12; 1.48.16;
Merge vmlocking2 to head.
 1.47 28-Nov-2007  simonb branches: 1.47.2; 1.47.6;
Use lswi/syswi instead of lwz/stw when doing loads/stores since we don't
know the alignment of data being copied. 403 cores have alignment
restrictions on lwz/stw that 405 cores don't have. lswi/syswi benchmark
at the same speed as lwz/stw on a 405 Walnut.

Fixes problems reported by Juergen Hannken-Illjes on the Explora.
 1.46 22-Nov-2007  hpeyerl Optimize copyin/copyout to transfer as many words as possible before doing
residual bytes. This improves small transfers. As a result, we can avoid
doing bigcopyin/bigcopyout until len>1024 instead of len>256.

Reviewed by: simonb.

(everybody run, Herb's in the kernel again).
 1.45 05-Nov-2007  ad branches: 1.45.2;
Don't set l_usrpri / spc_curpriority here. mi_userret() does it.
 1.44 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.43 09-Jul-2007  ad branches: 1.43.8; 1.43.10; 1.43.12; 1.43.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.42 22-May-2007  rjs Fix for yamt-idlelwp merge.
 1.41 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.40 04-Mar-2007  christos branches: 1.40.2; 1.40.4; 1.40.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.39 15-Feb-2007  ad branches: 1.39.2;
Make these compile again.
 1.38 09-Feb-2007  ad Merge newlock2 to head.
 1.37 05-Oct-2006  chs add support for O_DIRECT (I/O directly to application memory,
bypassing any kernel caching for file data).
 1.36 23-Jul-2006  ad branches: 1.36.4; 1.36.6;
Use the LWP cached credentials where sane.
 1.35 19-Jul-2006  ad - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
 1.34 15-May-2006  yamt include kauth.h for kauth_cred_geteuid.
 1.33 14-May-2006  elad integrate kauth.
 1.32 15-Mar-2006  drochner branches: 1.32.2;
adapt to uvm_fault() interface cleanup: kill the useless 3rd argument
 1.31 07-Mar-2006  thorpej branches: 1.31.2;
Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.30 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.29 24-Dec-2005  perry branches: 1.29.4; 1.29.6; 1.29.8;
bare asm -> __asm
 1.28 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.27 11-Dec-2005  christos merge ktrace-lwp.
 1.26 03-Jun-2005  scw branches: 1.26.2;
Appease the -Wshadow and -Wcast-qual gods.
 1.25 25-Feb-2005  simonb KNF: put "if (...)" and following statement on separate lines.
 1.24 19-Jan-2005  simonb branches: 1.24.2;
White space nit.
 1.23 02-Sep-2004  scw branches: 1.23.4;
Apply suggested changes from PR port-powerpc/24830 arch/powerpc/ibm4xx:
Bad register constraints in copyin(), copyout(), copyinstr(), copyoutstr(),
and delay().
 1.22 14-Mar-2004  cl add kernel part of concurrency support for SA on MP systems
- move per VP data into struct sadata_vp referenced from l->l_savp
* VP id
* lock on VP data
* LWP on VP
* recently blocked LWP on VP
* queue of LWPs woken which ran on this VP before sleep
* faultaddr
* LWP cache for upcalls
* upcall queue
- add current concurrency and requested concurrency variables
- make process exit run LWP on all VPs
- make signal delivery consider all VPs
- make timer events consider all VPs
- add sa_newsavp to allocate new sadata_vp structure
- add sa_increaseconcurrency to prepare new VP
- make sys_sa_setconcurrency request new VP or wakeup idle VP
- make sa_yield lower current concurrency
- set sa_cpu = VP id in upcalls
- maintain cached LWPs per VP
 1.21 24-Feb-2004  drochner deliver SIGSEGV/SEGV_ACCERR if code execution on stack is attempted,
tested by Juergen Hannken-Illjes
(there are more uninitialized ksi.ksi_code arguments)
 1.20 31-Oct-2003  cl Reduce code duplication by adding mi_userret() in sys/userret.h
containing signal posting, kernel-exit handling and sa_upcall processing.

XXX the pc532, sparc, sparc64 and vax ports should have their
XXX userret() code rearranged to use this.
 1.19 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

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

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.18 26-Sep-2003  eeh Define ksi.
 1.17 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.16 19-Sep-2003  cl add MD part of SA/pthread pagefault handling on powerpc
 1.15 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.14 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 28-Jun-2003  simonb branches: 1.13.2;
Sprinkle some KNF.
 1.12 07-Feb-2003  thorpej Fix some printf formats.
 1.11 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.10 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.9 25-Nov-2002  thorpej branches: 1.9.2;
Statements after labels.
 1.8 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.7 11-Jul-2002  simonb Clean up some white space niggles.
 1.6 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.5 17-Jun-2002  christos apply the fix from the powerpc port. this is almost a copy of powerpc/trap.c
and needs to be refactored.
 1.4 17-Jun-2002  christos MD systrace gluons.
 1.3 14-Feb-2002  chs branches: 1.3.8;
allow writing to write-only mappings. fixes PR 3493.
 1.2 22-Jul-2001  wiz branches: 1.2.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.1 13-Jun-2001  simonb branches: 1.1.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.1 03-Aug-2001  lukem update to -current
 1.2.6.15 07-Jan-2003  thorpej In the SA universe, the switch-to-this-LWP decision is made at a
different level than where preempt() calls are made, which renders
the "newlwp" argument useless. Replace it with a "more work to do"
boolean argument. Returning to userspace preempt() calls pass 0.
"Voluntary" preemptions in e.g. uiomove() pass 1. This will be used
to indicate to the SA subsystem that the LWP is not yet finished in
the kernel.

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

NOTE: THIS IS NOT A COMPLETE FIX TO THE preempt()-in-uiomove() PROBLEM
THAT CURRENTLY EXISTS FOR SA PROCESSES.
 1.2.6.14 11-Dec-2002  thorpej Sync with HEAD.
 1.2.6.13 06-Oct-2002  gmcgarry upcallret() takes struct *lwp.
 1.2.6.12 26-Sep-2002  nathanw Change "if (l->l_flag & L_SA_UPCALL)" to "while (l->l_flag & L_SA_UPCALL)"
in userret() functions or equivalent, to permit delivery of multiple upcalls
in a single kernel entry.

XXX It's getting crowded in here. Collapsing posting signals, upcalls, and
XXX kernel-exit handling into one mechanism would be nice.
 1.2.6.11 29-Aug-2002  nathanw Replace the old-fashioned P_WEXIT checking with p_userret hook handling.
 1.2.6.10 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.2.6.9 01-Aug-2002  nathanw Catch up to -current.
 1.2.6.8 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.2.6.7 03-Jul-2002  nathanw Do p->p_userret handling rather than the old P_WEXIT check in trap().
 1.2.6.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.2.6.5 20-Jun-2002  nathanw Catch up to -current.
 1.2.6.4 28-Feb-2002  nathanw Catch up to -current.
 1.2.6.3 17-Dec-2001  nathanw cpu_upcall() -> sa_upcall_userret().
 1.2.6.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.2.6.1 22-Jul-2001  briggs file trap.c was added on branch nathanw_sa on 2001-11-05 19:46:16 +0000
 1.3.8.3 31-Aug-2002  gehenna catch up with -current.
 1.3.8.2 16-Jul-2002  gehenna catch up with -current.
 1.3.8.1 15-Jul-2002  gehenna catch up with -current.
 1.9.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.13.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.13.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.2 03-Sep-2004  skrll Sync with HEAD
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.24.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.2.8 21-Jan-2008  yamt sync with head
 1.26.2.7 07-Dec-2007  yamt sync with head
 1.26.2.6 15-Nov-2007  yamt sync with head.
 1.26.2.5 27-Oct-2007  yamt sync with head.
 1.26.2.4 03-Sep-2007  yamt sync with head.
 1.26.2.3 26-Feb-2007  yamt sync with head.
 1.26.2.2 30-Dec-2006  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.29.8.4 11-Aug-2006  yamt sync with head
 1.29.8.3 24-May-2006  yamt sync with head.
 1.29.8.2 01-Apr-2006  yamt sync with head.
 1.29.8.1 13-Mar-2006  yamt sync with head.
 1.29.6.2 01-Jun-2006  kardel Sync with head.
 1.29.6.1 22-Apr-2006  simonb Sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.31.2.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.31.2.2 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.31.2.1 07-Mar-2006  elad file trap.c was added on branch elad-kernelauth on 2006-03-08 00:43:13 +0000
 1.32.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.36.6.1 22-Oct-2006  yamt sync with head
 1.36.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.36.4.1 18-Nov-2006  ad Sync with head.
 1.39.2.2 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.39.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.40.10.5 03-Oct-2007  garbled Sync with HEAD
 1.40.10.4 02-Aug-2007  macallan sync with HEAD
 1.40.10.3 26-Jun-2007  garbled Sync with HEAD.
 1.40.10.2 28-May-2007  freza Add KGDB support to evbppc/virtex port. From Jean-Francois Boudreault,
cosmetics by me.

While there, generalize virtex_console_tag() to virtex_bus_space_tag()
and fix one instance of yamt-idlelwp fallout (ci_need_resched renamed
to ci_want_resched).

XXX Only compile tested since my access to suitable Virtex HW is sporadic
XXX at best.
 1.40.10.1 22-May-2007  matt Update to HEAD.
 1.40.4.1 11-Jul-2007  mjf Sync with head.
 1.40.2.3 03-Dec-2007  ad Sync with HEAD.
 1.40.2.2 23-Oct-2007  ad Sync with head.
 1.40.2.1 15-Jul-2007  ad Sync with head.
 1.43.14.3 22-Nov-2007  bouyer Sync with HEAD
 1.43.14.2 13-Nov-2007  bouyer Sync with HEAD
 1.43.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.43.12.1 18-Oct-2007  yamt sync with head.
 1.43.10.2 09-Jan-2008  matt sync with HEAD
 1.43.10.1 06-Nov-2007  matt sync with HEAD
 1.43.8.4 03-Dec-2007  joerg Sync with HEAD.
 1.43.8.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.43.8.2 06-Nov-2007  joerg Sync with HEAD.
 1.43.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.45.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.45.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.47.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.47.2.1 27-Dec-2007  ad locking changes for macppc. Please test.
 1.48.16.1 19-Oct-2008  haad Sync with HEAD.
 1.48.12.3 30-Jun-2008  wrstuden Change how we make SA threads not generate upcalls. Instead of clearing
LW_SA, use a private flag, LP_SA_NOBLOCK, that we set when we want
to not generate upcalls. This means we do NOT need to lock (l)
(ourselves) to set it.

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

Introduce code pattern to set & remember this:

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

...

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

l->l_pflag ^= f;

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

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

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

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

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

Tweak some comments.
 1.48.12.2 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.48.12.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.48.10.3 11-Aug-2010  yamt sync with head.
 1.48.10.2 11-Mar-2010  yamt sync with head
 1.48.10.1 04-May-2009  yamt sync with head.
 1.48.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.49.16.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.49.16.1 07-Jan-2011  matt Deal with new powerpc world.
 1.49.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.49.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.53.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.54.2.3 12-Jun-2011  rmind sync with head
 1.54.2.2 05-Mar-2011  rmind sync with head
 1.54.2.1 30-May-2010  rmind sync with head
 1.57.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.58.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.62.6.2 24-Feb-2012  mrg sync to -current.
 1.62.6.1 18-Feb-2012  mrg merge to -current.
 1.62.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.62.2.2 30-Oct-2012  yamt sync with head
 1.62.2.1 17-Apr-2012  yamt sync with head
 1.65.4.1 28-Aug-2013  rmind sync with head
 1.65.2.2 03-Dec-2017  jdolecek update from HEAD
 1.65.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.67.2.1 05-Feb-2017  skrll Sync with HEAD
 1.69.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.69.16.1 10-Jun-2019  christos Sync with HEAD
 1.70.6.1 29-Feb-2020  ad Sync with head.
 1.70.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #735):

sys/arch/powerpc/ibm4xx/trap.c: revision 1.71
sys/arch/powerpc/ibm4xx/trap.c: revision 1.72
sys/arch/powerpc/ibm4xx/trap.c: revision 1.73
sys/arch/powerpc/ibm4xx/trap.c: revision 1.74
sys/arch/powerpc/ibm4xx/trap.c: revision 1.75
sys/arch/powerpc/ibm4xx/trap.c: revision 1.76
sys/arch/powerpc/ibm4xx/trap.c: revision 1.77
sys/arch/powerpc/ibm4xx/trap.c: revision 1.78

Sort headers.
-
Sort more headers...
-
Convert mi_userret(9) into powerpc-specific userret().

This is necessary in order to support RAS.

There are some sanity checks in userret() as well.
-
Oops, sort header again. My bad...
-
Comment out badaddr() and badaddr_read() on ibm4xx for now.

They are not used nor exposed externally in any header file; these
functions may have never been tested so far.

Enable them again when necessary.

Note that badaddr() for oea is used by macppc port, where it is
declared as an external function.
-
Cosmetic changes for assembler codes. No binary changes.
-
Tiny improvements to copyin() and copyout():
- Use lwz/stw instead of 4-byte lswi/stswi for 405 and later, which
support unaligned word load/store by hardware. In many cases, both
source and destination are aligned on word boundaries.
- Use dcbst instead of dcbf to flush cache. The former does not
invalidate the cache line. Copied data should be used soon after.
-
Do not try to recovery from data page fault in interrupt context;
catch up belatedly with powerpc/trap.c rev 1.49 and etc.:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.49
 1.85.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.30 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.29 06-Jul-2020  rin Include required opt_*.h for sure.
 1.28 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.27 15-Jul-2018  maxv branches: 1.27.4;
Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.26 28-Dec-2016  rin branches: 1.26.14; 1.26.16;
PR port-powerpc/51367: kernel panic for powerpc/ibm4xx with "option DDB"

Stop using ddbstk/ipkdbstk to make nested traps possible, which avoids
kernel panics reported in the PR.

Suggested and approved by matt.
 1.25 26-Dec-2016  rin No need to have same trap handlers in trap_subr.S.
No functional changes.
 1.24 09-Feb-2013  kiyohara branches: 1.24.14; 1.24.18;
Fix KASSERT(l == curlwp)ed in mi_switch(). Don't use INTSTK of cpu_info in
INTR_PROLOG when user-mode. Interrupted user context switches to newlwp, if
sched tick. This context must save to USPACE.
When use our INTSTK?
 1.23 29-Jan-2013  kiyohara Set SRR1 to r31 in intr_exit. Not cpuinfo.
 1.22 22-Dec-2011  kiyohara branches: 1.22.6;
Check PSL_PR instead of CI_IDEPTH in INTR_PROLOG.
 1.21 15-Dec-2011  kiyohara Like intrleave_to_user:, intrleave_to_kernel: should also restore PID.
Moreover, disable transration.
 1.20 15-Dec-2011  kiyohara Store r30 and r31 beforehand to restore.
 1.19 14-Dec-2011  kiyohara Indent.
Remove white-spaces and unnecessary semi-collons.
 1.18 28-Jun-2011  kiyohara branches: 1.18.2; 1.18.6;
Must need srr0 and srr1 in FRAME_SETUP and trapexit.
parentheses is good.
Remove no-need 'addi FRAME_TF'.
 1.17 24-Jun-2011  kiyohara Fix broken stack. The r4 points cpu_info in ddb_trap. (not test)
 1.16 15-Jun-2011  cliff - FRAME_SAVE_CALLEE() starts at r14 (not r13, which is curlwp) (from matt@)
- INTR_SAVE() must also save r13 (from matt@).
- fitint must pass clock frame, not trap frame
- fix comment in pitint and fitint to indicate passing clock frame, not intr frame
 1.15 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.14 02-May-2011  kiyohara branches: 1.14.2;
Fix broken stack. The r1 is stack pointer. Not cpu_info pointer.
 1.13 18-Jan-2011  matt 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.12 05-Jan-2011  matt branches: 1.12.2;
Use regnames (%rX %crX), use m[ft]sprg[0-9]. No binary difference.
 1.11 17-Oct-2007  garbled branches: 1.11.42; 1.11.46;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.10 11-Dec-2005  christos branches: 1.10.30; 1.10.38; 1.10.48; 1.10.50; 1.10.52; 1.10.54;
merge ktrace-lwp.
 1.9 11-Aug-2003  chs branches: 1.9.16;
catch up with changes elsewhere.
 1.8 09-Jul-2003  matt Enhance db_trace to understand syscalls and print the syscall number
that the user requested. For example:

0xd5c56f40: SC trap #240 by 0x15668c60: srr1=0xd032
r1=0xffffe470 cr=0x44000045 xer=0 ctr=0xeff27ab8
 1.7 02-Feb-2003  matt branches: 1.7.2;
Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.6 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.5 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.4 11-Jul-2002  simonb Clean up some white space niggles.
 1.3 13-Mar-2002  eeh branches: 1.3.4;
Add a vector for machine check traps.
 1.2 17-Jun-2001  simonb branches: 1.2.2; 1.2.8;
Globalise "trapexit" for new ddb tracing changes.
 1.1 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.2.8.4 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.2.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.2.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.8.1 17-Jun-2001  nathanw file trap_subr.S was added on branch nathanw_sa on 2002-04-01 07:42:02 +0000
 1.2.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.2 31-Aug-2002  gehenna catch up with -current.
 1.3.4.1 16-Jul-2002  gehenna catch up with -current.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.1 27-Oct-2007  yamt sync with head.
 1.10.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.52.1 18-Oct-2007  yamt sync with head.
 1.10.50.1 06-Nov-2007  matt sync with HEAD
 1.10.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.10.38.1 28-May-2007  freza Add KGDB support to evbppc/virtex port. From Jean-Francois Boudreault,
cosmetics by me.

While there, generalize virtex_console_tag() to virtex_bus_space_tag()
and fix one instance of yamt-idlelwp fallout (ci_need_resched renamed
to ci_want_resched).

XXX Only compile tested since my access to suitable Virtex HW is sporadic
XXX at best.
 1.10.30.1 23-Oct-2007  ad Sync with head.
 1.11.46.1 07-Jan-2011  matt Deal with new powerpc world.
 1.11.42.3 12-Jun-2011  rmind sync with head
 1.11.42.2 31-May-2011  rmind sync with head
 1.11.42.1 05-Mar-2011  rmind sync with head
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18.6.1 18-Feb-2012  mrg merge to -current.
 1.18.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.18.2.1 17-Apr-2012  yamt sync with head
 1.22.6.2 03-Dec-2017  jdolecek update from HEAD
 1.22.6.1 25-Feb-2013  tls resync with head
 1.24.18.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.14.1 05-Feb-2017  skrll Sync with HEAD
 1.26.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.26.16.1 10-Jun-2019  christos Sync with HEAD
 1.26.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.27.4.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.5 12-Aug-2002  simonb Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.4 13-Mar-2002  eeh branches: 1.4.4;
Adapt to the new, separate mainbus.
 1.3 08-Mar-2002  simonb Include libkern.h for strcmp() prototype.
 1.2 29-Oct-2001  simonb branches: 1.2.2;
Don't return at the end of a void function.
 1.1 24-Jun-2001  simonb branches: 1.1.2; 1.1.6;
Move on-chip 405GP devices to powerpc/ibm4xx/dev.
 1.1.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.1.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.3 13-Aug-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 29-Oct-2001  nathanw file com_mainbus.c was added on branch nathanw_sa on 2002-04-01 07:42:03 +0000
 1.4.4.1 31-Aug-2002  gehenna catch up with -current.
 1.25 27-Feb-2021  rin Switch to intr_establish_xname().
 1.24 06-Jul-2020  rin branches: 1.24.2;
Style and cosmetic changes. No binary changes intended.
 1.23 15-Dec-2019  rin Belatedly catch up with MI com(4) change in com.c rev. 1.351:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/ic/com.c#rev1.351

XXX
pullup to netbsd-9
 1.22 08-Dec-2018  thorpej branches: 1.22.4;
Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.21 18-Jun-2011  matt branches: 1.21.52; 1.21.54;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.20 14-Mar-2008  cube branches: 1.20.36;
Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend). Use proper types and ansify where appropriate.
 1.19 22-Feb-2007  thorpej branches: 1.19.22; 1.19.38; 1.19.42;
TRUE -> true, FALSE -> false
 1.18 13-Jul-2006  gdamore branches: 1.18.10;
Add an option COM_REGMAP to allow com(4) to use an array of register indices.
This allows us to convert aucom to just another com attachment, and cleanup
some code in the com_arbus.c.

Additionally, we use a common com_cleanup routine rather than having a
zillion copies of it in the attachment points.

This has been tested on a number architectures, and it has been shown to get
close to comparable performance when COM_REGMAP is defined, and comparable
when it is not defined.

Approved by core@. Fixes PR port-evbmips/32362.
 1.17 10-Jul-2006  thorpej Put appropriate prefixes on property names to reduce chances of name
collisions.
 1.16 07-May-2006  simonb branches: 1.16.4;
Unwrap not-too-long long.
 1.15 05-May-2006  thorpej Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.14 18-Feb-2006  thorpej branches: 1.14.2; 1.14.4; 1.14.6;
- Don't expose dev_propdb directly -- provide devprop_*() wrappers instead.
- Rework the ARMADILLO / epe device properties interaction so that it actually
associates the MAC address property with the epe device instance.
 1.13 11-Dec-2005  christos branches: 1.13.2; 1.13.4; 1.13.6;
merge ktrace-lwp.
 1.12 24-Dec-2004  shige branches: 1.12.10;
Add functions:
- com_opb_cnattach
- com_opb_device_register
 1.11 15-Jul-2003  lukem branches: 1.11.6;
__KERNEL_RCSID()
 1.10 14-Jul-2003  simonb Check return value of prop_get() correctly; serial ports now attach on
a walnut, but don't seem to accept input(?!).
 1.9 04-Jul-2003  thorpej Consult the "frequency" property associated with the device in the
dev_propdb, rather than using "board_info".
 1.8 02-Oct-2002  thorpej branches: 1.8.6;
Add trailing ; to CFATTACH_DECL.
 1.7 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.4 23-Aug-2002  scw branches: 1.4.2; 1.4.4;
Don't assume all com ports run at "COM_FREQ", or a multiple thereof.
Use a board-specific property instead.
 1.3 14-Aug-2002  simonb Remove the "comfound < 2" bogosity.
 1.2 14-Aug-2002  simonb Remove an unused global variable (that was marked with an XXX!).
 1.1 12-Aug-2002  simonb branches: 1.1.2;
Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 12-Aug-2002  nathanw file com_opb.c was added on branch nathanw_sa on 2002-08-13 02:18:43 +0000
 1.4.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.1 23-Aug-2002  jdolecek file com_opb.c was added on branch kqueue on 2002-09-06 08:39:06 +0000
 1.4.2.2 31-Aug-2002  gehenna catch up with -current.
 1.4.2.1 23-Aug-2002  gehenna file com_opb.c was added on branch gehenna-devsw on 2002-08-31 13:45:43 +0000
 1.8.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.8.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.6.1 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.12.10.4 17-Mar-2008  yamt sync with head.
 1.12.10.3 26-Feb-2007  yamt sync with head.
 1.12.10.2 30-Dec-2006  yamt sync with head.
 1.12.10.1 21-Jun-2006  yamt sync with head.
 1.13.6.2 01-Jun-2006  kardel Sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 18-Feb-2006  yamt sync with head.
 1.14.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.4.1 11-May-2006  elad sync with head
 1.14.2.2 11-Aug-2006  yamt sync with head
 1.14.2.1 24-May-2006  yamt sync with head.
 1.16.4.4 13-Jul-2006  gdamore Merge from HEAD.
 1.16.4.3 16-Jun-2006  gdamore Adapt to KNF changes per simonb.
 1.16.4.2 16-Jun-2006  simonb Fix order of arguments to COM_INIT_REGS macro. Fixes console problems
on a Walnut.
 1.16.4.1 15-Jun-2006  gdamore Initial work for PowerPC-specific com(4) rewhack. Compile tested, but I
lack hardware to test. If someone wants to validate, would be appreciated.
(Compile tested for WALNUT, EXPLORA451, and EV64260 kernels.)
 1.18.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.19.42.1 03-Apr-2008  mjf Sync with HEAD.
 1.19.38.1 24-Mar-2008  keiichi sync with head.
 1.19.22.1 23-Mar-2008  matt sync with HEAD
 1.20.36.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.21.54.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.54.1 10-Jun-2019  christos Sync with HEAD
 1.21.52.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.22.4.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #728):

sys/arch/powerpc/ibm4xx/dev/com_opb.c: revision 1.23

Belatedly catch up with MI com(4) change in com.c rev. 1.351:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/ic/com.c#rev1.351

XXX
pullup to netbsd-9
 1.24.2.1 03-Apr-2021  thorpej Sync with HEAD.
 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 11-Dec-2005  christos branches: 1.2.110;
merge ktrace-lwp.
 1.1 24-Dec-2004  shige branches: 1.1.4; 1.1.14;
Add functions:
- com_opb_cnattach
- com_opb_device_register
 1.1.14.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.1.14.1 24-Dec-2004  riz file comopbvar.h was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.1.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.1 24-Dec-2004  skrll file comopbvar.h was added on branch ktrace-lwp on 2005-01-17 19:30:09 +0000
 1.2.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 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 27-Feb-2021  rin branches: 1.6.2;
Switch to intr_establish_xname().
 1.5 23-Apr-2016  skrll branches: 1.5.30;
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.4 30-Jul-2015  skrll Use IPL_VM for dwc2_intr and mark as MP safe where possible.
 1.3 02-Sep-2014  skrll branches: 1.3.2;
Use IPL_SCHED for dwctwo(4) - no need for the KERNEL_LOCK.
 1.2 21-Nov-2013  kiyohara branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.14;
Move the parameters for obs600 to obs600_autoconf.c. This parameters was set from u-boot.
 1.1 21-Nov-2013  kiyohara Support Synopsys DesigneWave OTG on PowerPC 405EX.
 1.2.14.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 21-Nov-2013  tls file dwctwo_plb.c was added on branch tls-maxphys on 2014-08-20 00:03:19 +0000
 1.2.8.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.2.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.1 21-Nov-2013  yamt file dwctwo_plb.c was added on branch yamt-pagecache on 2014-05-22 11:40:04 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 21-Nov-2013  rmind file dwctwo_plb.c was added on branch rmind-smpnet on 2014-05-18 17:45:22 +0000
 1.3.2.2 22-Sep-2015  skrll Sync with HEAD
 1.3.2.1 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.5.30.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.7.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.16 27-Feb-2021  rin Switch to intr_establish_xname().
 1.15 25-Feb-2014  martin branches: 1.15.42;
Remove unused variable
 1.14 18-Jun-2011  matt branches: 1.14.2; 1.14.12; 1.14.16;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.13 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.12 18-Mar-2010  kiyohara branches: 1.12.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.11 05-May-2006  thorpej branches: 1.11.66; 1.11.86; 1.11.88;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.10 24-Dec-2005  perry branches: 1.10.4; 1.10.6; 1.10.8; 1.10.10; 1.10.12;
bare asm -> __asm
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 15-Jul-2003  lukem branches: 1.8.16;
__KERNEL_RCSID()
 1.7 11-Mar-2003  hannken branches: 1.7.2;
Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.2 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.1 23-Aug-2002  scw branches: 1.1.2; 1.1.4; 1.1.6;
Add "ecc at plb" device.
Add an "irq" locator to the plb device.
This gets rid of the original hack where ecc support was wedged into
the cpu driver.
 1.1.6.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 23-Aug-2002  jdolecek file ecc_plb.c was added on branch kqueue on 2002-09-06 08:39:06 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 23-Aug-2002  gehenna file ecc_plb.c was added on branch gehenna-devsw on 2002-08-31 13:45:44 +0000
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 23-Aug-2002  nathanw file ecc_plb.c was added on branch nathanw_sa on 2002-08-27 23:45:07 +0000
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.10.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.10.10.1 11-May-2006  elad sync with head
 1.10.8.1 24-May-2006  yamt sync with head.
 1.10.6.1 01-Jun-2006  kardel Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.88.1 30-May-2010  rmind sync with head
 1.11.86.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.66.1 11-Aug-2010  yamt sync with head.
 1.12.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.16.1 18-May-2014  rmind sync with head
 1.14.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.42.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 02-Nov-2024  andvar s/aboce/above/ and s/Abobe/Above/ in comments.
 1.5 30-Mar-2021  rin branches: 1.5.22;
Support OPB running @ 33MHz for 405GP based boards.
No need to modify EMAC_MR1 register this case
(STACR_OPBC fields are reserved for 405GP).
 1.4 06-Jul-2020  rin branches: 1.4.2; 1.4.4;
Style and cosmetic changes. No binary changes intended.
 1.3 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.2 16-Oct-2006  kiyohara branches: 1.2.56; 1.2.76; 1.2.78;
do bus_space_map() to get bus space handle in emacs_attach()
 1.1 13-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.28; 1.1.58; 1.1.60;
Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.1.60.1 22-Oct-2006  yamt sync with head
 1.1.58.1 18-Nov-2006  ad Sync with head.
 1.1.28.1 30-Dec-2006  yamt sync with head.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Aug-2002  jdolecek file emacreg.h was added on branch kqueue on 2002-09-06 08:39:07 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 13-Aug-2002  gehenna file emacreg.h was added on branch gehenna-devsw on 2002-08-31 13:45:44 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 13-Aug-2002  nathanw file emacreg.h was added on branch nathanw_sa on 2002-08-27 23:45:08 +0000
 1.2.78.1 30-May-2010  rmind sync with head
 1.2.76.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.56.1 11-Aug-2010  yamt sync with head.
 1.4.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5.22.1 02-Aug-2025  perseant Sync with HEAD
 1.5 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.4 24-Apr-2021  thorpej branches: 1.4.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.3 17-Jun-2011  matt branches: 1.3.68;
struct device * -> device_t
struct cfdata * -> cfdata_t
split device/softc (CFATTACH_DECL_NEW)
use device_accessors and device_private
constify
 1.2 06-Nov-2010  uebayasi branches: 1.2.2; 1.2.8; 1.2.10;
Add IBM405GPr "External Bus" driver.
 1.1 11-Aug-2010  uebayasi branches: 1.1.2;
file exb.c was initially added on branch uebayasi-xip.
 1.1.2.2 19-Aug-2010  uebayasi Define FlashROM addresses in board specific code.
 1.1.2.1 11-Aug-2010  uebayasi Implement 405GPr's "External Bus" as exb(4).
 1.2.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.8.2 05-Mar-2011  rmind sync with head
 1.2.8.1 06-Nov-2010  rmind file exb.c was added on branch rmind-uvmplock on 2011-03-05 20:51:36 +0000
 1.2.2.2 10-Jan-2011  jym Sync with HEAD
 1.2.2.1 06-Nov-2010  jym file exb.c was added on branch jym-xensuspend on 2011-01-10 00:37:36 +0000
 1.3.68.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.3.68.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.4.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 06-Nov-2010  uebayasi branches: 1.2.2; 1.2.8;
Add IBM405GPr "External Bus" driver.
 1.1 11-Aug-2010  uebayasi branches: 1.1.2;
file exbvar.h was initially added on branch uebayasi-xip.
 1.1.2.1 11-Aug-2010  uebayasi Implement 405GPr's "External Bus" as exb(4).
 1.2.8.2 05-Mar-2011  rmind sync with head
 1.2.8.1 06-Nov-2010  rmind file exbvar.h was added on branch rmind-uvmplock on 2011-03-05 20:51:36 +0000
 1.2.2.2 10-Jan-2011  jym Sync with HEAD
 1.2.2.1 06-Nov-2010  jym file exbvar.h was added on branch jym-xensuspend on 2011-01-10 00:37:36 +0000
 1.1 11-Aug-2010  uebayasi branches: 1.1.2;
file flash_exb.c was initially added on branch uebayasi-xip.
 1.1.2.1 11-Aug-2010  uebayasi Implement flash(4) glue at exb(4).
 1.13 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 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 22-Dec-2019  thorpej branches: 1.10.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.9 18-Jun-2011  matt branches: 1.9.54;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.8 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.7 12-Jun-2011  kiyohara Initialize i2cbus_attach_args before call config_found(). It has other member.
 1.6 12-Jul-2008  tsutsui branches: 1.6.26;
- if SDA is set to low during DIR(INPUT) in gpiic_set_bits(),
store the SDA status into softc and enable it once after
DIR() is changed to OUTPUT in gpiic_set_dir()
- remove "Read in output mode" warning in gpiic_read_bits()
since it's a vaild operation (to read SCL during SDA output is low)

Tested by kiyohara@ on OPENBLOCKS266.
 1.5 06-Dec-2007  ad branches: 1.5.12; 1.5.16; 1.5.18; 1.5.20; 1.5.22;
lockmgr -> mutex
 1.4 26-Jun-2006  drochner branches: 1.4.18; 1.4.32; 1.4.34; 1.4.40; 1.4.44;
use the "i2cbus" interface attribute rather than putting a string name
into the i2cbus attach args
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.8; 1.3.16;
merge ktrace-lwp.
 1.2 06-Oct-2003  scw branches: 1.2.4; 1.2.18;
Gah. Pick up the MI i2c headers from the right place.
Pointed out by Shigeyuki Fukushima on port-powerpc@.
 1.1 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.2.18.2 07-Dec-2007  yamt sync with head
 1.2.18.1 30-Dec-2006  yamt sync with head.
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 06-Oct-2003  skrll file gpiic_opb.c was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.3.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.8.1 11-Aug-2006  yamt sync with head
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.44.1 08-Dec-2007  ad Sync with head.
 1.4.40.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.34.1 09-Jan-2008  matt sync with HEAD
 1.4.32.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.4.18.1 09-Dec-2007  reinoud Pullup to HEAD
 1.5.22.1 19-Oct-2008  haad Sync with HEAD.
 1.5.20.1 18-Jul-2008  simonb Sync with head.
 1.5.18.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.16.1 04-May-2009  yamt sync with head.
 1.5.12.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.54.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.10.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.11.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 24-Dec-2022  andvar s/Reqest/Request/ and adding apostrophe for don't and didn't in comments.
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 06-Oct-2003  scw branches: 1.1.4;
MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 06-Oct-2003  skrll file gpiicreg.h was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.10 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.9 24-Apr-2021  thorpej branches: 1.9.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.8 17-Jun-2011  matt branches: 1.8.68;
struct device * -> device_t
struct cfdata * -> cfdata_t
split device/softc (CFATTACH_DECL_NEW)
use device_accessors and device_private
constify
 1.7 18-Mar-2010  kiyohara branches: 1.7.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.6 06-Feb-2007  simonb branches: 1.6.48; 1.6.68; 1.6.70;
Fix a tyop in a comment.
 1.5 13-Mar-2006  shige branches: 1.5.10;
IBM4xx on-chip GPIO controller apllying MI GPIO framework.
 1.4 11-Dec-2005  christos branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
merge ktrace-lwp.
 1.3 16-Oct-2005  he Complete the renaming gpio -> ppcgpio for evbppc, to make room for
the MI gpio. Internal static functions in gpio_opb.c are not
renamed here, but the softc type is renamed together with the attach
declaration data.
 1.2 26-Aug-2005  drochner s/locdesc_t/int/g
 1.1 23-Jan-2005  shige branches: 1.1.2; 1.1.10; 1.1.12;
Add driver for On-chip General Purpose I/O.
 1.1.12.2 26-Feb-2007  yamt sync with head.
 1.1.12.1 21-Jun-2006  yamt sync with head.
 1.1.10.2 29-Apr-2005  kent sync with -current
 1.1.10.1 23-Jan-2005  kent file gpio_opb.c was added on branch kent-audio2 on 2005-04-29 11:28:20 +0000
 1.1.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 23-Jan-2005  skrll file gpio_opb.c was added on branch ktrace-lwp on 2005-01-24 08:34:26 +0000
 1.4.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.10.1 09-Feb-2007  ad Sync with HEAD.
 1.6.70.1 30-May-2010  rmind sync with head
 1.6.68.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.48.1 11-Aug-2010  yamt sync with head.
 1.7.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.68.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.9.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 13-Mar-2006  shige IBM4xx on-chip GPIO controller apllying MI GPIO framework.
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.10;
merge ktrace-lwp.
 1.2 23-Jan-2005  shige branches: 1.2.8;
Add driver for On-chip General Purpose I/O.
 1.1 13-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.20;
Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.1.20.1 29-Apr-2005  kent sync with -current
 1.1.12.1 24-Jan-2005  skrll Sync with HEAD.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Aug-2002  jdolecek file gpioreg.h was added on branch kqueue on 2002-09-06 08:39:07 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 13-Aug-2002  gehenna file gpioreg.h was added on branch gehenna-devsw on 2002-08-31 13:45:44 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 13-Aug-2002  nathanw file gpioreg.h was added on branch nathanw_sa on 2002-08-27 23:45:09 +0000
 1.2.8.1 21-Jun-2006  yamt sync with head.
 1.3.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.3.8.1 01-Apr-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3 13-Mar-2006  shige IBM4xx on-chip GPIO controller applying MI GPIO framework.
 1.2 11-Dec-2005  christos branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10;
merge ktrace-lwp.
 1.1 23-Jan-2005  shige branches: 1.1.2; 1.1.10; 1.1.12;
Add driver for On-chip General Purpose I/O.
 1.1.12.1 21-Jun-2006  yamt sync with head.
 1.1.10.2 29-Apr-2005  kent sync with -current
 1.1.10.1 23-Jan-2005  kent file gpiovar.h was added on branch kent-audio2 on 2005-04-29 11:28:20 +0000
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 23-Jan-2005  skrll file gpiovar.h was added on branch ktrace-lwp on 2005-01-24 08:34:27 +0000
 1.2.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.2.8.1 01-Apr-2006  yamt sync with head.
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.8 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.7 17-Aug-2011  matt branches: 1.7.12; 1.7.30; 1.7.34;
First pass of the new PCI MSI/MSI ABI definitions. (return EOPNOTSUPP for
now).
 1.6 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.5 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 11-Dec-2005  christos branches: 1.4.110;
merge ktrace-lwp.
 1.3 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 09-Dec-2002  scw branches: 1.1.2; 1.1.8;
Changes/additions to support evbppc.
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 09-Dec-2002  thorpej file ibm405gp.c was added on branch nathanw_sa on 2002-12-11 06:11:39 +0000
 1.4.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.34.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7.30.1 05-Dec-2016  skrll Sync with HEAD
 1.7.12.1 03-Dec-2017  jdolecek update from HEAD
 1.60 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.59 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.58 02-Feb-2024  andvar fix typos, mainly s/unsupport/unsupported/ in log messages.
 1.57 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.56 30-Mar-2021  rin Support OPB running @ 33MHz for 405GP based boards.
No need to modify EMAC_MR1 register this case
(STACR_OPBC fields are reserved for 405GP).
 1.55 27-Feb-2021  rin branches: 1.55.2;
Switch to intr_establish_xname().
 1.54 24-Jan-2021  rin Add rnd(9) support.
 1.53 06-Jul-2020  rin branches: 1.53.2;
Style and cosmetic changes. No binary changes intended.
 1.52 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.51 28-May-2019  msaitoh branches: 1.51.4;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.50 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.49 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.48 26-Jun-2018  msaitoh branches: 1.48.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.47 15-Dec-2016  ozaki-r branches: 1.47.14;
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.46 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.45 10-Jun-2016  ozaki-r branches: 1.45.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.44 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.43 16-Oct-2014  snj branches: 1.43.2;
fix typo in comment
 1.42 26-Jun-2014  msaitoh Pass MIIF_DOPAUSE mask to mii_attach() in if_emac.c. emac(4) change a
register from IFM_FLOW flag, so this change is required to control the
setting via ifconfig. PR#48950. OK'd by matt@.
 1.41 22-Jul-2012  matt branches: 1.41.2; 1.41.12;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.40 24-Jun-2012  kiyohara Flush current empty descriptor in emac_rxeob_intr().
 1.39 18-Jun-2011  matt branches: 1.39.2;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.38 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.37 05-Apr-2010  joerg branches: 1.37.6;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.36 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.35 22-Jan-2010  martin branches: 1.35.2; 1.35.4;
Unify the name of the device property to hold a MAC address - there was
no clear majority for either "mac-addr" vs. "mac-address", but a quick
gallup poll among developers selected the latter.
 1.34 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

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

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.33 08-Jul-2008  kiyohara Initialize the member sc_callout before call callout_reset().
 1.32 22-Jan-2008  he branches: 1.32.6; 1.32.10; 1.32.12; 1.32.14; 1.32.16;
Delete a now-unused local variable.
 1.31 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.30 17-Oct-2007  garbled branches: 1.30.2; 1.30.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.29 26-Aug-2007  dyoung branches: 1.29.2;
Constify.
 1.28 04-Mar-2007  christos branches: 1.28.2; 1.28.10; 1.28.14; 1.28.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 16-Oct-2006  kiyohara branches: 1.27.4;
do bus_space_map() to get bus space handle in emacs_attach()
 1.26 05-May-2006  thorpej branches: 1.26.8; 1.26.10;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.25 20-Feb-2006  thorpej branches: 1.25.2; 1.25.4; 1.25.6;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.24 18-Feb-2006  thorpej - Don't expose dev_propdb directly -- provide devprop_*() wrappers instead.
- Rework the ARMADILLO / epe device properties interaction so that it actually
associates the MAC address property with the epe device instance.
 1.23 11-Dec-2005  christos branches: 1.23.2; 1.23.4; 1.23.6;
merge ktrace-lwp.
 1.22 30-Jan-2005  thorpej branches: 1.22.6;
Eliminate use of M_HASFCS.
 1.21 21-Jan-2005  simonb branches: 1.21.2;
Set up last segment descriptor to send an interrupt after that
descriptor is transmitted, and bypass existing Tx descriptor reaping
method (for now...).

Fixes problems with bad NFS write performance.
 1.20 21-Jan-2005  simonb In emac_txeob_intr():
- return 1 if we processed any completed tx packets.
- try to get more packets going by calling emac_start().
 1.19 30-Oct-2004  thorpej branches: 1.19.4;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.18 24-Mar-2004  simonb branches: 1.18.4;
Add promiscuous and multicast support.

From KIYOHARA Takashi in PR port-powerpc/23892.
 1.17 27-Oct-2003  simonb Keep bogus gcc -Wuninitialised warnings happy.
 1.16 15-Oct-2003  simonb Correct a test for setting IFF_OACTIVE on the interface.
 1.15 15-Jul-2003  lukem __KERNEL_RCSID()
 1.14 04-Jul-2003  thorpej Consult the "mac-addr" property associated with the emac device in
the dev_propdb rather than referencing board_data.
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
Add trailing ; to CFATTACH_DECL.
 1.12 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.9 13-Aug-2002  simonb Use the base space tag from the attach args, don't recreate it all the
time.
Clean up some include files.
 1.8 13-Aug-2002  simonb Use "ibm4xx" instead of "galaxy"; galaxy was an early code name for the
405GP.
 1.7 13-Aug-2002  simonb Fix include file location botch in previous.
 1.6 13-Aug-2002  simonb Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.5 12-Aug-2002  simonb Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.4 09-Aug-2002  simonb Fix for when EMAC_EVENT_COUNTERS isn't defined. Problem reported by
Allen Briggs.
 1.3 09-Aug-2002  simonb Add a driver the for IBM 405gp (and possibly other IBM 4xx cpus) ethernet
MAC (emac). Much thanks to Jason Thorpe for debugging help writing this
driver. Tested on the walnut, and an earlier version of this driver works
on the OpenBlockSS.
 1.2 15-Mar-2002  eeh branches: 1.2.4;
Use new non-PCI mainbus.
 1.1 24-Jun-2001  simonb branches: 1.1.2; 1.1.8;
Move on-chip 405GP devices to powerpc/ibm4xx/dev.
 1.1.8.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.8.4 27-Aug-2002  nathanw Catch up to -current.
 1.1.8.3 13-Aug-2002  nathanw Catch up to -current.
 1.1.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.8.1 24-Jun-2001  nathanw file if_emac.c was added on branch nathanw_sa on 2002-04-01 07:42:03 +0000
 1.1.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.1 31-Aug-2002  gehenna catch up with -current.
 1.13.6.6 04-Feb-2005  skrll Sync with HEAD.
 1.13.6.5 24-Jan-2005  skrll Sync with HEAD.
 1.13.6.4 02-Nov-2004  skrll Sync with HEAD.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.18.4.1 24-Jan-2005  he Pull up revision 1.19 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.19.4.1 29-Apr-2005  kent sync with -current
 1.21.2.1 12-Feb-2005  yamt sync with head.
 1.22.6.5 04-Feb-2008  yamt sync with head.
 1.22.6.4 21-Jan-2008  yamt sync with head
 1.22.6.3 03-Sep-2007  yamt sync with head.
 1.22.6.2 30-Dec-2006  yamt sync with head.
 1.22.6.1 21-Jun-2006  yamt sync with head.
 1.23.6.2 01-Jun-2006  kardel Sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.23.2.2 01-Mar-2006  yamt sync with head.
 1.23.2.1 18-Feb-2006  yamt sync with head.
 1.25.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.25.4.1 11-May-2006  elad sync with head
 1.25.2.1 24-May-2006  yamt sync with head.
 1.26.10.1 22-Oct-2006  yamt sync with head
 1.26.8.1 18-Nov-2006  ad Sync with head.
 1.27.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.28.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.28.10.1 03-Oct-2007  garbled Sync with HEAD
 1.28.2.1 09-Oct-2007  ad Sync with head.
 1.29.2.2 23-Mar-2008  matt sync with HEAD
 1.29.2.1 06-Nov-2007  matt sync with HEAD
 1.30.8.2 23-Jan-2008  bouyer Sync with HEAD.
 1.30.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.30.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.32.16.1 19-Oct-2008  haad Sync with HEAD.
 1.32.14.1 18-Jul-2008  simonb Sync with head.
 1.32.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.10.3 11-Aug-2010  yamt sync with head.
 1.32.10.2 11-Mar-2010  yamt sync with head
 1.32.10.1 04-May-2009  yamt sync with head.
 1.32.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.35.4.1 30-May-2010  rmind sync with head
 1.35.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.2.1 30-Oct-2012  yamt sync with head
 1.41.12.1 10-Aug-2014  tls Rebase.
 1.41.2.2 03-Dec-2017  jdolecek update from HEAD
 1.41.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.2.3 05-Feb-2017  skrll Sync with HEAD
 1.43.2.2 09-Jul-2016  skrll Sync with HEAD
 1.43.2.1 19-Mar-2016  skrll Sync with HEAD
 1.45.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.14.2 26-Jan-2019  pgoyette Sync with HEAD
 1.47.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.48.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.2.1 10-Jun-2019  christos Sync with HEAD
 1.51.4.1 29-Feb-2020  ad Sync with head.
 1.53.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.55.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 24-Jun-2001  simonb branches: 1.1.8;
Move on-chip 405GP devices to powerpc/ibm4xx/dev.
 1.1.8.2 24-Jun-2001  simonb Move on-chip 405GP devices to powerpc/ibm4xx/dev.
 1.1.8.1 24-Jun-2001  simonb file if_emacreg.h was added on branch nathanw_sa on 2001-06-24 02:13:38 +0000
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file if_emacvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file if_emacvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file if_emacvar.h was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.2 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.1 23-Sep-2003  shige Add on-chip IIC driver.
Add some definitions for IIC driver.
 1.4 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.3 23-Sep-2003  shige Add on-chip IIC driver.
Add some definitions for IIC driver.
 1.2 01-May-2003  scw branches: 1.2.2;
Add bit definitions for some registers.
 1.1 13-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6;
Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Aug-2002  jdolecek file iicreg.h was added on branch kqueue on 2002-09-06 08:39:08 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 13-Aug-2002  gehenna file iicreg.h was added on branch gehenna-devsw on 2002-08-31 13:45:44 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 13-Aug-2002  nathanw file iicreg.h was added on branch nathanw_sa on 2002-08-27 23:45:11 +0000
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.1 23-Sep-2003  shige Add on-chip IIC driver.
Add some definitions for IIC driver.
 1.5 19-Jun-2023  msaitoh Fix typo. unknwon -> unknown
 1.4 27-Feb-2021  rin Switch to intr_establish_xname().
 1.3 18-Jun-2011  matt branches: 1.3.66;
Use __builtin_clz instead of our own cntlzw
 1.2 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file mal.c was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file mal.c was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file mal.c was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.3.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file malvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file malvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file malvar.h was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 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 06-Jul-2020  rin branches: 1.27.4;
Style and cosmetic changes. No binary changes intended.
 1.26 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.25 18-Mar-2010  kiyohara branches: 1.25.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.24 25-Feb-2010  matt branches: 1.24.2;
Adapt to spr.h breakup.
 1.23 13-Mar-2006  shige branches: 1.23.68; 1.23.88; 1.23.92;
IBM4xx on-chip GPIO controller apllying MI GPIO framework.
 1.22 21-Feb-2006  thorpej branches: 1.22.2; 1.22.4;
Add an "instance" member to opb_attach_args and use it when fetching
the mac-address property from board_info. port-powerpc/32862
 1.21 11-Dec-2005  christos branches: 1.21.2; 1.21.4; 1.21.6;
merge ktrace-lwp.
 1.20 26-Aug-2005  drochner s/locdesc_t/int/g
 1.19 03-Jul-2005  he branches: 1.19.2;
We need to name parameters in function declaration...
 1.18 28-Jun-2005  drochner convert remaining autoconf bus "submatch" functions to use the new
signature (passing locators), and remove some which obviously don't
serve any purpose
(untested, sorry)
 1.17 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.16 06-Oct-2003  scw MD i2c glue for the 405GP's onboard IIC controller.
Bit-bang only for now.
 1.15 23-Sep-2003  shige Add devices info for IBM405GPR.
 1.14 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 01-Jan-2003  thorpej branches: 1.12.2;
Use aprint_normal() for cfprint routines.
 1.11 10-Oct-2002  jdolecek fix typo - driver name is 'opb', not 'obp'
 1.10 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.9 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.6 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.5 13-Aug-2002  simonb branches: 1.5.2; 1.5.4;
Use the base space tag from the attach args, don't recreate it all the
time.
Clean up some include files.
 1.4 13-Aug-2002  simonb Use "ibm4xx" instead of "galaxy"; galaxy was an early code name for the
405GP.
 1.3 13-Aug-2002  simonb Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.2 12-Aug-2002  simonb branches: 1.2.2;
Add a pvr field to 'struct opb_dev', to allow the opb_devs array to
contain info about on-chip devices for more than one CPU type.
 1.1 12-Aug-2002  simonb Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.2.2.5 03-Jan-2003  thorpej Sync with HEAD.
 1.2.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.2.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.2.2.1 12-Aug-2002  nathanw file opb.c was added on branch nathanw_sa on 2002-08-13 02:18:43 +0000
 1.5.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.4.1 13-Aug-2002  jdolecek file opb.c was added on branch kqueue on 2002-09-06 08:39:08 +0000
 1.5.2.2 31-Aug-2002  gehenna catch up with -current.
 1.5.2.1 13-Aug-2002  gehenna file opb.c was added on branch gehenna-devsw on 2002-08-31 13:45:44 +0000
 1.12.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.21.2.1 01-Mar-2006  yamt sync with head.
 1.22.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.22.2.1 01-Apr-2006  yamt sync with head.
 1.23.92.1 07-Jan-2011  matt Deal with new powerpc world.
 1.23.88.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.23.68.2 11-Aug-2010  yamt sync with head.
 1.23.68.1 11-Mar-2010  yamt sync with head
 1.24.2.1 30-May-2010  rmind sync with head
 1.25.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.27.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.27.4.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.28.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1 13-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.118; 1.1.138; 1.1.140;
Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.1.140.1 30-May-2010  rmind sync with head
 1.1.138.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.118.1 11-Aug-2010  yamt sync with head.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Aug-2002  jdolecek file opbreg.h was added on branch kqueue on 2002-09-06 08:39:09 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 13-Aug-2002  gehenna file opbreg.h was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 13-Aug-2002  nathanw file opbreg.h was added on branch nathanw_sa on 2002-08-27 23:45:12 +0000
 1.6 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.5 18-Mar-2010  kiyohara branches: 1.5.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.4 21-Feb-2006  thorpej branches: 1.4.72; 1.4.92; 1.4.94;
Add an "instance" member to opb_attach_args and use it when fetching
the mac-address property from board_info. port-powerpc/32862
 1.3 11-Dec-2005  christos branches: 1.3.2; 1.3.4; 1.3.6;
merge ktrace-lwp.
 1.2 25-Jul-2003  scw branches: 1.2.16;
Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.1 12-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12;
Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.1.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.12.1 03-Aug-2004  skrll Sync with HEAD
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 12-Aug-2002  jdolecek file opbvar.h was added on branch kqueue on 2002-09-06 08:39:09 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 12-Aug-2002  gehenna file opbvar.h was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 12-Aug-2002  nathanw file opbvar.h was added on branch nathanw_sa on 2002-08-13 02:18:43 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.1 01-Mar-2006  yamt sync with head.
 1.4.94.1 30-May-2010  rmind sync with head
 1.4.92.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.72.1 11-Aug-2010  yamt sync with head.
 1.5.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2 24-Jun-2023  msaitoh Fix typo in comment.
 1.1 13-Aug-2002  simonb branches: 1.1.2; 1.1.4; 1.1.6;
Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Aug-2002  jdolecek file pcicreg.h was added on branch kqueue on 2002-09-06 08:39:10 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 13-Aug-2002  gehenna file pcicreg.h was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 13-Aug-2002  nathanw file pcicreg.h was added on branch nathanw_sa on 2002-08-27 23:45:13 +0000
 1.25 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.24 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.23 24-Apr-2021  thorpej branches: 1.23.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.22 06-Jul-2020  rin branches: 1.22.4;
Style and cosmetic changes. No binary changes intended.
 1.21 21-Nov-2013  kiyohara Support Synopsys DesigneWave OTG on PowerPC 405EX.
 1.20 18-Jun-2011  matt branches: 1.20.2; 1.20.12; 1.20.16;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.19 06-Jun-2011  matt More device_t, cfdata, CFATTACH_DECL_NEW cleanup.
 1.18 13-Dec-2010  kiyohara branches: 1.18.6;
Fix PR#43911.
 1.17 09-Nov-2010  uebayasi Whitespace.
 1.16 06-Nov-2010  uebayasi Add IBM405GPr "External Bus" driver.
 1.15 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.14 11-Dec-2005  christos branches: 1.14.78; 1.14.98; 1.14.100;
merge ktrace-lwp.
 1.13 28-Jun-2005  drochner convert remaining autoconf bus "submatch" functions to use the new
signature (passing locators), and remove some which obviously don't
serve any purpose
(untested, sorry)
 1.12 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.11 25-Jul-2003  scw Fix the default bus dma tag.
 1.10 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 01-Jan-2003  thorpej branches: 1.8.2;
Use aprint_normal() for cfprint routines.
 1.7 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.3 23-Aug-2002  scw branches: 1.3.2; 1.3.4;
Add "ecc at plb" device.
Add an "irq" locator to the plb device.
This gets rid of the original hack where ecc support was wedged into
the cpu driver.
 1.2 13-Aug-2002  simonb Use "ibm4xx" instead of "galaxy"; galaxy was an early code name for the
405GP.
 1.1 12-Aug-2002  simonb branches: 1.1.2;
Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.1.2.5 03-Jan-2003  thorpej Sync with HEAD.
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 12-Aug-2002  nathanw file plb.c was added on branch nathanw_sa on 2002-08-13 02:18:44 +0000
 1.3.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.4.1 23-Aug-2002  jdolecek file plb.c was added on branch kqueue on 2002-09-06 08:39:10 +0000
 1.3.2.2 31-Aug-2002  gehenna catch up with -current.
 1.3.2.1 23-Aug-2002  gehenna file plb.c was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.100.3 12-Jun-2011  rmind sync with head
 1.14.100.2 05-Mar-2011  rmind sync with head
 1.14.100.1 30-May-2010  rmind sync with head
 1.14.98.4 09-Nov-2010  uebayasi Sync with HEAD.
 1.14.98.3 09-Nov-2010  uebayasi Sync with HEAD.
 1.14.98.2 11-Aug-2010  uebayasi Implement 405GPr's "External Bus" as exb(4).
 1.14.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.14.78.1 11-Aug-2010  yamt sync with head.
 1.18.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.20.16.1 18-May-2014  rmind sync with head
 1.20.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.4.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.23.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 21-Nov-2013  kiyohara Support Synopsys DesigneWave OTG on PowerPC 405EX.
 1.6 18-Jun-2011  matt branches: 1.6.2; 1.6.12; 1.6.16;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.5 18-Mar-2010  kiyohara branches: 1.5.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.4 11-Dec-2005  christos branches: 1.4.78; 1.4.98; 1.4.100;
merge ktrace-lwp.
 1.3 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.2 23-Aug-2002  scw branches: 1.2.2; 1.2.4; 1.2.10;
Add "ecc at plb" device.
Add an "irq" locator to the plb device.
This gets rid of the original hack where ecc support was wedged into
the cpu driver.
 1.1 12-Aug-2002  simonb branches: 1.1.2;
Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.1.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 12-Aug-2002  nathanw file plbvar.h was added on branch nathanw_sa on 2002-08-13 02:18:44 +0000
 1.2.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.10.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.4.1 23-Aug-2002  jdolecek file plbvar.h was added on branch kqueue on 2002-09-06 08:39:11 +0000
 1.2.2.2 31-Aug-2002  gehenna catch up with -current.
 1.2.2.1 23-Aug-2002  gehenna file plbvar.h was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.4.100.1 30-May-2010  rmind sync with head
 1.4.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.78.1 11-Aug-2010  yamt sync with head.
 1.5.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.16.1 18-May-2014  rmind sync with head
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file rgmii.c was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file rgmii.c was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file rgmii.c was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file rgmiireg.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file rgmiireg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file rgmiireg.h was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file rmiivar.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file rmiivar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file rmiivar.h was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.5 18-Sep-2006  gdamore Conversion of evbppc to generic TODR. ok freza@
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 04-Jun-2005  he branches: 1.3.2;
Fix the various todr_gettime() and todr_settime() fallouts from
-Wcast-qual differently, by instead changing the signatore of those
"functions" to take a "volatile struct timeval*" instead of a
"struct timeval*". Many places, these functions are called with
&time, and time is declared as volatile in <sys/kernel.h>. This
way we can get rid of all the ugly casts which now also triggered
warnings, and caused more code to be added to work around the
problem.

Reviewed by thorpej.
 1.2 03-Jun-2005  scw Appease -Wcast-qual
 1.1 06-Oct-2003  shige branches: 1.1.4;
Add Real time clock support code.
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 06-Oct-2003  skrll file rtc.c was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.3.2.1 30-Dec-2006  yamt sync with head.
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.4 17-Sep-2006  gdamore Remove unused todclock files -- these are left overs from pre-generic-TODR.
 1.3 11-Dec-2005  christos branches: 1.3.20;
merge ktrace-lwp.
 1.2 05-Jul-2004  pk branches: 1.2.2; 1.2.14;
Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().
 1.1 23-Sep-2003  shige Move todclock driver from evbppc/walnut/dev.
 1.2.14.1 30-Dec-2006  yamt sync with head.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 05-Jul-2004  skrll file todclock.c was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.3.20.1 18-Nov-2006  ad Sync with head.
 1.3 17-Sep-2006  gdamore Remove unused todclock files -- these are left overs from pre-generic-TODR.
 1.2 11-Dec-2005  christos branches: 1.2.20;
merge ktrace-lwp.
 1.1 23-Sep-2003  shige branches: 1.1.4; 1.1.18;
Move todclock driver from evbppc/walnut/dev.
 1.1.18.1 30-Dec-2006  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 23-Sep-2003  skrll file todclockvar.h was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.2.20.1 18-Nov-2006  ad Sync with head.
 1.12 18-Jun-2011  matt Use aprint_normal include sys/cpu.h
 1.11 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.10 25-Feb-2010  matt branches: 1.10.8;
Adapt to spr.h breakup.
 1.9 05-May-2006  thorpej branches: 1.9.66; 1.9.86; 1.9.90;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
merge ktrace-lwp.
 1.7 15-Jul-2003  lukem branches: 1.7.16;
__KERNEL_RCSID()
 1.6 02-Oct-2002  thorpej branches: 1.6.6;
Add trailing ; to CFATTACH_DECL.
 1.5 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.2 12-Aug-2002  simonb branches: 1.2.2; 1.2.4;
Reorganise the IBM 4xx bus layout, using terminology from the IBM
documentation:
- Remove "mainbus" altogether.
- The new root is "plb" - the Processor Local Bus.
- Attached to this is the "opb" - the On-chip Peripheral Bus, to which
all the on-chip devices are attached (except the cpu and pci host
bridge).
- Port-specific code can pass an array of 'struct plb_dev' to
config_rootfound() to attach extra devices to the plb. The walnut
port attaches a "pbus" (Peripheral Bus) in here for the RTC and
pc keyboard controller to attach to.
There is still much 405GP specific code; the next round of changes will
generalise this to enable easier support for other 4xx CPUs.
 1.1 01-Aug-2002  simonb branches: 1.1.2;
Add driver for 405gp (and other 4xx?) watchdog timer.
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.1.2.1 01-Aug-2002  nathanw file wdog.c was added on branch nathanw_sa on 2002-08-06 22:47:09 +0000
 1.2.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.4.1 12-Aug-2002  jdolecek file wdog.c was added on branch kqueue on 2002-09-06 08:39:12 +0000
 1.2.2.2 31-Aug-2002  gehenna catch up with -current.
 1.2.2.1 12-Aug-2002  gehenna file wdog.c was added on branch gehenna-devsw on 2002-08-31 13:45:45 +0000
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 11-May-2006  elad sync with head
 1.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 01-Jun-2006  kardel Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.90.1 07-Jan-2011  matt Deal with new powerpc world.
 1.9.86.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.9.66.1 11-Mar-2010  yamt sync with head
 1.10.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1 20-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Fix build failed.
Add forgot zmiireg.h since support 405EX.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 20-Mar-2010  yamt file zmiireg.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:33 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 20-Mar-2010  rmind file zmiireg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:02 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 20-Mar-2010  uebayasi file zmiireg.h was added on branch uebayasi-xip on 2010-04-30 14:39:42 +0000
 1.17 30-Mar-2021  rin Use mnemonic "bdneq". Add missing register prefix.

No binary changes.
 1.16 07-Mar-2021  simonb branches: 1.16.2;
Remove unused/unreferenced legacy intrcnt/intrnames.
 1.15 06-Jul-2020  rin branches: 1.15.2;
Do not silently #undef PPC_4XX_NOCACHE, which results in terrible confusion.
Raise #error instead.
 1.14 06-Jul-2020  rin Drop unused opt_lockdebug.h, opt_multiprocessor.h, and opt_ppcarch.h.
 1.13 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.12 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.11 05-Aug-2014  joerg branches: 1.11.26; 1.11.28;
The argument of stwu is displacement(register), but GAS translates the
%rX mnemonic very early into plain X, so it seemingly accepts
%register(displacement) as well. Be consistent in the formatting for
human consumption.
 1.10 20-Jun-2011  matt branches: 1.10.12; 1.10.26;
Don't include *pmap.h in assembly files. Get the needed definitions
from "assym.h".
 1.9 17-Jan-2011  matt branches: 1.9.4;
Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.8 18-Mar-2010  kiyohara branches: 1.8.2;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.7 25-Feb-2010  matt branches: 1.7.2;
Adapt to spr.h breakup.
 1.6 26-Nov-2009  matt branches: 1.6.2;
Kill proc0paddr. Use lwp0.l_addr instead.
 1.5 13-Feb-2009  apb Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.4 13-Nov-2008  ad branches: 1.4.4;
LKM -> MODULAR
 1.3 16-Oct-2006  kiyohara branches: 1.3.52; 1.3.56; 1.3.62; 1.3.64; 1.3.74;
* convert ibm4xx-based evbppc from reserved-TLB entry allocation to recently
introduced ppc4xx_tlb_reserve() API.
* ibm405gp UART0 used to be linear mapped. The VA happens to be inside kernel
segment, giving us the possibility of multiple VA matches in the TLB. This
is considered "programming error" by 405 core and results in "undefined
behaviour". We now avoid mapping peripherals in kernel segment.
* Some boards used to map hardwired RAM size. We now use the real size as
passed in by boot firmware.
 1.2 11-Dec-2005  christos branches: 1.2.20; 1.2.22;
merge ktrace-lwp.
 1.1 23-Sep-2003  shige branches: 1.1.4; 1.1.18;
Copy IBM4XX OpenBIOS locore.S from evbppc/walnut.
 1.1.18.1 30-Dec-2006  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 23-Sep-2003  skrll file locore.S was added on branch ktrace-lwp on 2004-08-03 10:39:28 +0000
 1.2.22.1 22-Oct-2006  yamt sync with head
 1.2.20.1 18-Nov-2006  ad Sync with head.
 1.3.74.1 07-Jan-2011  matt Deal with new powerpc world.
 1.3.64.2 03-Mar-2009  skrll Sync with HEAD.
 1.3.64.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.62.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.56.3 11-Aug-2010  yamt sync with head.
 1.3.56.2 11-Mar-2010  yamt sync with head
 1.3.56.1 04-May-2009  yamt sync with head.
 1.3.52.1 17-Jan-2009  mjf Sync with HEAD.
 1.4.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.2.2 05-Mar-2011  rmind sync with head
 1.7.2.1 30-May-2010  rmind sync with head
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.26.1 10-Aug-2014  tls Rebase.
 1.10.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 10-Jun-2019  christos Sync with HEAD
 1.11.26.1 28-Jul-2018  pgoyette Sync with HEAD
 1.15.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.16.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 30-Mar-2021  rin - Document IBM/AMCC Walnut is supported by this file.
- Misc style fixes.
 1.6 30-Mar-2021  rin Remove unused "startkernel" argument for openbios_board_init().
 1.5 18-Jun-2011  matt branches: 1.5.66; 1.5.68;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 22-Feb-2007  thorpej branches: 1.4.78;
TRUE -> true, FALSE -> false
 1.3 05-May-2006  thorpej branches: 1.3.14;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.2 11-Dec-2005  christos branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12;
merge ktrace-lwp.
 1.1 17-Jan-2005  shige branches: 1.1.2; 1.1.10; 1.1.12; 1.1.14;
Add openbios-board related modules.
- openbios.c
getting board data memory image from openbios.
setting all board data to board properties database.
- board_prop.c
initialize board properties database.
(set/get board properties [macros in ibm4xx/cpu.h])
 1.1.14.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.1.14.1 17-Jan-2005  riz file openbios.c was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.1.12.2 26-Feb-2007  yamt sync with head.
 1.1.12.1 21-Jun-2006  yamt sync with head.
 1.1.10.2 29-Apr-2005  kent sync with -current
 1.1.10.1 17-Jan-2005  kent file openbios.c was added on branch kent-audio2 on 2005-04-29 11:28:20 +0000
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 17-Jan-2005  skrll file openbios.c was added on branch ktrace-lwp on 2005-01-24 08:34:27 +0000
 1.2.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.10.1 11-May-2006  elad sync with head
 1.2.8.1 24-May-2006  yamt sync with head.
 1.2.6.1 01-Jun-2006  kardel Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.3.14.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.4.78.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.68.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.16 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.15 24-Apr-2021  thorpej branches: 1.15.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

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

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

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

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.13 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.12 14-Jun-2020  chs replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.11 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.10 22-Jun-2011  matt branches: 1.10.2; 1.10.6;
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.9 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.8 06-Jun-2011  matt More device_t, cfdata, CFATTACH_DECL_NEW cleanup.
 1.7 17-May-2011  dyoung branches: 1.7.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.6 04-May-2008  martin branches: 1.6.22; 1.6.28;
Move to standard TNF 2 clause license
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 04-Sep-2005  kiyohara Support the 'PCMCIA adapter BOX' for OpenBlockS266.
 1.3 30-Aug-2004  drochner branches: 1.3.10; 1.3.12;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.2 24-Apr-2004  kleink branches: 1.2.2;
Update for new pci_devinfo(9) signature.
 1.1 23-Sep-2003  shige Copy PCI codes for IBM405GPx from evbppc/walnut/pci/{pchb.c,pci_machdep.c}.
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.3 03-Sep-2004  skrll Sync with HEAD
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 24-Apr-2004  skrll file pchb.c was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.3.12.1 21-Jun-2006  yamt sync with head.
 1.3.10.1 14-Sep-2005  tron Apply patch (requested by shige in ticket #763):
Synchronize OpenBlockS266 port with NetBSD-current for enhanced stability.
 1.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.22.2 12-Jun-2011  rmind sync with head
 1.6.22.1 31-May-2011  rmind sync with head
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.6.1 18-Feb-2012  mrg merge to -current.
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.14.4.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.15.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.13 15-Oct-2022  rin DHT Walnut: Fix failure to attach on-board pdcide(4) for cold boot.

U-Boot seems to initialize pdcide(4) to compatible mode. Therefore, we
need to reinitialize it to native-PCI mode in pci_conf_hook(). Otherwise,
we will fail to configure IO registers for native-PCI mode during
PCI_NETBSD_CONFIGURE.
 1.12 06-Jul-2020  rin Include missing opt_pci.h
 1.11 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.10 22-Jun-2011  matt branches: 1.10.12; 1.10.30;
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.9 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.8 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.7 18-Mar-2010  kiyohara branches: 1.7.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.6 30-May-2008  ad branches: 1.6.18; 1.6.20;
pci_intr_setattr(), allows PCI interrupts to be marked MPSAFE on x86, and
other platforms if the code is added.

pci_intr_map(...)
pci_intr_setattr(pc, ih, PCI_INTR_MPSAFE, 1);
pci_intr_establish(...)
 1.5 30-Jun-2006  freza branches: 1.5.58; 1.5.60; 1.5.62; 1.5.64;
Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.4 29-Mar-2006  shige branches: 1.4.4;
Move pci_intr_map and pci_conf_interrupt functions to MD codes.
Change Max PCI devices from 5 to 31.
 1.3 10-Feb-2006  gdamore branches: 1.3.2; 1.3.4; 1.3.6;
PCI_NETBSD_CONFIGURE should allocate (but not map) address space expansion
ROMS by default. Full discussion at
http://mail-index.netbsd.org/tech-kern/2005/12/16/0023.html
Closes PR kern/32467
Reviewed by briggs@
 1.2 11-Dec-2005  christos branches: 1.2.2; 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 23-Sep-2003  shige branches: 1.1.4; 1.1.18;
Copy PCI codes for IBM405GPx from evbppc/walnut/pci/{pchb.c,pci_machdep.c}.
 1.1.18.2 30-Dec-2006  yamt sync with head.
 1.1.18.1 21-Jun-2006  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 23-Sep-2003  skrll file pci_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 18-Feb-2006  yamt sync with head.
 1.3.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.3.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.3.2.2 11-Aug-2006  yamt sync with head
 1.3.2.1 01-Apr-2006  yamt sync with head.
 1.4.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.64.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.62.2 11-Aug-2010  yamt sync with head.
 1.5.62.1 04-May-2009  yamt sync with head.
 1.5.60.1 04-Jun-2008  yamt sync with head
 1.5.58.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.20.1 30-May-2010  rmind sync with head
 1.6.18.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.30.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.10.12.1 03-Dec-2017  jdolecek update from HEAD
 1.45 30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.44 04-Nov-2024  christos Undo previous lwp.h change.
 1.43 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.42 12-Jul-2018  maxv branches: 1.42.36;
Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

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

* Removes the PMC code of ARM XSCALE.

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

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

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

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.41 21-Dec-2015  christos branches: 1.41.16; 1.41.18;
Add mips fenv.h (From FreeBSD)
 1.40 23-Jul-2014  alnsn branches: 1.40.4;
Rename sljitarch.h to sljit_machdep.h.
 1.39 17-Nov-2013  alnsn branches: 1.39.2;
Enable sljit and bpfjit on powerpc.
 1.38 17-Jul-2011  joerg branches: 1.38.2; 1.38.12; 1.38.16;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.37 20-Jun-2011  matt Readd powerpc/include/vmparam.h to the set lists
Export it to powerpc/include.h
Protect pmap.h and vmparam.h from getting an #error when included
from userland.
Export safe definitions of VM_MAXUSER_ADDRESS, VM_MIN_ADDRESS,
VM_MAX_ADDRESS when _RUMPKERNEL is defined.
 1.36 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.35 02-Mar-2010  matt branches: 1.35.2; 1.35.4; 1.35.8;
Add missing <powerpc/FOO/spr.h> to a few files missed on the first pass.
Don't export <machine/spr.h> to userland, only <powerpc/spr.h>
 1.34 09-Feb-2007  ad branches: 1.34.48; 1.34.68;
Merge newlock2 to head.
 1.33 11-Dec-2005  christos branches: 1.33.20;
merge ktrace-lwp.
 1.32 17-Feb-2005  briggs branches: 1.32.6;
Install spr.h
 1.31 08-May-2004  kleink branches: 1.31.4; 1.31.6;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.30 20-Oct-2003  matt Reorganize the way powerpc port install machine specific headers.
Use <powerpc/oea/bat.h> exclusively and remove <machine/bat.h> and
<powerpc/bat.h>. Remove unneeded <machine/cpufunc.h>. To insure
1:1 correspondence of <powerpc/FOO.h> to <machine/FOO.h> include
"../../powerpc/include/Makefile" in "arch/FOO/include/Makefile".
Incororpate <byte_swap.h> into <bswap.h> and then byte_swap.h
 1.29 18-Jan-2003  thorpej branches: 1.29.2;
Merge the nathanw_sa branch.
 1.28 26-Nov-2002  lukem Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.27 04-Nov-2002  jdolecek back previous off; don't install macho_machdep.h
 1.26 30-Oct-2002  manu Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.25 07-Aug-2002  briggs Implement pmc(9) -- An interface to hardware performance monitoring
counters. These counters do not exist on all CPUs, but where they
do exist, can be used for counting events such as dcache misses that
would otherwise be difficult or impossible to instrument by code
inspection or hardware simulation.

pmc(9) is meant to be a general interface. Initially, the Intel XScale
counters are the only ones supported.
 1.24 28-Jul-2002  chs install atomic.h.
 1.23 13-Jun-2001  simonb branches: 1.23.2; 1.23.8; 1.23.16;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.22 12-Jun-2001  tsubai Include powerpc/mpc6xx/{bat.h,pte.h} if PPC_MPC6XX is defined.
 1.21 10-Jun-2001  tsubai Make the new pmap optional. Use the old (stable!) pmap by default.
 1.20 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.19 30-May-2001  tsubai Inline bswap{16,32} when the argument is constant.
 1.18 03-May-2001  soren PPC machine type tags haven't been used for a while.
 1.17 15-Apr-2001  kleink Add definitions of C99 integer format conversion macros.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.16 15-Apr-2001  kleink Add definitions of C99 specified-width integer type limits.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.15 14-Apr-2001  kleink Add definitions of C99 integer constant macros.
Tidy Makefiles up a little.
 1.14 14-Apr-2001  kleink Add definitions of C99 minimum-width and greatest-width integer types.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.13 07-Feb-2001  tsutsui branches: 1.13.2;
Add pio.h to INCS.
 1.12 09-Nov-2000  tsubai powerpc HID registers definitions (only HID0 for now).
 1.11 26-Jun-2000  kleink Add <machine/int_types.h>, which provides namespace-pure definitions
of exact-width integer types.
 1.10 29-Apr-2000  thorpej Require that each each MACHINE/MACHINE_ARCH supply a lock.h. This file
contains the values __SIMPLELOCK_LOCKED and __SIMPLELOCK_UNLOCKED, which
replace the old SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED. These files
are also required to supply inline functions __cpu_simple_lock(),
__cpu_simple_lock_try(), and __cpu_simple_unlock() if locking is to be
supported on that platform (i.e. if MULTIPROCESSOR is defined in the
_KERNEL case). Change these functions to take an int * (&alp->lock_data)
rather than the struct simplelock * itself.

These changes make it possible for userland to use the locking primitives
by including <machine/lock.h>.
 1.9 17-Mar-2000  tron Install "machineendian_machdep.h".
 1.8 27-Feb-2000  tsubai Rewrite stdarg/varargs.
 1.7 18-Feb-2000  tsubai Remove vmparam.h.
 1.6 23-Dec-1999  kleink C99: Define a NAN macro in <math.h> which evaulates to a constant expression of
a single-precision quiet NaN; only to be defined on platforms that do support
this value.
 1.5 18-Dec-1999  thorpej Hardware Implementation Dependent registers for the PowerPC 601.
 1.4 05-May-1999  tsubai branches: 1.4.2; 1.4.8;
Add cpu.h.
 1.3 17-Jan-1999  tsubai branches: 1.3.4;
Add missing backslash.
 1.2 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.3.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.4.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.23.16.1 31-Aug-2002  gehenna catch up with -current.
 1.23.8.5 11-Dec-2002  thorpej Sync with HEAD.
 1.23.8.4 13-Aug-2002  nathanw Catch up to -current.
 1.23.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.23.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.23.8.1 13-Jun-2001  briggs file Makefile was added on branch nathanw_sa on 2001-11-05 19:46:16 +0000
 1.23.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.29.2.4 17-Feb-2005  skrll Sync with HEAD.
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.31.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.31.4.1 29-Apr-2005  kent sync with -current
 1.32.6.1 26-Feb-2007  yamt sync with head.
 1.33.20.1 30-Jan-2007  ad Add missing headers.
 1.34.68.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.48.1 11-Mar-2010  yamt sync with head
 1.35.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.35.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.35.2.1 12-Jun-2011  rmind sync with head
 1.38.16.1 18-May-2014  rmind sync with head
 1.38.12.2 03-Dec-2017  jdolecek update from HEAD
 1.38.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.2.1 10-Aug-2014  tls Rebase.
 1.40.4.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.41.18.1 10-Jun-2019  christos Sync with HEAD
 1.41.16.1 28-Jul-2018  pgoyette Sync with HEAD
 1.42.36.1 02-Aug-2025  perseant Sync with HEAD
 1.3 10-Aug-2014  joerg Put GCC/GAS specific options under ACTIVE_CC == "gcc".
 1.2 26-Oct-2011  chs branches: 1.2.12;
avoid linker warnings with the new binutils by not forcing rump modules
to be soft-float.
 1.1 19-Dec-2002  thorpej branches: 1.1.2;
Build LKMs with -msoft-float.
 1.1.2.2 19-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 19-Dec-2002  thorpej file Makefile.inc was added on branch nathanw_sa on 2002-12-19 23:20:18 +0000
 1.2.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19 28-May-2022  andvar fix various typos in comments.
 1.18 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.17 16-Mar-2017  chs branches: 1.17.12;
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.16 22-Aug-2013  drochner branches: 1.16.6; 1.16.10; 1.16.14;
-extend the pcu(9) API by a function which saves all context on the
current CPU, and use it if a CPU is taken offline
-add a bool argument to pcu_discard which tells whether the internal
"LWP has used the coprocessor" flag should be set or reset. The flag
is reported by pcu_used_p(). If set, future accesses should use the
state stored in the PCB. If reset, it should be reset to default.
The former case is useful for setmcontext().
With that, it should not be necessary anymore to manage the "FPU used"
state by an additional MD variable.

approved by matt
 1.15 02-May-2011  matt branches: 1.15.4; 1.15.14; 1.15.18;
Fix cut/paste error.
 1.14 02-May-2011  matt Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.13 18-Jan-2011  matt 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.12 28-Apr-2008  martin branches: 1.12.22; 1.12.26; 1.12.28;
Remove clause 3 and 4 from TNF licenses
 1.11 17-Oct-2007  garbled branches: 1.11.16; 1.11.18; 1.11.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.10 11-Dec-2005  christos branches: 1.10.30; 1.10.38; 1.10.48; 1.10.50; 1.10.52; 1.10.54;
merge ktrace-lwp.
 1.9 16-Apr-2004  matt branches: 1.9.12;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.8 23-Jun-2003  martin branches: 1.8.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.7 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.6 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.5 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.4 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.3 18-Jul-2002  matt Make sure that pmap_zero_page and pmap_copy_page don't make calls or
reference while relocation is disabled since the stack will be inaccessible.
Add support for using AltiVec in pmap_zero_page and pmap_copy_page on
AltiVec capable processors.
 1.2 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.1 19-Nov-2000  matt branches: 1.1.2; 1.1.6; 1.1.10; 1.1.18;
Add AltiVec VSCR definitions.
 1.1.18.3 31-Aug-2002  gehenna catch up with -current.
 1.1.18.2 21-Jul-2002  gehenna catch up with -current.
 1.1.18.1 16-Jul-2002  gehenna catch up with -current.
 1.1.10.3 11-Nov-2002  nathanw Catch up to -current
 1.1.10.2 01-Aug-2002  nathanw LWPify.
 1.1.10.1 01-Aug-2002  nathanw Catch up to -current.
 1.1.6.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 19-Nov-2000  bouyer file altivec.h was added on branch thorpej_scsipi on 2000-11-22 16:01:27 +0000
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.12.1 27-Oct-2007  yamt sync with head.
 1.10.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.52.1 18-Oct-2007  yamt sync with head.
 1.10.50.1 06-Nov-2007  matt sync with HEAD
 1.10.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.10.38.1 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.10.30.1 23-Oct-2007  ad Sync with head.
 1.11.20.1 16-May-2008  yamt sync with head.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.11.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.26.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.12.22.2 31-May-2011  rmind sync with head
 1.12.22.1 05-Mar-2011  rmind sync with head
 1.15.18.1 28-Aug-2013  rmind sync with head
 1.15.14.2 03-Dec-2017  jdolecek update from HEAD
 1.15.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.16.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.16.6.1 28-Aug-2017  skrll Sync with HEAD
 1.17.12.1 22-Apr-2018  pgoyette Sync with HEAD
 1.31 07-May-2019  kamil Switch all users (except ia64) of custom machine/ansi.h to common_ansi.h

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

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

Proposed and discussed on a mailing list (twice).

Itanium uses custom !ELF fallback switch, temporarily leave it as it is.
 1.30 17-Jun-2015  matt branches: 1.30.18;
Make _BSD_CLOCK_T_ unsigned int so it's the same for IPL32 and LP64
environments. We don't really have a powerpc64 native userland
and the mips64 native userland is IPL32 so this shouldn't affect anything.
 1.29 17-Jul-2011  joerg branches: 1.29.12; 1.29.28; 1.29.30;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.28 27-Mar-2010  tnozaki 1. {wctype,wctrans,mbstate}_t: switch MD to MI like other
libc implementation (such as *BSD and glibc2).

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

no ABI change was made.
 1.27 11-Jan-2009  christos branches: 1.27.4; 1.27.6;
merge christos-time_t
 1.26 21-Jun-2008  gmcgarry branches: 1.26.4;
Add stdargs support for pcc.
 1.25 17-Oct-2007  garbled branches: 1.25.16; 1.25.18; 1.25.22; 1.25.24; 1.25.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.24 03-Sep-2007  drochner clean up some definitions around rune_t which are not needed anymore
 1.23 04-Oct-2006  tnozaki branches: 1.23.8; 1.23.16; 1.23.22; 1.23.26; 1.23.28;
fix gcc -Werror -Wmissing-braces problem
mbstate_t(this is opaque object)'s initializer should be ``{ 0 }'',
so changed 1st field of union from character array to integer.
 1.22 11-Dec-2005  christos branches: 1.22.20; 1.22.22;
merge ktrace-lwp.
 1.21 24-Sep-2003  matt branches: 1.21.16;
Define va_list as __builtin_va_list for GCC 3.x. Change stdarg macros
appropriately. (this is committed from a system run a kernel and userland
built with these changes).
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19 02-Mar-2003  tshiozak branches: 1.19.2;
add some ISO C 1995 I18N functions and types:
btowc, wctrans, towctrans, wcscoll, wcsxfrm, wctype_t and wctrans_t.
 1.18 18-Jan-2003  matt Fix LP64 botch.
 1.17 04-Dec-2002  thorpej Revert my previous GCC 3.3-related changes; GCC 3.3 has been fixed
to handle our stdarg/varargs ABI for PowerPC.
 1.16 25-Oct-2002  thorpej Make these work with GCC 3.x.
 1.15 14-Aug-2002  matt Prepare for PPC64. Use register_t for mtmsr/mfmsr since the msr on PPC64
is 64bits wide. Define proper types for PPC64 if _LP64 is defined.
 1.14 07-Aug-2002  tsubai Re-correct previous. It's intentional.
 1.13 07-Aug-2002  matt Correct __va_list typedef for GCC 3.* to match the GCC 3.* definition.
 1.12 01-Jun-2002  tsubai Add gcc 3.x version.
 1.11 03-Jan-2001  takemura branches: 1.11.4; 1.11.8; 1.11.16; 1.11.18;
replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.10 26-Dec-2000  itojun make mbstate_t bigger (32 -> 128 bytes).
XXX if you have libc after citrus locale import, please recompile libc,
and your applications that use mbstate_t (rather rare). really sorry
for the mess.
 1.9 21-Dec-2000  itojun populate _BSD_MBSTATE_T_. add warning regarding to rune_t.
 1.8 27-Jun-2000  kleink G/c _BSD_INTPTR_T_ and _BSD_UINTPTR_T_.
 1.7 27-Feb-2000  tsubai branches: 1.7.2;
Rewrite stdarg/varargs.
 1.6 16-Aug-1998  kleink branches: 1.6.12;
Add missing wint_t (currently unused).
 1.5 27-Apr-1998  kleink Provide definitions for intptr_t and uintptr_t, signed resp. unsigned integral
types large enough to hold any pointer.
 1.4 23-Nov-1997  kleink Add _BSD_SUSECONDS_T_ and _BSD_USECONDS_T_; do some space vs. tab formatting
cleanup
 1.3 16-Apr-1997  thorpej Update to varargs/stdarg implementation; conform to the SVR4 calling
convention.
 1.2 15-Nov-1996  jtc Define _BSD_CLOCKID_T_ and _BSD_TIMER_T_
 1.1 30-Sep-1996  ws PowerPC port
 1.6.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.6.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.11.18.2 21-Nov-2002  he Apply patch (requested by he in ticket #638):
Back out latest change -- it is somewhat controversial,
ref. revision 1.14 and causes a build problem.
 1.11.18.1 16-Nov-2002  he Pull up revision 1.13 (via patch, requested by matt in ticket #638):
Correct __va_list typedef for GCC 3.x to match the GCC 3.x
definition.
 1.11.16.2 31-Aug-2002  gehenna catch up with -current.
 1.11.16.1 15-Jul-2002  gehenna catch up with -current.
 1.11.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.11.8.3 11-Nov-2002  nathanw Catch up to -current
 1.11.8.2 27-Aug-2002  nathanw Catch up to -current.
 1.11.8.1 20-Jun-2002  nathanw Catch up to -current.
 1.11.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.11.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.16.2 27-Oct-2007  yamt sync with head.
 1.21.16.1 30-Dec-2006  yamt sync with head.
 1.22.22.1 22-Oct-2006  yamt sync with head
 1.22.20.1 18-Nov-2006  ad Sync with head.
 1.23.28.1 06-Nov-2007  matt sync with HEAD
 1.23.26.1 02-Oct-2007  joerg Sync with HEAD.
 1.23.22.1 10-Sep-2007  skrll Sync with HEAD.
 1.23.16.1 03-Oct-2007  garbled Sync with HEAD
 1.23.8.1 09-Oct-2007  ad Sync with head.
 1.25.26.1 27-Jun-2008  simonb Sync with head.
 1.25.24.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.22.2 11-Aug-2010  yamt sync with head.
 1.25.22.1 04-May-2009  yamt sync with head.
 1.25.18.4 04-Jan-2009  christos handle LP64
 1.25.18.3 01-Nov-2008  christos Sync with head.
 1.25.18.2 30-Mar-2008  christos time_t is now __int64_t
 1.25.18.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.25.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.25.16.1 29-Jun-2008  mjf Sync with HEAD.
 1.26.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.6.1 30-May-2010  rmind sync with head
 1.27.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.29.30.1 22-Sep-2015  skrll Sync with HEAD
 1.29.28.1 16-Jul-2015  riz Pull up following revision(s) (requested by martin in ticket #846):
sys/arch/mips/include/ansi.h: revision 1.29
sys/arch/sh3/include/ansi.h: revision 1.16
sys/arch/sparc64/include/ansi.h: revision 1.18
sys/arch/m68k/include/ansi.h: revision 1.24
sys/arch/powerpc/include/ansi.h: revision 1.30
sys/arch/hppa/include/ansi.h: revision 1.14
sys/arch/i386/include/ansi.h: revision 1.27
sys/arch/alpha/include/ansi.h: revision 1.25
sys/arch/usermode/include/ansi.h: revision 1.5
sys/arch/sparc/include/ansi.h: revision 1.24
Make _BSD_CLOCK_T_ unsigned int so it's the same for IPL32 and LP64
environments. We don't really have a powerpc64 native userland
and the mips64 native userland is IPL32 so this shouldn't affect anything.
Make clock_t unsigned
Make clock_t unsigned int everywhere.
Ok: matt@, mrg@
 1.29.12.1 03-Dec-2017  jdolecek update from HEAD
 1.30.18.1 10-Jun-2019  christos Sync with HEAD
 1.6 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.5 10-Dec-2002  thorpej Rename __LDPGSZ to AOUT_LDPGSZ, to accurately reflect what it is.
 1.4 28-Oct-2002  manu Changed the ifndef guard of this header file from _MACH_EXEC_H_ to
_POWERPC_AOUT_EXEC_H_. The former was conflicting with
<compat/mach/mach_exec.h>.
 1.3 09-Feb-2001  wiz branches: 1.3.8;
De-lint. Reviewed by christos.
 1.2 03-Dec-1998  sakamoto branches: 1.2.10;
Change r_type bit field size 5 to 6 and reduce unused bit(2 to 1).
Suggested by Mirian Crzig Lennox.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.10.1 11-Feb-2001  bouyer Sync with HEAD.
 1.3.8.2 11-Dec-2002  thorpej Sync with HEAD.
 1.3.8.1 11-Nov-2002  nathanw Catch up to -current
 1.56 06-Jan-2025  martin PR 58960: fix misunderstanding in semantic and provide both the original
id string as well as _NETBSD_REVISIONID.
Do not rely on string concatenation in the inline assembler, use .ascii
and .asciz for individual string parts instead.
 1.55 04-Jan-2025  martin PR 58960: powerpc/asm.h: Respect NETBSD_REVISIONID.
 1.54 10-Feb-2024  andvar branches: 1.54.2;
s/psuedo/pseudo/ in comments.
 1.53 07-Jan-2022  andvar s/udpate/update/
 1.52 06-Jul-2020  rin Consistently use _LP64 instead of __LP64__, although both are defined for
powerpc64.

No binary changes intended.
 1.51 18-Apr-2020  joerg It's __RCSID for an extra level of indirection on PPC
 1.50 17-Apr-2020  joerg Mark the .ident section as mergable string section to avoid redundant
entries.
 1.49 01-Mar-2020  rin branches: 1.49.4;
Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.48 12-Jan-2015  dennis branches: 1.48.18; 1.48.22;
Name the offsets to the remaining fields in the ppc64
stack frame header. Add a stack frame alignment macro
to avoid hard-coding that.
 1.47 23-Aug-2014  matt branches: 1.47.2;
Fix cmpptr/cmpreq/etc to use right mnemonics
 1.46 06-Mar-2014  matt branches: 1.46.4;
Add _XENTRY which doesn't set the section to .text
 1.45 28-Feb-2014  matt Add cmp{ptr,long,reg}{,l}{,i}
 1.44 27-Feb-2014  matt Use ## for concatenation
 1.43 27-Feb-2014  matt Add P2SZREG to be usign with .p2align
 1.42 12-Sep-2013  joerg Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
 1.41 29-Jan-2013  kiyohara branches: 1.41.2;
Support 16bits over stack size.
 1.40 25-Nov-2012  christos provide _ENTRY(x) because some code needs it.
 1.39 26-Oct-2011  christos branches: 1.39.2; 1.39.12;
- Indent ifdefs, comment endif and else cpp tags
- Add missing END macro for LP64
- Make whitespace consistent
 1.38 08-Jun-2011  matt In INIT_CPUINFO, make L_CPU to set the cpu_info (just to be safe).
 1.37 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.36 07-Feb-2011  matt branches: 1.36.2;
binutils is automagically doing securecrt so make sure plt calls are emitted
with the secureplt magic as well.
 1.35 23-Jan-2011  matt Some ports use %r0 as tmp2 to INIT_CPUINFO which has adverse effects so
never use tmp2 to hold an address.
 1.34 18-Jan-2011  matt branches: 1.34.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.33 17-Jan-2011  matt Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.32 16-Jan-2011  matt branches: 1.32.2;
Add PIC_GOTSETUP and PIC_TOCSETUP which replace the old methods to get the
GOT (via a bl) to the new REL16 based relocs. This is another step to
supporting secure plt.
 1.31 15-Jan-2011  matt Add END(sym)
Add __RCSID (to match cdefs.h)
 1.30 20-Dec-2010  joerg Consistently use .gnu.warning with .pushsectio and .popsection on all
architectures instead of obsolete STABS frames for linker warnings.
 1.29 09-Mar-2010  matt branches: 1.29.2;
Put ASM RCSIDs into .ident
 1.28 10-Dec-2009  rmind branches: 1.28.2;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.27 26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.26 23-Feb-2008  matt branches: 1.26.4; 1.26.26;
Add clrr{ptr,long,reg}i, l{ptr,long,reg}arx, st{ptr,long,reg}cx macros
 1.25 17-Oct-2007  garbled branches: 1.25.12; 1.25.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.24 17-May-2007  yamt branches: 1.24.10;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.23 12-Jul-2006  ross branches: 1.23.10; 1.23.14; 1.23.16; 1.23.22;
wrap as(1)-only elements in #ifdef _LOCORE
 1.22 07-Jul-2006  ross Add stmd and lmd macros.
 1.21 06-Jul-2006  ross more refinements for ppc64 PIC/PLT/TOC issues
 1.20 01-Jul-2006  ross Add ppc64 ENTRY() macro that defines the descriptor and the dot symbol.
 1.19 20-Jan-2006  christos branches: 1.19.2; 1.19.6; 1.19.14;
Add a STRONG_ALIAS macro
 1.18 11-Dec-2005  christos branches: 1.18.2;
merge ktrace-lwp.
 1.17 23-Jan-2005  simonb branches: 1.17.8;
Use lis@h/ori@l instead of lis@ha/addi@l since we may use r0 and addi
is one of those funny instructions that treats r0 == 0 when used as the
first arg.

Fixes problems on ibm4xx. Ok'd by matt@.
 1.16 19-Jan-2005  matt Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.15 08-Aug-2003  matt branches: 1.15.8;
Nuke ci_spillstk/CI_SPILLSTK. No longer needed.
 1.14 02-Aug-2003  matt Nuke stmreg/ldmreg. PPC64 doesn't have a lmd/stmd so make sure lmw/stmw
don't invoke valid instructions on PPC64.
 1.13 31-Jul-2003  matt Define SZREG {4,8} appropriately. Add pseudo-instructions (via #define)
to load/store int, long, pointer, register, multiple registers. This is so
assembly files can be support IPL32 and LP64 PowerPC implementations.
 1.12 02-Feb-2003  matt branches: 1.12.2;
Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.11 18-Jan-2003  matt Add a temporary bridge to use %foo regnames in kernel / standalone code.
 1.10 30-Jul-2002  matt Don't define register references if not KERNEL or STANDALONE.
 1.9 23-Jun-2002  thorpej Add ENTRY_NOPROFILE().
 1.8 13-Jun-2001  simonb branches: 1.8.2; 1.8.8; 1.8.16; 1.8.18;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.7 23-Jun-2000  kleink branches: 1.7.2;
Add a WEAK_ALIAS() macro.
 1.6 05-Mar-1999  tsubai branches: 1.6.8; 1.6.18;
First-cut of profiling support.
XXX userland only, for now.
 1.5 02-Dec-1998  thorpej Implement WARN_REFERENCES().
 1.4 24-Nov-1998  tsubai Add PIC definitions.
 1.3 16-Apr-1997  thorpej Update for Elf.
 1.2 30-Nov-1996  jtc PROF -> GPROF
 1.1 30-Sep-1996  ws PowerPC port
 1.6.18.1 25-Jul-2000  kleink Pull up rev. 1.7 (approved by thorpej):
For ELF, add a WEAK_ALIAS() macro.
 1.6.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.18.1 23-Jul-2004  tron Pull up revision 1.10 (requested by skrll in ticket #1725):
Don't define register references if not KERNEL or STANDALONE.
 1.8.16.2 31-Aug-2002  gehenna catch up with -current.
 1.8.16.1 16-Jul-2002  gehenna catch up with -current.
 1.8.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.8.8.1 13-Jun-2001  nathanw file asm.h was added on branch nathanw_sa on 2002-08-01 02:43:02 +0000
 1.8.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.2.4 24-Jan-2005  skrll Sync with HEAD.
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.17.8.4 27-Feb-2008  yamt sync with head.
 1.17.8.3 03-Sep-2007  yamt sync with head.
 1.17.8.2 30-Dec-2006  yamt sync with head.
 1.17.8.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 01-Feb-2006  yamt sync with head.
 1.19.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.19.6.1 11-Aug-2006  yamt sync with head
 1.19.2.1 09-Sep-2006  rpaulo sync with head
 1.23.22.2 02-Aug-2007  macallan sync with HEAD
 1.23.22.1 22-May-2007  matt Update to HEAD.
 1.23.16.1 11-Jul-2007  mjf Sync with head.
 1.23.14.1 27-May-2007  ad Sync with head.
 1.23.10.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.24.10.2 23-Mar-2008  matt sync with HEAD
 1.24.10.1 06-Nov-2007  matt sync with HEAD
 1.25.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.12.1 24-Mar-2008  keiichi sync with head.
 1.26.26.3 26-Jan-2011  matt Init CI_CURPCB too.
 1.26.26.2 11-Jan-2011  matt Add a END(y) for function sizes.
 1.26.26.1 07-Jan-2011  matt Allow implementation to not have an interrupt stack (booke).
Use .ident for RCSID
 1.26.4.1 11-Mar-2010  yamt sync with head
 1.28.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.29.2.2 12-Jun-2011  rmind sync with head
 1.29.2.1 05-Mar-2011  rmind sync with head
 1.32.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.36.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.12.3 03-Dec-2017  jdolecek update from HEAD
 1.39.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.12.1 25-Feb-2013  tls resync with head
 1.39.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.39.2.1 16-Jan-2013  yamt sync with (a bit old) head
 1.41.2.1 18-May-2014  rmind sync with head
 1.46.4.1 04-Feb-2015  martin Pull up following revision(s) (requested by chs in ticket #492):
lib/libc/arch/powerpc64/sys/__vfork14.S: revision 1.2
lib/libc/arch/powerpc64/sys/__syscall.S: revision 1.2
lib/libc/arch/powerpc/sys/__syscall.S: revision 1.3
lib/libc/arch/powerpc64/sys/syscall.S: revision 1.2
lib/libc/arch/powerpc/sys/__clone.S: revision 1.6
lib/libc/arch/powerpc64/gen/__setjmp14.S: revision 1.3
sys/arch/powerpc/include/asm.h: revision 1.47
lib/libc/arch/powerpc64/sys/cerror.S: revision 1.6
lib/libc/arch/powerpc64/sys/getcontext.S: revision 1.5
lib/libc/arch/powerpc64/sys/brk.S: revision 1.5
lib/libc/arch/powerpc64/sys/ptrace.S: revision 1.3
lib/libc/arch/powerpc64/genassym.cf: revision 1.1
lib/libc/arch/powerpc64/gen/__sigsetjmp14.S: revision 1.3
lib/libc/arch/powerpc/sys/getcontext.S: revision 1.6
compat/powerpc64/powerpc/bsd.powerpc.mk: revision 1.3
lib/libc/arch/powerpc64/sys/pipe.S: revision 1.2
lib/libc/arch/powerpc/sys/brk.S: revision 1.14
lib/libc/arch/powerpc64/SYS.h: revision 1.3
lib/libc/arch/powerpc64/sys/fork.S: revision 1.2
lib/libc/arch/powerpc64/sys/__sigtramp2.S: revision 1.4
lib/libc/arch/powerpc64/Makefile.inc: revision 1.3
lib/libc/arch/powerpc/sys/pipe.S: revision 1.9
lib/libc/compiler_rt/Makefile.inc: revision 1.25
lib/libc/arch/powerpc64/sys/sbrk.S: revision 1.4, 1.5
lib/libc/arch/powerpc64/sys/__clone.S: revision 1.2
lib/libc/arch/powerpc/sys/sbrk.S: revision 1.13
lib/libc/arch/powerpc/SYS.h: revision 1.13
powerpc64 uses the same sources as powerpc and needs the long double as
double-double sources.
-
Spell LdAddr consistently
-
Add LDFLAGS+=-Wl,-m,elf32ppc_nbsd
-
Fix cmpptr/cmpreq/etc to use right mnemonics
-
Minimize differences between powerpc and powerpc64
-
Fix powerpc64 assembly to use right instructions for 64bit CPUs.
-
Use hidden for __curbrk and __minbrk to avoid GOT/TOC relocations.
 1.47.2.1 06-Apr-2015  skrll Sync with HEAD
 1.48.22.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.48.18.2 21-Apr-2020  martin Sync with HEAD
 1.48.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.49.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.54.2.1 02-Aug-2025  perseant Sync with HEAD
 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 28-Dec-2005  perry branches: 1.4.100; 1.4.106; 1.4.110;
inline -> __inline
 1.3 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 25-Nov-2002  thorpej branches: 1.2.22;
No newlines in string constants.
 1.1 28-Jul-2002  chs branches: 1.1.2; 1.1.4; 1.1.6;
add some atomic operations.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 28-Jul-2002  jdolecek file atomic.h was added on branch kqueue on 2002-09-06 08:39:13 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 28-Jul-2002  gehenna file atomic.h was added on branch gehenna-devsw on 2002-08-31 13:45:46 +0000
 1.1.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 28-Jul-2002  nathanw file atomic.h was added on branch nathanw_sa on 2002-08-01 02:43:02 +0000
 1.2.22.1 21-Jun-2006  yamt sync with head.
 1.4.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.100.1 12-Jun-2011  rmind sync with head
 1.6 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.5 03-Feb-2003  matt branches: 1.5.18; 1.5.80; 1.5.86;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.4 12-Jun-2001  tsubai branches: 1.4.8;
Include powerpc/mpc6xx/{bat.h,pte.h} if PPC_MPC6XX is defined.
 1.3 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.2 18-Dec-1999  thorpej branches: 1.2.6;
- Comment the BAT bits.
- Add defintions for the PowerPC 601 BATs.
- Change the BATU()/BATL() macros to be a bit more flexible; allow size,
permissions, etc. to be specified.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.34;
PowerPC port
 1.1.34.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.2 12-Jun-2001  tsubai Include powerpc/mpc6xx/{bat.h,pte.h} if PPC_MPC6XX is defined.
 1.4.8.1 12-Jun-2001  tsubai file bat.h was added on branch nathanw_sa on 2001-06-12 17:20:51 +0000
 1.5.86.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.80.1 23-Mar-2008  matt sync with HEAD
 1.5.18.1 11-Feb-2008  yamt sync with head.
 1.6 31-Jan-2006  dsl This file only needs to #include sys/bswap.h
 1.5 11-Dec-2005  christos branches: 1.5.2;
merge ktrace-lwp.
 1.4 20-Oct-2003  matt branches: 1.4.16;
Reorganize the way powerpc port install machine specific headers.
Use <powerpc/oea/bat.h> exclusively and remove <machine/bat.h> and
<powerpc/bat.h>. Remove unneeded <machine/cpufunc.h>. To insure
1:1 correspondence of <powerpc/FOO.h> to <machine/FOO.h> include
"../../powerpc/include/Makefile" in "arch/FOO/include/Makefile".
Incororpate <byte_swap.h> into <bswap.h> and then byte_swap.h
 1.3 30-May-2001  tsubai branches: 1.3.8; 1.3.24;
Inline bswap{16,32} when the argument is constant.
 1.2 21-Aug-1999  simonb branches: 1.2.14;
Include <sys/bswap.h> for function prototypes. i386, pc532 and vax
still include <machine/byte_swap.h> and define macros for some of
the bswap*() functions.
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2.14.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.24.1 03-Aug-2004  skrll Sync with HEAD
 1.3.8.2 30-May-2001  tsubai Inline bswap{16,32} when the argument is constant.
 1.3.8.1 30-May-2001  tsubai file bswap.h was added on branch nathanw_sa on 2001-05-30 13:08:35 +0000
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.5.2.1 01-Feb-2006  yamt sync with head.
 1.22 17-Jul-2011  dyoung Enable new-style <sys/bus.h> on several PowerPC ports supporting PCI
buses. Make non-inline implementations of bus_space(9) and bus_dma(9)
routines and move them to appropriate .c files.

This may leave amigappc in a bad state, sorry. Fortunately, it will be
easy to repair by imitating the bus.h -> bus_{defs,funcs}.h split in
some other PowerPC port.
 1.21 09-Jun-2011  matt For PPC_BOOKE, make BUS_DMA_COHERENT equal to BUS_DMA_NOCACHE. Now USB
works again. (which means USB uses of bus_dmamap_sync is broken).
 1.20 28-Apr-2008  martin branches: 1.20.20; 1.20.22; 1.20.26; 1.20.32;
Remove clause 3 and 4 from TNF licenses
 1.19 03-Feb-2008  matt branches: 1.19.6; 1.19.8; 1.19.10;
Use uintN_t in comments (since that's what are really using) instead of
u_intN_t
 1.18 17-Oct-2007  garbled branches: 1.18.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.17 04-Mar-2007  christos branches: 1.17.2; 1.17.10; 1.17.18; 1.17.20; 1.17.22; 1.17.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 21-Feb-2007  mrg add a pair of new bus_dma(9) functions:
int _bus_dmatag_subregion(bus_dma_tag_t tag,
bus_addr_t min_addr,
bus_addr_t max_addr,
bus_dma_tag_t *newtag,
int flags)
void _bus_dmatag_destroy(bus_dma_tag_t tag)

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

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

XXX: bus_dma(9) needs an update still.
 1.15 11-Dec-2005  christos branches: 1.15.26;
merge ktrace-lwp.
 1.14 09-Mar-2005  matt branches: 1.14.4;
Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API
to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create). dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
 1.13 03-Sep-2003  simonb branches: 1.13.8; 1.13.10;
Need to set BUS_DMA_COHERENT to BUS_DMA_NOCACHE on IBM ppc4xx CPUs.

The "emac" interface now works properly again on my Walnut. Much
thanks to Steve Woodford for tracking this down.
 1.12 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.11 15-Jun-2003  fvdl branches: 1.11.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.10 12-Jun-2003  scw Oops, delete an accidentally committed local change.
 1.9 12-Jun-2003  scw Allow <machine/bus.h> to override the definition of BUS_DMA_COHERENT.
For example, machine-dependent code can make it equivalent to
BUS_DMA_NOCACHE if the hardware cannot reliably snoop the bus.
 1.8 18-Mar-2003  matt Switch/adapt to new bus space infrastructure.
 1.7 06-Mar-2003  matt Adapt to powerpc/bus.h changes.
 1.6 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.5 28-Jan-2003  kent Introduce BUS_DMA_NOCACHE, and bus_dmamem_map() of i386 supports it.
 1.4 31-May-2002  augustss Add bus_space_vaddr().
 1.3 10-Dec-2001  briggs branches: 1.3.8;
Provide basic bus_space_mmap(). Noted by self and in PR port-powerpc/14873.
This at least allows the compile to complete. There are still Issues with
vga_pci.c's assumptions about a PC-ish environment.
 1.2 19-Jul-2001  thorpej branches: 1.2.6;
Add BUS_DMA_READ and BUS_DMA_WRITE flags, that hint the back-end
at dmamap load time that the mapping will be used for a unidirectional
transfer of the specified direction.
 1.1 06-Jun-2001  matt branches: 1.1.2; 1.1.4;
Include a common bus.h and bus_dma.c that powerpc ports can use
if they so choose.
 1.1.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 03-Aug-2001  lukem update to -current
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.6.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.2.6.1 19-Jul-2001  nathanw file bus.h was added on branch nathanw_sa on 2002-01-08 00:27:09 +0000
 1.3.8.1 15-Jul-2002  gehenna catch up with -current.
 1.11.2.4 01-Apr-2005  skrll Sync with HEAD.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.8.1 29-Apr-2005  kent sync with -current
 1.14.4.4 04-Feb-2008  yamt sync with head.
 1.14.4.3 27-Oct-2007  yamt sync with head.
 1.14.4.2 03-Sep-2007  yamt sync with head.
 1.14.4.1 26-Feb-2007  yamt sync with head.
 1.15.26.2 12-Mar-2007  rmind Sync with HEAD.
 1.15.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.17.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.17.22.1 18-Oct-2007  yamt sync with head.
 1.17.20.2 23-Mar-2008  matt sync with HEAD
 1.17.20.1 06-Nov-2007  matt sync with HEAD
 1.17.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.10.1 05-Jun-2007  matt Allow a private bus_space but common bus_dma. For now.
 1.17.2.1 23-Oct-2007  ad Sync with head.
 1.18.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.19.10.1 16-May-2008  yamt sync with head.
 1.19.8.1 18-May-2008  yamt sync with head.
 1.19.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.20.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.20.26.1 26-Jul-2011  matt Force COHERENT bus dma mappings to be NOCACHE.
 1.20.22.1 12-Jun-2011  rmind sync with head
 1.20.20.1 11-Aug-2010  uebayasi Support bus_space_physload(9) and friends.
 1.5 10-Mar-2022  riastradh powerpc: Implement bus_space_barrier as eieio.
 1.4 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.3 23-Sep-2019  skrll Provide PRIxBUSADDR, PRIxBUSSIZE, PRIuBUSSIZE, and PRIxBSH for all arches
to follow arm and (generic) mips.

Reviewed by christos.
 1.2 28-Feb-2014  matt branches: 1.2.30;
Use uintptr_t for bus_size_t, bus_addr_t, bus_space_handler_t since uint32_t
doesn't really work too 64-bit platforms.
 1.1 01-Jul-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16;
Per discussion at
<http://mail-index.netbsd.org/tech-kern/2010/04/02/msg007941.html>,
divide each machine's bus.h into bus_defs.h (constants & data types)
and bus_funcs.h (macro implementations of bus_space(9) routines and MD
prototypes).

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

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

These #include files are not referenced by any (committed) Makefiles or
header files, yet. Changes to Makefiles, to <sys/bus.h>, and to some
more machine-dependent files will dribble in before I throw the switch.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 10-Mar-2022  riastradh powerpc: Implement bus_space_barrier as eieio.
 1.1 01-Jul-2011  dyoung Per discussion at
<http://mail-index.netbsd.org/tech-kern/2010/04/02/msg007941.html>,
divide each machine's bus.h into bus_defs.h (constants & data types)
and bus_funcs.h (macro implementations of bus_space(9) routines and MD
prototypes).

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

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

These #include files are not referenced by any (committed) Makefiles or
header files, yet. Changes to Makefiles, to <sys/bus.h>, and to some
more machine-dependent files will dribble in before I throw the switch.
 1.2 20-Oct-2003  matt Reorganize the way powerpc port install machine specific headers.
Use <powerpc/oea/bat.h> exclusively and remove <machine/bat.h> and
<powerpc/bat.h>. Remove unneeded <machine/cpufunc.h>. To insure
1:1 correspondence of <powerpc/FOO.h> to <machine/FOO.h> include
"../../powerpc/include/Makefile" in "arch/FOO/include/Makefile".
Incororpate <byte_swap.h> into <bswap.h> and then byte_swap.h
 1.1 30-May-2001  tsubai branches: 1.1.2; 1.1.10; 1.1.26;
Inline bswap{16,32} when the argument is constant.
 1.1.26.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 30-May-2001  tsubai Inline bswap{16,32} when the argument is constant.
 1.1.10.1 30-May-2001  tsubai file byte_swap.h was added on branch nathanw_sa on 2001-05-30 13:08:35 +0000
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10 28-Feb-2014  matt Add ALIGNBYTES32 for COMPAT_NETBSD32
 1.9 21-Feb-2012  matt branches: 1.9.2; 1.9.4;
Restore back to double alignment.
 1.8 21-Feb-2012  matt Change ALIGNBYTES to be AltiVec savvy
 1.7 20-Jan-2012  joerg Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.6 03-Nov-2002  matt branches: 1.6.146; 1.6.150;
Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.5 20-Mar-1999  thorpej branches: 1.5.26;
Garbage-collect.
 1.4 04-Nov-1997  thorpej Bug fixes and cleanup from Chris Demetriou <cgd@pa.dec.com>:
- fix _C_LABEL so that it actually works.
- make __RENAME use _C_LABEL.
- fix __RENAME so that it expects an unquoted argument.
- fix __indr_reference and __warn_references so that they
supply their own final semicolon.
- define __warn_references to nothing if not GNU C (required
by the way it's used).

The __warn_references semicolon change has to be made
so that __warn_references can be defined into nothing.
(A ; all by itself isn't a great idea.) The __indr_reference
change was made for consistency.
 1.3 22-Oct-1997  thorpej Implement __RENAME() in <machine/cdefs.h>
 1.2 16-Apr-1997  thorpej branches: 1.2.8;
Update for Elf.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.8.2 04-Nov-1997  thorpej Pull up from trunk: bug fixes and cleaups.
 1.2.8.1 22-Oct-1997  thorpej Pull up from trunk: Implement __RENAME() in <machine/cdefs.h>
 1.5.26.1 11-Nov-2002  nathanw Catch up to -current
 1.6.150.1 18-Feb-2012  mrg merge to -current.
 1.6.146.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.146.1 17-Apr-2012  yamt sync with head
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.125 20-Sep-2025  mrg add a "struct trapframe;" forward decl before a prototype that wants
a pointer to it. GCC 14 didn't like this.
 1.124 26-Jul-2023  skrll Trailing whitespace
 1.123 15-Nov-2022  macallan remove workaround for old clang - it's not needed anymore and caused problems
elsewhere
 1.122 30-May-2022  rin Export CPU capability of unaligned memory access to userland
as machdep.no_unaligned sysctl(7) variable.

This will be used for ld.so.conf in order to provide strictly-
aligned versions of libc routines.
 1.121 30-May-2022  rin Introduce PPC_NO_UNALIGNED flag to indicate that CPU cannot handle
unaligned memory access, and emulation should be provided to userland.
 1.120 02-Nov-2021  ryo In order to prevent _mcount() from being recursively called when built with COPTS=-O0,
sprinkle `__always_inline' to make _mcount() be generated as a single function.
 1.119 14-Aug-2021  ryo Improved the performance of kernel profiling on MULTIPROCESSOR, and possible to get profiling data for each CPU.

In the current implementation, locks are acquired at the entrance of the mcount
internal function, so the higher the number of cores, the more lock conflict
occurs, making profiling performance in a MULTIPROCESSOR environment unusable
and slow. Profiling buffers has been changed to be reserved for each CPU,
improving profiling performance in MP by several to several dozen times.

- Eliminated cpu_simple_lock in mcount internal function, using per-CPU buffers.
- Add ci_gmon member to struct cpu_info of each MP arch.
- Add kern.profiling.percpu node in sysctl tree.
- Add new -c <cpuid> option to kgmon(8) to specify the cpuid, like openbsd.
For compatibility, if the -c option is not specified, the entire system can be
operated as before, and the -p option will get the total profiling data for
all CPUs.
 1.118 07-Mar-2021  rin For LP64, remove members of struct cpu_info that exist just for
compatible with booke or ibm4xx. Even if MODULAR || _MODULE,
these members are useless for powerpc64.
 1.117 24-Feb-2021  thorpej Add a provision for a per-cpu battable. Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.
 1.116 03-Feb-2021  rin Pull out constant definitions inside struct declaration.

Enable CTASSERT(9) for CPUSAVE_SIZE.
 1.115 15-Jul-2020  rin branches: 1.115.2;
Factor out emulation code for m[ft]msr in user mode from oea, and
adjust it for systems without FPU.

Now, it can be used from booke and ibm4xx in order to support fenv(3).
 1.114 07-Jul-2020  rin Part of PR port-powerpc/55425
openssl fails on FPU emulation for powerpc

Provide machdep.fpu_present sysctl variable like other ports.

Userland can get informed that FPU is absent and emulated in software
(and calculation results may not be correct in bit-to-bit precision).

This variable should be useful even if we could fix FPU emulation;
it is much faster to skip FPU arithmetic in general, rather than
relying upon emulation by kernel via illegal instruction handler.
 1.113 06-Jul-2020  rin Use (CI_SAVEMAX*CPUSAVE_LEN) as CPUSAVE_SIZE for MODULAR || _MODULE,
since it exceeds 128 (256 for now).

XXX
We should use CTASSERT here, but it conflicts with genassym...
 1.112 06-Jul-2020  rin Drop unused opt_lockdebug.h.
 1.111 27-Jun-2020  macallan apply __HIDE_DELAY so zfs and friends at least compile
 1.110 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.109 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.108 22-Aug-2018  msaitoh - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.107 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.106 25-May-2018  macallan branches: 1.106.2;
copy HID1 from the boot CPU to secondary CPUs as well on 64bit CPUs
now the 2nd CPU on my G5s runs at full speed
 1.105 04-May-2018  macallan save & restore HID4 and HID5, zero SPR_HIOR on 970
 1.104 22-Mar-2018  macallan first step towards G5 SMP:
- only save/restore BATs on CPUs that have them
- treat HID0 as 64bit on 64bit CPUs
 1.103 17-Dec-2017  chs branches: 1.103.2;
apply the same change for powerpc as mrg did for arm and mips:

CPU_INFO_FOREACH() must always iterate at least the boot cpu.
document this in sys/cpu.h and fix the arm and mips versions
to check ncpu is non zero before using it as an iterator max.

this should fix the new assert in init_main.c.
 1.102 19-Oct-2016  nonaka branches: 1.102.8;
Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.101 23-Jan-2015  nonaka branches: 1.101.2;
ddb MP support
 1.100 24-Mar-2014  christos branches: 1.100.6;
use cpu_{g,s}etmodel
 1.99 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.98 08-Nov-2013  nisimura resort the sys/cpu.h way for unused cii iterator in !MULTIPROCESSOR case.
 1.97 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.96 25-Apr-2013  macallan branches: 1.96.4; 1.96.6;
we can read the timebase register as a 64bit chunk when _ARCH_PPC64 is defined,
not necessarily LP64
 1.95 27-Nov-2012  matt 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.94 20-Oct-2012  kiyohara Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.93 28-Jul-2012  matt branches: 1.93.2;
Fix -fno-common fallout.
 1.92 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.91 10-Apr-2012  matt Don't use global asm for __clang__
 1.90 16-Mar-2012  matt Add CPU_EXECPROT sysctl so that atf can enable exec permission tests for
PPC Booke.
 1.89 13-Dec-2011  kiyohara branches: 1.89.2;
Remove white-spaces.
 1.88 30-Jun-2011  matt branches: 1.88.2; 1.88.6;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.87 29-Jun-2011  matt Cleanup hatch names.
Add cpuset_info.
 1.86 21-Jun-2011  matt Add a common cpu_ast(l, ci) routine.
Add a ci_pmap_asid_cur for BOOKE debugging.
 1.85 21-Jun-2011  matt Reap the ci_ev_soft* evcnts since every variant implements __HAVE_FAST_SOFTINTS
 1.84 20-Jun-2011  matt Make struct cpu_info the same size if building MODULAR
kernels or compiling a module.
 1.83 20-Jun-2011  matt Make more module friendly (part 1).
Don't export frame.h and psl.h to all of the kernel.
add lwp_pc and clkf accessor functions.
whitespace cleanup.
 1.82 17-Jun-2011  matt struct device * -> device_t
 1.81 15-Jun-2011  matt Move booke_fixup_stubs() to fixup.c and rename it to cpu_fixup_stubs().
This makes it easier for other PPC variants to use it.
 1.80 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.79 13-Jun-2011  matt Add __HAVE_CPU_UAREA_ROUTINES support so that uareas will be direct-mapped.
(This avoids the nasty tlb recursion problem on ibm4xx as well on mpc85xx).
 1.78 12-Jun-2011  matt Use mfsprg0 instead of mfsprg r,0
 1.77 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.76 04-May-2011  macallan branches: 1.76.2;
add access functions for the Instruction Cache Throttling Control register
found in 750 and newer CPUs
 1.75 16-Feb-2011  matt Fix CLKF_INTR
Add debug evcnt.
 1.74 18-Jan-2011  matt branches: 1.74.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.73 21-Dec-2010  phx branches: 1.73.2;
All ports have to expose 'struct cpu_info' when _KMEMUSER is defined.
We will just expose cpu_info.ci_data for the moment, which is needed for
vmstat(1) to compile. Doing so with the whole cpu_info structure is
problematic, because of imask_t.
 1.72 13-Nov-2010  uebayasi Include sys/device_if.h instead of sys/device.h. machine/cpu.h is
one of the lower-most definitions. Relying on the huge sys/device.h
is not a good idea.
 1.71 20-Oct-2010  phx Support sysctl machdep.cpu_speed for 7447A and 7448 based Macs. On those
machines the CPU's DFS (Dynamic Frequency Switching) feature is used instead
of a GPIO to control the speed.
Two new functions in powerpc/oea/cpu_subr.c were introduced to support
reading and writing of DFS: cpu_get_dfs() and cpu_set_dfs(). Also works
for multiple CPUs, but not before interrupts are enabled.
 1.70 24-Apr-2010  kiyohara Support 64-bit imask for powerpc/pic.
 1.69 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.68 09-Mar-2010  matt branches: 1.68.2;
Add BookE modifications to cpu_info
 1.67 24-Oct-2009  rmind branches: 1.67.2;
Provide cpu_lwp_free* stubs in vax and powerpc.
Reported by <he>.
 1.66 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.65 30-Apr-2008  macallan branches: 1.65.22;
add dummy argument to cpu_did_resched() so kern_synch.c is happy again
 1.64 08-Apr-2008  garbled branches: 1.64.2; 1.64.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.63 27-Feb-2008  xtraeme Remove CTL_MACHDEP_NAMES, it's not used anywhere.

Ok by martin@.
 1.62 05-Feb-2008  garbled branches: 1.62.2; 1.62.6;
Replace as much of the hardcoded CACHELINESIZE with
curcpu()->ci_ci.dcache_line_size as I can. With this change, an ofppc kernel
compiled with both PPC_OEA and PPC_OEA64_BRIDGE defined, boots.
 1.61 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.60 03-Dec-2007  ad Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.59 17-Oct-2007  garbled branches: 1.59.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.58 01-Jun-2007  nisimura branches: 1.58.8; 1.58.10; 1.58.12; 1.58.14;
- add booted_device and booted_kernel sysctl nodes to let userland know
about runtime environment.
 1.57 18-May-2007  rjs Fix for yamt-idlelwp merge.
 1.56 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.55 04-Mar-2007  christos branches: 1.55.2; 1.55.4; 1.55.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.54 16-Feb-2007  ad branches: 1.54.2;
Remove spllowersoftclock() and CLKF_BASEPRI(), and always dispatch callouts
via a soft interrupt. In the near future, softclock will be run from process
context.
 1.53 09-Feb-2007  ad Merge newlock2 to head.
 1.52 31-Aug-2006  matt branches: 1.52.2;
Add unmapiodev.
 1.51 05-Aug-2006  sanjayl 1st cut of Powermac G5 support (uses bridge mode).
 1.50 30-Jun-2006  freza Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.49 13-Jun-2006  freza branches: 1.49.2;
Merge multiple definitions of cntlzw() ("count leading zeros")
instruction-wrapper to <powerpc/cpu.h>.

OK by briggs@
 1.48 30-May-2006  freza Remove duplicate definitions of mfdcr()/mtdcr() in favor of a single one
in cpu.h

OK Matt Thomas
 1.47 16-Feb-2006  perry branches: 1.47.2; 1.47.8;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.46 24-Dec-2005  perry branches: 1.46.2; 1.46.4; 1.46.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.45 11-Dec-2005  christos merge ktrace-lwp.
 1.44 03-Feb-2005  briggs branches: 1.44.6;
Keep track of the CPU's current speed (in kHz) in the cpu info structure,
if we can get it. May want to expand this in the future to include min
and max speeds for systems where we can adjust the speed.
 1.43 19-Jan-2005  matt branches: 1.43.2;
Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.42 22-Sep-2004  yamt branches: 1.42.4;
move some per-cpu data definitions to MI place so that they can be modified
without touching all ports. discussed on tech-kern@.
 1.41 06-Jun-2004  kleink Mark cr0 as clobbered in mfrtc().
 1.40 17-Feb-2004  matt Don't waste space on likely unused sysmon structure.
Instead malloc them as needed.
 1.39 04-Jan-2004  jdolecek Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
as FPU state), and is the last potentially blocking operation;
all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
 1.38 21-Nov-2003  matt Restore ci_curpm since it re-enables 603 to working state.
 1.37 03-Sep-2003  matt Move CLKF_BASEPRI to machine specific <intr.h> file since it depends on
the encoding of the spl for the port.
 1.36 18-Aug-2003  matt Not all PPC ports (e.g. macppc) equate IPL_NONE with 0.
 1.35 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.34 08-Aug-2003  matt Nuke ci_spillstk/CI_SPILLSTK. No longer needed.
 1.33 04-Aug-2003  matt Make that OEA based kernels can properly deal with kernel ISI faults. Now
that LKMs are supported, it is possible for a LKM page to be "outspilled"
resulting in a possible ISI fault. Try to spill the page back in.
 1.32 02-Aug-2003  matt Add symbolic offsets for what's in cpu save locations.
Add a PPC64 variant of mftb
 1.31 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.30 13-Mar-2003  matt branches: 1.30.2;
Use __asm & __volatile to make lint(1) happy.
 1.29 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.28 04-Mar-2003  matt Add some missing volatiles.
 1.27 10-Feb-2003  matt Only include kernel headers if _KERNEL is defined.
 1.26 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.25 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.24 22-Jan-2003  kleink Add mfrtcl() and mfrtc(), similar to mftbl() and mftb().
 1.23 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.22 25-Nov-2002  thorpej No newlines in string constants.
 1.21 26-Sep-2002  matt In mftb(), make sure we say we are clobbering cr0.
 1.20 14-Aug-2002  matt Prepare for PPC64. Use register_t for mtmsr/mfmsr since the msr on PPC64
is 64bits wide. Define proper types for PPC64 if _LP64 is defined.
 1.19 06-Aug-2002  chs move more inlines to cpu.h: mftb(), mftbl() and mfpvr().
(the mftb() in pmap.c only wanted the lower 32 bits, so that's now mftbl()).
 1.18 28-Jul-2002  chs define CPU_INFO iterators so that the CPU-states sysctl works for MP.
 1.17 16-Jul-2002  matt Add machdep.powerpc sysctl. Change the default value of powersave to -1
(< 0 mean no powersave available). Enable powersave by default for
750/7400/7410 but leave if off for 7450/7455.
 1.16 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.15 26-Mar-2002  matt branches: 1.15.2;
Use size_t in prototype (so this will be LP64 clean for PPC64 someday).
Calculate len separately for icache & dcache in case each has different
cacheline widths. Make the code for both loops the same except for the
dcbst/icbi. Deal with sizes >=2GB properly (like that'll happen but ...)
 1.14 13-Mar-2002  eeh Add cache_info to cpu_info which provides details about D$ and I$
sizes and line sizes. This is needed for cache flusing, clearing
memory, and several other operations. This information is accessible
from userland through a new CPU_CACHEINFO sysctl.
 1.13 06-Mar-2002  nathanw Move #include <dev/sysmon/sysmonvar.h> inside #ifdef _KERNEL.
 1.12 03-Mar-2002  nathanw Add sysmon data structures to struct cpu_info.
 1.11 05-Dec-2001  chs fix macppc MULTIPROCESSOR compilation.
 1.10 28-Aug-2001  matt branches: 1.10.6;
__syncicache needs to be exports to userspace as well as the kernel.
 1.9 26-Aug-2001  matt Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.8 13-Jun-2001  simonb branches: 1.8.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.7 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.6 05-May-1999  tsubai branches: 1.6.2; 1.6.16;
Add missing CPU_MAXID definition.
 1.5 17-Apr-1999  ws Modify syncicache on PowerPC from an inline to a real function.
Support different cache line sizes with the same object code in userland.
While here, move the function to implementation name space.
 1.4 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.3 05-Nov-1997  thorpej asm -> __asm__, volatile -> __volatile
 1.2 16-Apr-1997  thorpej branches: 1.2.8;
Definitions for machine_vec interface, from Wolfgang Solfrank.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.8.1 05-Nov-1997  thorpej Update from trunk: asm -> __asm__, volatile -> __volatile
 1.6.16.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.8.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.8.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.10.6.13 11-Dec-2002  thorpej Sync with HEAD.
 1.10.6.12 18-Oct-2002  nathanw Catch up to -current.
 1.10.6.11 27-Aug-2002  nathanw Catch up to -current.
 1.10.6.10 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.10.6.9 01-Aug-2002  nathanw LWPify.
 1.10.6.8 01-Aug-2002  nathanw Catch up to -current.
 1.10.6.7 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.10.6.6 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.6.5 08-Jan-2002  nathanw Catch up to -current.
 1.10.6.4 08-Dec-2001  thorpej Add a cpu_proc_fork(), called from uvm_proc_fork(), which takes care
of machine-dependent handling a fork() time (this is different from
forking the actual context in an LWP world). #define it away on
platforms which do not need it.

Problem noted by Gregory McGarry.
 1.10.6.3 15-Nov-2001  briggs PROC_PC -> LWP_PC. (thanks, thorpej)
 1.10.6.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.10.6.1 28-Aug-2001  briggs file cpu.h was added on branch nathanw_sa on 2001-11-05 19:46:16 +0000
 1.15.2.3 31-Aug-2002  gehenna catch up with -current.
 1.15.2.2 21-Jul-2002  gehenna catch up with -current.
 1.15.2.1 16-Jul-2002  gehenna catch up with -current.
 1.30.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.30.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.30.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.30.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.30.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.30.2.1 03-Aug-2004  skrll Sync with HEAD
 1.42.4.1 29-Apr-2005  kent sync with -current
 1.43.2.1 12-Feb-2005  yamt sync with head.
 1.44.6.8 17-Mar-2008  yamt sync with head.
 1.44.6.7 11-Feb-2008  yamt sync with head.
 1.44.6.6 07-Dec-2007  yamt sync with head
 1.44.6.5 27-Oct-2007  yamt sync with head.
 1.44.6.4 03-Sep-2007  yamt sync with head.
 1.44.6.3 26-Feb-2007  yamt sync with head.
 1.44.6.2 30-Dec-2006  yamt sync with head.
 1.44.6.1 21-Jun-2006  yamt sync with head.
 1.46.6.2 01-Jun-2006  kardel Sync with head.
 1.46.6.1 22-Apr-2006  simonb Sync with head.
 1.46.4.1 09-Sep-2006  rpaulo sync with head
 1.46.2.1 18-Feb-2006  yamt sync with head.
 1.47.8.1 19-Jun-2006  chap Sync with head.
 1.47.2.3 03-Sep-2006  yamt sync with head.
 1.47.2.2 11-Aug-2006  yamt sync with head
 1.47.2.1 26-Jun-2006  yamt sync with head.
 1.49.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.52.2.1 28-Jan-2007  ad powerpc changes.
 1.54.2.3 07-Apr-2007  matt Add cpu_did_resched()
 1.54.2.2 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.54.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.55.10.5 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.55.10.4 04-Oct-2007  macallan add event counters for IPIs received on each CPU
 1.55.10.3 02-Aug-2007  macallan sync with HEAD
 1.55.10.2 26-Jun-2007  garbled Sync with HEAD.
 1.55.10.1 22-May-2007  matt Update to HEAD.
 1.55.4.1 11-Jul-2007  mjf Sync with head.
 1.55.2.4 03-Dec-2007  ad Sync with HEAD.
 1.55.2.3 23-Oct-2007  ad Sync with head.
 1.55.2.2 09-Jun-2007  ad Sync with head.
 1.55.2.1 27-May-2007  ad Sync with head.
 1.58.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.58.12.1 18-Oct-2007  yamt sync with head.
 1.58.10.3 23-Mar-2008  matt sync with HEAD
 1.58.10.2 09-Jan-2008  matt sync with HEAD
 1.58.10.1 06-Nov-2007  matt sync with HEAD
 1.58.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.58.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.59.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.59.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.62.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.62.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.62.2.1 24-Mar-2008  keiichi sync with head.
 1.64.4.3 11-Aug-2010  yamt sync with head.
 1.64.4.2 11-Mar-2010  yamt sync with head
 1.64.4.1 16-May-2008  yamt sync with head.
 1.64.2.1 18-May-2008  yamt sync with head.
 1.65.22.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.65.22.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.65.22.1 07-Jan-2011  matt Add booke support.
 1.67.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.67.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.68.2.4 12-Jun-2011  rmind sync with head
 1.68.2.3 31-May-2011  rmind sync with head
 1.68.2.2 05-Mar-2011  rmind sync with head
 1.68.2.1 30-May-2010  rmind sync with head
 1.73.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.74.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.76.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.88.6.3 29-Apr-2012  mrg sync to latest -current.
 1.88.6.2 05-Apr-2012  mrg sync to latest -current.
 1.88.6.1 18-Feb-2012  mrg merge to -current.
 1.88.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.88.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.88.2.2 30-Oct-2012  yamt sync with head
 1.88.2.1 17-Apr-2012  yamt sync with head
 1.89.2.2 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #251):
sys/arch/powerpc/powerpc/powerpc_machdep.c: revision 1.64
sys/arch/powerpc/include/cpu.h: revision 1.90
Add CPU_EXECPROT sysctl so that atf can enable exec permission tests for
PPC Booke.
 1.89.2.1 09-May-2012  riz Pull up following revision(s) (requested by matt in ticket #242):
sys/arch/powerpc/include/cpu.h: revision 1.91
Don't use global asm for __clang__
 1.93.2.5 03-Dec-2017  jdolecek update from HEAD
 1.93.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.93.2.3 23-Jun-2013  tls resync from head
 1.93.2.2 25-Feb-2013  tls resync with head
 1.93.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.96.6.1 23-Jul-2013  riastradh sync with HEAD
 1.96.4.2 18-May-2014  rmind sync with head
 1.96.4.1 28-Aug-2013  rmind sync with head
 1.100.6.2 05-Dec-2016  skrll Sync with HEAD
 1.100.6.1 06-Apr-2015  skrll Sync with HEAD
 1.101.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.102.8.1 26-Feb-2018  snj Pull up following revision(s) (requested by skrll in ticket #566):
sys/arch/arm/include/cpu.h: 1.94
sys/arch/mips/include/cpu.h: 1.122
sys/arch/powerpc/include/cpu.h: 1.103
sys/sys/cpu.h: 1.42
CPU_INFO_FOREACH() must always iterate at least the boot cpu.
document this in sys/cpu.h and fix the arm and mips versions
to check ncpu is non zero before using it as an iterator max.
this should fix the new assert in init_main.c.
--
apply the same change for powerpc as mrg did for arm and mips:
CPU_INFO_FOREACH() must always iterate at least the boot cpu.
document this in sys/cpu.h and fix the arm and mips versions
to check ncpu is non zero before using it as an iterator max.
this should fix the new assert in init_main.c.
 1.103.2.5 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.103.2.4 28-Jul-2018  pgoyette Sync with HEAD
 1.103.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.103.2.2 21-May-2018  pgoyette Sync with HEAD
 1.103.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.106.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.106.2.1 10-Jun-2019  christos Sync with HEAD
 1.115.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.8 18-Jan-2011  matt 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.7 25-Feb-2010  matt branches: 1.7.2; 1.7.4;
Adapt to spr.h breakup.
 1.6 05-Feb-2008  garbled branches: 1.6.10; 1.6.30; 1.6.34;
Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.5 17-Oct-2007  garbled branches: 1.5.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.4 16-Feb-2006  perry branches: 1.4.24; 1.4.32; 1.4.42; 1.4.44; 1.4.46; 1.4.48;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.3 24-Dec-2005  perry branches: 1.3.2; 1.3.4; 1.3.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 11-Mar-2003  hannken branches: 1.2.18;
Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.1 05-Feb-2003  nakayama Replace machine/rnd.h with more appropriate name to share it
with cycle counter based microtime in kern/kern_microtime.c.
 1.2.18.3 11-Feb-2008  yamt sync with head.
 1.2.18.2 27-Oct-2007  yamt sync with head.
 1.2.18.1 21-Jun-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.1 18-Feb-2006  yamt sync with head.
 1.4.48.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.46.1 18-Oct-2007  yamt sync with head.
 1.4.44.2 23-Mar-2008  matt sync with HEAD
 1.4.44.1 06-Nov-2007  matt sync with HEAD
 1.4.42.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.32.1 16-Oct-2007  macallan make cpu_frequency() work at least on a few machines
Needed for stuff like lockstat.
 1.4.24.1 23-Oct-2007  ad Sync with head.
 1.5.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.34.1 07-Jan-2011  matt Add booke support
 1.6.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.10.1 11-Mar-2010  yamt sync with head
 1.7.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.2.1 05-Mar-2011  rmind sync with head
 1.2 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.1 05-Jun-2011  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.20; 1.1.24; 1.1.32;
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.32.1 23-Jul-2013  riastradh sync with HEAD
 1.1.24.1 28-Aug-2013  rmind sync with head
 1.1.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.8.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.8.1 05-Jun-2011  matt file cpuset.h was added on branch matt-nb5-pq3 on 2011-10-14 17:21:26 +0000
 1.1.6.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.6.1 05-Jun-2011  cherry file cpuset.h was added on branch cherry-xenmp on 2011-06-23 14:19:30 +0000
 1.1.4.2 12-Jun-2011  rmind sync with head
 1.1.4.1 05-Jun-2011  rmind file cpuset.h was added on branch rmind-uvmplock on 2011-06-12 00:24:04 +0000
 1.1.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 05-Jun-2011  jruoho file cpuset.h was added on branch jruoho-x86intr on 2011-06-06 09:06:27 +0000
 1.11 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.10 28-Apr-2008  martin branches: 1.10.22; 1.10.28;
Remove clause 3 and 4 from TNF licenses
 1.9 11-Dec-2005  christos branches: 1.9.74; 1.9.76; 1.9.78;
merge ktrace-lwp.
 1.8 25-Jun-2005  christos move ppc commpage stuff here.
 1.7 15-Jul-2004  manu typo
 1.6 04-Jul-2004  manu MacOS X.3 introduces a new sigreturn for PowerPC, with a usercontext
versionning argument. For now we only implement the X.2 flavor.
 1.5 03-Jul-2004  manu In MacOS X.3, the kernel maps tw opages of memory in every user process.
This areas is called the comm pages. It is used to provide fast access to
several data and functions.

The comm pages are mapped starting at 0xffff800 (address chosed so that
absolute branch can be used, so it can be accessed even when dynamic linking
is not ready). NetBSD has the user stack here, so we need to provide a
Darwin-specific stack setup routine which sets the top of the stack at
0xbfff0000.

This implementation is not complete but it does enough to get MacOS X.3
starting again (static binaries run, dynamic binaries still have an issue).
in the comm pages functions, we only implement bcopy, pthread_self and
memcpy.

TODO:
- clean up the powerpc specific code from MD parts
- for now we map only one page to avoid a crash, we want two pages.
- write all the comm functions.
 1.4 11-Nov-2003  manu Implement mach_thread_get_state.
While we are here, try to tag machine dependent functions in header files.
also transformed darwin_ppc_*_state into mach_ppc_*_state, as this is
what they really are (COMPAT_DARWIN is on the top of COMPAT_MACH, not the
other way around)
 1.3 07-Sep-2003  manu forgotten commit for KERN_PROCARGS sysctl in COMPAT_DARWIN
 1.2 08-Dec-2002  manu branches: 1.2.2; 1.2.8;
A working fork/vfork implementation. Darwin fork differs from our fork by
two ways:
- the child gets its pid as retval[0] (userland stub will turn it into a 0),
retval[1] is 1 and it is 0 in the parent.
- in the child, the fork syscall is successful, hence we must skip the next
instruction.
 1.1 26-Nov-2002  manu Add signal delivery for the PowerPC. Everything is implemented except siginfo.
The stack layout is observed from stack dumps on Darwin, so it should be
very accurate.
 1.2.8.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.8.1 03-Aug-2004  skrll Sync with HEAD
 1.2.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.1 08-Dec-2002  thorpej file darwin_machdep.h was added on branch nathanw_sa on 2002-12-11 06:11:41 +0000
 1.9.78.1 16-May-2008  yamt sync with head.
 1.9.76.1 18-May-2008  yamt sync with head.
 1.9.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.22.1 31-May-2011  rmind sync with head
 1.30 11-Mar-2021  simonb Use ifdef _KERNEL_OPT instead of ifdef _KERNEL before including
"opt_ppcarch.h".
 1.29 06-Jan-2021  rin Switch DDB for powerpc/booke into SOFTWARE_SSTEP.

SR_SINGLESTEP aka PSL_SE bit in MSR is only available for oea, and HW
debug facilities for booke are significantly different from oea.
 1.28 06-Jul-2020  rin branches: 1.28.2;
Style and cosmetic changes. No binary changes intended.
 1.27 15-Dec-2019  rin Do not mask out LK bit (bit 31) from M_BCTR, which distinguishes
bcctr and bcctrl.

Fix build failure for ibm4xx kernels with GCC8.

XXX
pullup to netbsd-9, -8, and -7
 1.26 06-Nov-2017  christos branches: 1.26.4; 1.26.8;
Cleanup and clarify the ELFSIZE mess:

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

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

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

In sys/exec_elf.h, if ELFSIZE is not set, it is set to KERN_ELFSIZE
for the kernel and ARCH_ELFSIZE for userland. These defaults should
eliminate the need for most manual ELFSIZE setting.
 1.25 23-Jan-2015  nonaka ddb MP support
 1.24 14-Jun-2011  matt branches: 1.24.12; 1.24.30;
Update KDB_NUMREGS to match what gdb6 is using for PPC.
Patch taken from PR/43196
 1.23 26-May-2011  joerg branches: 1.23.2;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.22 18-Jan-2011  matt 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.21 28-Jan-2010  phx branches: 1.21.4; 1.21.6;
New machine commands for PPC OEA:
bat: prints the BAT registers and translations
mmu: prints MMU registers (sdr1, sr0..15)
 1.20 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.19 14-May-2006  elad branches: 1.19.66; 1.19.74; 1.19.80; 1.19.88;
integrate kauth.
 1.18 01-Apr-2006  cherry closes kern/32359
 1.17 29-Apr-2003  scw branches: 1.17.18; 1.17.32; 1.17.34; 1.17.36; 1.17.38; 1.17.40;
Add a BKPT_ADDR() macro which gives MD code a chance to munge a
breakpoint address before it's used. Currently a no-op on all but sh5.

This is useful on sh5, for example, to mask off the instruction
type encoding in the bottom two address bits, and makes it possible
to do "db> break $rXX" instead of manually munging the address.
 1.16 14-Mar-2003  matt Make lint happy by not assigning to casted lvalue.
 1.15 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.14 20-Dec-2002  scw Use Software Single Stepping for now when PPC_IBM4xx is defined. The
existing hardware assisted method doesn't work on this cpu.

Also correct the "I_B" constant in db_machine.h.
 1.13 13-May-2002  matt Eliminate commons.
 1.12 06-Jan-2002  dbj add support for kgdb over zs
 1.11 27-Dec-2001  dbj fix single stepping and continuing from breakpoints in ddb
 1.10 20-Jun-2001  briggs branches: 1.10.2; 1.10.8;
Build for kgdb as well as for ddb (mutually exclusive).
 1.9 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.8 02-Aug-2000  tsubai branches: 1.8.2;
uvm/uvm_inherit.h was removed.
 1.7 26-Jun-2000  mrg <vm/vm_param.h> -> <uvm/uvm_param.h>
 1.6 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.5 25-Jun-2000  mrg <vm/vm_prot.h> becomes <uvm/uvm_prot.h>
 1.4 31-Aug-1998  tsubai branches: 1.4.12; 1.4.22;
vm_offset_t --> [pv]addr_t
 1.3 31-Aug-1998  tsubai Change db_expr_t from int to long like other ports.
 1.2 23-Feb-1998  mycroft Fix layout of powerpc_saved_state.
 1.1 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.4.22.1 05-Aug-2000  wiz Apply patch (approved by jhawk and thorpej):

Rename VM_INHERIT_* to MAP_INHERIT_* and move them to sys/sys/mman.h as
discussed on tech-kern.
Retire sys/vm/vm_inherit.h, update man page for minherit(2).

The patch includes approximately the following diffs (approximately
since -current already used uvm/uvm_inherit.h):
minherit.2: 1.4 -> 1.8
mman.h: 1.26 -> 1.27
powerpc/include/db_machdep.h: 1.7 -> 1.8
pc532/include/db_machdep.h: 1.12 -> 1.13
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.8.6 29-Dec-2002  thorpej Sync with HEAD.
 1.10.8.5 20-Jun-2002  nathanw Catch up to -current.
 1.10.8.4 28-Feb-2002  nathanw Catch up to -current.
 1.10.8.3 11-Jan-2002  nathanw More catchup.
 1.10.8.2 08-Jan-2002  nathanw Catch up to -current.
 1.10.8.1 20-Jun-2001  nathanw file db_machdep.h was added on branch nathanw_sa on 2002-01-08 00:27:10 +0000
 1.10.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.40.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.17.38.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.17.36.1 11-Apr-2006  yamt sync with head
 1.17.34.1 22-Apr-2006  simonb Sync with head.
 1.17.32.1 09-Sep-2006  rpaulo sync with head
 1.17.18.1 21-Jun-2006  yamt sync with head.
 1.19.88.1 07-Jan-2011  matt Add booke support.
 1.19.80.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.74.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.66.2 11-Mar-2010  yamt sync with head
 1.19.66.1 04-May-2009  yamt sync with head.
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.2 31-May-2011  rmind sync with head
 1.21.4.1 05-Mar-2011  rmind sync with head
 1.23.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.24.30.1 06-Apr-2015  skrll Sync with HEAD
 1.24.12.1 03-Dec-2017  jdolecek update from HEAD
 1.26.8.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #727):

sys/arch/powerpc/include/db_machdep.h: revision 1.27

Do not mask out LK bit (bit 31) from M_BCTR, which distinguishes
bcctr and bcctrl.

Fix build failure for ibm4xx kernels with GCC8.

XXX
pullup to netbsd-9, -8, and -7
 1.26.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.28.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.3 02-Mar-1998  drochner Change MBR partition type for NetBSD to 0xa9, like the i386 port.
Provide compatibility via COMPAT_386BSD_MBRPART.
 1.2 16-Apr-1997  thorpej Don't define two partition types for NetBSD - just use the standard 0xa5.
(Eww, DOS MBR)
 1.1 30-Sep-1996  ws PowerPC port
 1.16 08-Dec-2019  uwe Fix typo in the definition of #ha() in a comment.
 1.15 06-Nov-2017  christos branches: 1.15.4;
handle ppc64
 1.14 06-Nov-2017  christos Cleanup and clarify the ELFSIZE mess:

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

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

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

In sys/exec_elf.h, if ELFSIZE is not set, it is set to KERN_ELFSIZE
for the kernel and ARCH_ELFSIZE for userland. These defaults should
eliminate the need for most manual ELFSIZE setting.
 1.13 10-Aug-2017  joerg Add IRELATIVE support for ARM, X86 and PowerPC.
 1.12 07-Mar-2014  matt branches: 1.12.6;
Don't define ARCH_ELFSIZE if it's already defined.
 1.11 06-Mar-2014  matt Add PowerPC64 DTs
 1.10 06-Mar-2014  matt More comments.
rest of powerpc64 relocs
 1.9 15-Jan-2011  matt branches: 1.9.8; 1.9.18; 1.9.22;
Add some more reloc types as well as DT_PPC_GOT
 1.8 30-May-2009  skrll branches: 1.8.4;
Add TLS relocation definitions.
 1.7 25-Nov-2006  freza branches: 1.7.56;
PR toolchain/35105: Don't include reloc.h, instead provide R_PPC_* defines
and make R_TYPE() use them. This is more consistent with other ports, too.

Suggested by Manuel Bouyer, ok'd by Matt Thomas.
 1.6 08-Jul-2006  ross branches: 1.6.4; 1.6.6;
add new split personality for ELF64
 1.5 09-Dec-2001  thorpej branches: 1.5.32; 1.5.46; 1.5.50; 1.5.58;
Add support for dumping ELF-cormat core files.
 1.4 02-Apr-2000  minoura branches: 1.4.8; 1.4.12;
Move dl* function definitions to libc on ELF.
Based on the patch supplied by Takuya Shiozaki <tshiozak@astec.co.jp>.
See http://mail-index.netbsd.org/tech-userlevel/2000/02/23/0000.html.
 1.3 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.2 24-Nov-1998  tsubai branches: 1.2.10; 1.2.12; 1.2.14;
Add PIC definitions.
 1.1 16-Apr-1997  thorpej Machine-dependent definitions for Elf on NetBSD/powerpc.
 1.2.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.12.1 15-Nov-1999  fvdl Sync with -current
 1.2.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.12.1 08-Jan-2002  nathanw Catch up to -current.
 1.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.58.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.50.1 11-Aug-2006  yamt sync with head
 1.5.46.1 09-Sep-2006  rpaulo sync with head
 1.5.32.1 30-Dec-2006  yamt sync with head.
 1.6.6.1 10-Dec-2006  yamt sync with head.
 1.6.4.1 12-Jan-2007  ad Sync with head.
 1.7.56.1 20-Jun-2009  yamt sync with head
 1.8.4.1 05-Mar-2011  rmind sync with head
 1.9.22.1 18-May-2014  rmind sync with head
 1.9.18.2 03-Dec-2017  jdolecek update from HEAD
 1.9.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.8.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.6.1 28-Aug-2017  skrll Sync with HEAD
 1.15.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.9 17-Mar-2000  mycroft In the `MY THAT'S GROSS' department...
Eliminate the recursive include of machine/endian.h from sys/endian.h.
 1.8 16-Mar-2000  mycroft Foolish consistency. Mainly, always use underscores and sys/endian.h.
 1.7 21-Aug-1999  simonb branches: 1.7.2;
Include <sys/endian.h> after defining whether where are little- or
big-endian. i386, pc532 and vax still include <machine/byte_swap.h>
and define macros for the {n,h}to{h,n}*() functions. mips also
defines some endian-independent assembly-code aliases for unaligned
memory accesses.
 1.6 24-Jan-1999  mycroft Mark [hn]to[nh][ls]() with __const__, so they are subject to CSE.
 1.5 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.4 31-Jul-1998  mycroft (Always) (practice) (safe) (macro expansion).
 1.3 09-Oct-1997  bouyer branches: 1.3.4;
Add byte-swapping functions (bswap16, bswap32, bswap64) to libkern.
Only assembly version for i386 bswap16 and bswap32 for now (bswap64 uses
bswap32). Contribution of assembly versions of these are welcome.
Add byte-swapping of ext2fs metadata for big-endian systems.
Tested on i386 and sparc.
 1.2 13-Oct-1996  christos branches: 1.2.10;
use in_addr_t and in_port_t
 1.1 30-Sep-1996  ws PowerPC port
 1.2.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1 17-Mar-2000  mycroft branches: 1.1.6;
In the `MY THAT'S GROSS' department...
Eliminate the recursive include of machine/endian.h from sys/endian.h.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 17-Mar-2000  bouyer file endian_machdep.h was added on branch thorpej_scsipi on 2000-11-20 20:31:08 +0000
 1.2 08-Oct-1996  cgd moved to aout_machdep.h (via repository copy)
 1.1 30-Sep-1996  ws PowerPC port
 1.8 30-Oct-2024  riastradh Sprinkle <sys/featuretest.h> where _*_SOURCE macros are consulted.

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

PR lib/58752: various header files test _*_SOURCE macros but don't
include sys/featuretest.h
 1.7 13-Sep-2022  rin branches: 1.7.10;
fesetexceptflag(): Set FE_ALL_INVALID instead of FE_ALL_EXCEPT for
FE_INVALID. Taken from FreeBSD:

https://cgit.freebsd.org/src/commit/lib/msun/powerpc/fenv.h?id=e7bd4f846f0c9185aebfd3d116bb78ab137280fa

> [POWERPC] msun: fix incorrect flag in fesetexceptflag
> Fix incorrect mask being used when FE_INVALID bit is wanted by user.
> The problem was noticed thanks to msun fenv tests.
>
> Reviewed by: jhibbits, luporl
> Sponsored by: Eldorado Research Institute (eldorado.org.br)
> Differential Revision: https://reviews.freebsd.org/D27201

No regression for full ATF on both real and emulated FPU.

XXX
Import some tests from FreeBSD's lib/msun/tests.
 1.6 30-Oct-2019  christos do the ignore builtin dance for gcc-8
 1.5 19-Apr-2018  christos branches: 1.5.2;
s/static inline/static __inline/g for consistency.
 1.4 18-Sep-2017  phx branches: 1.4.2; 1.4.4;
Fixed feholdexcept() by copying the actual contents of FPSCR to the fenv_t
instead of a double precision floating point representation of it.
 1.3 22-Mar-2017  chs branches: 1.3.6;
provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().
 1.2 27-Feb-2017  chs update the FE0/FE1 MSR bits as needed when changing the exception mask.
 1.1 20-Dec-2015  christos branches: 1.1.2; 1.1.4; 1.1.6;
Add fenv.h for powerpc (from FreeBSD)
 1.1.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.4.2 26-Apr-2017  pgoyette Sync with HEAD
 1.1.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.1 20-Dec-2015  skrll file fenv.h was added on branch nick-nhusb on 2015-12-27 12:09:40 +0000
 1.3.6.1 23-Sep-2017  snj Pull up following revision(s) (requested by phx in ticket #291):
sys/arch/powerpc/include/fenv.h: revision 1.4
Fixed feholdexcept() by copying the actual contents of FPSCR to the fenv_t
instead of a double precision floating point representation of it.
 1.4.4.1 22-Apr-2018  pgoyette Sync with HEAD
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 18-Sep-2017  jdolecek file fenv.h was added on branch tls-maxphys on 2017-12-03 11:36:37 +0000
 1.5.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 12-May-2003  kleink Rename <sys/float_ieee.h> to <sys/float_ieee754.h>, following libc's
convention for these.
 1.5 19-Apr-2003  christos PR/3012: Greg A. Woods: Write all float.h files [except the vax of course]
in terms of float_ieee.h
 1.4 13-Jun-2001  simonb branches: 1.4.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.3 18-Feb-1998  mycroft branches: 1.3.26;
Minor changes to make all the float.h files match.
 1.2 03-Feb-1998  mycroft Prototype __flt_rounds() consistently.
 1.1 30-Sep-1996  ws branches: 1.1.14;
PowerPC port
 1.1.14.1 08-May-1998  mycroft Sync with trunk, per request of mycroft.
 1.3.26.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.4.8.1 13-Jun-2001  simonb file float.h was added on branch nathanw_sa on 2001-06-13 06:01:49 +0000
 1.25 15-Jul-2020  rin Expose fpu_get_fault_code() even if !PPC_HAVE_FPU, and
adjust it to systems without FPU.
 1.24 06-Jul-2020  rin Drop unused opt_multiprocessor.h includes.
 1.23 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.22 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.21 16-Mar-2017  chs branches: 1.21.12;
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.20 22-Aug-2013  drochner branches: 1.20.6; 1.20.10; 1.20.14;
-extend the pcu(9) API by a function which saves all context on the
current CPU, and use it if a CPU is taken offline
-add a bool argument to pcu_discard which tells whether the internal
"LWP has used the coprocessor" flag should be set or reset. The flag
is reported by pcu_used_p(). If set, future accesses should use the
state stored in the PCB. If reset, it should be reset to default.
The former case is useful for setmcontext().
With that, it should not be necessary anymore to manage the "FPU used"
state by an additional MD variable.

approved by matt
 1.19 19-May-2011  kiyohara branches: 1.19.4; 1.19.14; 1.19.18;
Remove unnecessary Tab.
 1.18 02-May-2011  matt Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.17 18-Jan-2011  matt 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.16 17-Oct-2007  garbled branches: 1.16.42; 1.16.46; 1.16.48;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.15 05-Aug-2006  sanjayl branches: 1.15.14; 1.15.22; 1.15.32; 1.15.34; 1.15.36; 1.15.38;
1st cut of Powermac G5 support (uses bridge mode).
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.8;
merge ktrace-lwp.
 1.13 16-Apr-2004  matt branches: 1.13.12;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.12 04-Apr-2004  matt Add int get_fpu_fault_code(void).
 1.11 23-Jun-2003  martin branches: 1.11.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.10 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.7 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.6 19-May-2002  jdolecek make usable in LKM context (use #if defined(_KERNEL_OPT))
 1.5 05-Dec-2001  chs branches: 1.5.8;
fix macppc MULTIPROCESSOR compilation.
 1.4 13-Jun-2001  simonb branches: 1.4.2; 1.4.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.3 04-Feb-2001  briggs branches: 1.3.2;
Build with -Wall -Wetc.
 1.2 07-Dec-1999  danw Fix "FPCSR" to "FPSCR". ("Floating Point Status and Control Register")
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.34;
PowerPC port
 1.1.34.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.28.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.7 11-Nov-2002  nathanw Catch up to -current
 1.4.8.6 01-Aug-2002  nathanw LWPify.
 1.4.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.4.8.4 20-Jun-2002  nathanw Catch up to -current.
 1.4.8.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.4.8.1 13-Jun-2001  briggs file fpu.h was added on branch nathanw_sa on 2001-11-05 19:46:16 +0000
 1.4.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.8.2 31-Aug-2002  gehenna catch up with -current.
 1.5.8.1 30-May-2002  gehenna Catch up with -current.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.2 27-Oct-2007  yamt sync with head.
 1.13.12.1 30-Dec-2006  yamt sync with head.
 1.14.8.1 11-Aug-2006  yamt sync with head
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.38.1 25-Oct-2007  bouyer Sync with HEAD.
 1.15.36.1 18-Oct-2007  yamt sync with head.
 1.15.34.1 06-Nov-2007  matt sync with HEAD
 1.15.32.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.15.22.1 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.15.14.1 23-Oct-2007  ad Sync with head.
 1.16.48.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.46.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.16.42.2 31-May-2011  rmind sync with head
 1.16.42.1 05-Mar-2011  rmind sync with head
 1.19.18.1 28-Aug-2013  rmind sync with head
 1.19.14.2 03-Dec-2017  jdolecek update from HEAD
 1.19.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.20.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.20.6.1 28-Aug-2017  skrll Sync with HEAD
 1.21.12.1 22-Apr-2018  pgoyette Sync with HEAD
 1.29 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.28 06-Jul-2020  rin LKM was gone. _KERNEL is always defined for module.
 1.27 24-Jan-2016  christos expose __register32_t for frame.h
 1.26 28-Feb-2014  matt branches: 1.26.6;
Add trapframe32 for COMPAT_NETBSD32
 1.25 01-Aug-2012  matt branches: 1.25.2; 1.25.4;
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.24 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.23 20-Jun-2011  matt branches: 1.23.2; 1.23.6; 1.23.8;
Pad out trapframe for OEA so that trapframe has identical sizes for all
PPC variants.
 1.22 18-Jan-2011  matt branches: 1.22.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.21 27-Nov-2009  rmind branches: 1.21.4; 1.21.6;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.20 16-Oct-2008  wrstuden branches: 1.20.16;
Bring back saframe. Noted by Robert Swindells.
 1.19 09-Feb-2007  ad branches: 1.19.44; 1.19.48; 1.19.54;
Merge newlock2 to head.
 1.18 11-Dec-2005  christos branches: 1.18.20;
merge ktrace-lwp.
 1.17 27-Aug-2003  matt branches: 1.17.16;
Move SFRAMELEN to frame.h and use it in vm_machdep.c. In setfunc, setup
callframe linkages correctly. Restore use of ldptr to locore_subr.S
[pthreads and gdb no longer crash/hang the system]
 1.16 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.15 31-Jul-2003  matt Change switchframe to use register_t (anything that uses stmX/lmX needs
to be defined as register_t).
 1.14 03-Feb-2003  matt branches: 1.14.2;
Don't use trapframe in sigcontext. Instead define a new structure
utrapframe that fixed in size (and the same size as the trapframe
in NetBSD 1.5). This preserves binary compatibility for those programs
that dealt looked at sigcontexts.
 1.13 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.12 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.11 19-Jan-2003  matt Use CALLFRAMELEN instead of 16.
 1.10 19-Jan-2003  matt Add trapframe32 (for compat_netbsd32).
Add CALLFRAMELEN. (so we can remove many of the hard coded "16" or "15"
in the powerpc code).
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.7 24-Jul-2002  chs rename the intr_depth field of struct intrframe to avoid a name conflict
in MULTIPROCESSOR builds.
 1.6 18-Jul-2002  matt Make sure that pmap_zero_page and pmap_copy_page don't make calls or
reference while relocation is disabled since the stack will be inaccessible.
Add support for using AltiVec in pmap_zero_page and pmap_copy_page on
AltiVec capable processors.
 1.5 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.4 21-Apr-2002  kleink branches: 1.4.2;
Convert the spill stack frame to use symbolic offset names; inspired by
a conversation with Matt Thomas.
 1.3 18-Apr-2002  matt Use a common genassym.cf for all the PPC_MPC6XX ports. Add a makeoptions to
std.foo to indicate the directory to get genassym.cf from. Add an intrframe
to <powerpc/frame.h> and make trap_subr.S use symbolic offsets into it.
 1.2 10-Jan-1999  tsubai branches: 1.2.22; 1.2.26;
Fix void * arithmetic.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.26.6 11-Nov-2002  nathanw Catch up to -current
 1.2.26.5 01-Aug-2002  nathanw Catch up to -current.
 1.2.26.4 03-Jul-2002  nathanw Whitespace.
 1.2.26.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.26.2 13-Nov-2001  briggs Improve upcall to better work with libpthread.
 1.2.26.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.2.22.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.22.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.3 31-Aug-2002  gehenna catch up with -current.
 1.4.2.2 21-Jul-2002  gehenna catch up with -current.
 1.4.2.1 16-Jul-2002  gehenna catch up with -current.
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.16.1 26-Feb-2007  yamt sync with head.
 1.18.20.1 01-Feb-2007  ad Header file cleanup.
 1.19.54.1 19-Oct-2008  haad Sync with HEAD.
 1.19.48.2 11-Mar-2010  yamt sync with head
 1.19.48.1 04-May-2009  yamt sync with head.
 1.19.44.1 17-Jan-2009  mjf Sync with HEAD.
 1.20.16.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.20.16.1 07-Jan-2011  matt intrframe is dead. Just use a partially filled trapframe.
Add a ktrapframe which include the cf_sp/cf_lr of the callframe in addition
to the trapframe. This allows the FRAME_XX+8 to just be FRAME_XX.
Cleanup and simplify.
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.1 05-Mar-2011  rmind sync with head
 1.22.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.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.23.6.1 24-Feb-2012  mrg sync to -current.
 1.23.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.23.2.2 30-Oct-2012  yamt sync with head
 1.23.2.1 17-Apr-2012  yamt sync with head
 1.25.4.1 18-May-2014  rmind sync with head
 1.25.2.2 03-Dec-2017  jdolecek update from HEAD
 1.25.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.6.1 19-Mar-2016  skrll Sync with HEAD
 1.2 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.1 09-Nov-2000  tsubai branches: 1.1.2;
powerpc HID registers definitions (only HID0 for now).
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 09-Nov-2000  bouyer file hid.h was added on branch thorpej_scsipi on 2000-11-22 16:01:27 +0000
 1.2 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.1 18-Dec-1999  thorpej branches: 1.1.2; 1.1.8;
Hardware Implementation Dependent registers for the PowerPC 601.
 1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.8.1 18-Dec-1999  bouyer file hid_601.h was added on branch thorpej_scsipi on 2000-11-20 20:31:09 +0000
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7 23-Jan-2024  rin powerpc/ieee.h: Protect from multiple includes

Fix build failure triggered by import of libm long-double functions.
 1.6 22-Oct-2014  joerg Support copysignl on PowerPC.
 1.5 11-Dec-2005  christos branches: 1.5.122; 1.5.140;
merge ktrace-lwp.
 1.4 15-Apr-2005  kleink Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.

IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.3 26-Oct-2003  kleink branches: 1.3.8; 1.3.14;
Use <sys/ieee754.h> where applicable.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 30-Sep-1996  ws branches: 1.1.62;
PowerPC port
 1.1.62.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.62.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.62.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.62.1 03-Aug-2004  skrll Sync with HEAD
 1.3.14.1 19-Apr-2005  tron Pull up revision 1.4 (requested by kleink in ticket #163):
Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.
IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.3.8.1 29-Apr-2005  kent sync with -current
 1.5.140.1 25-May-2015  msaitoh Pull up following revision(s) (requested by joerg in ticket #790):
sys/arch/powerpc/include/math.h: revision 1.5
lib/libm/src/namespace.h: revision 1.13
lib/libm/arch/vax/n_support.S: revision 1.10
lib/libm/src/s_copysignl.c: revision 1.3
lib/libm/src/s_copysignl.c: revision 1.4
lib/libm/src/s_copysignl.c: revision 1.5
sys/arch/powerpc/include/ieee.h: revision 1.6
lib/libm/src/s_copysign.c: revision 1.12
lib/libm/src/s_copysign.c: revision 1.13
- Support copysignl on PowerPC.
- Define copysignl on !long double platforms. Be consistent in the use of
weak aliases.
- copysignl is also needed for PowerPC's double-double format, so special
case that. Functional support was added earlier, but not enabled.
 1.5.122.1 03-Dec-2017  jdolecek update from HEAD
 1.7 22-Mar-2017  chs provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().
 1.6 27-Feb-2017  chs the FP_* exception constants need to be different from the new FE_* constants
to preserve the ABI, so shift them as needed when using them.
 1.5 25-Dec-2015  christos branches: 1.5.2; 1.5.4;
move fenv inside ifdef
 1.4 22-Dec-2015  christos remove dup definitions from fenv.h
 1.3 05-Aug-2008  matt branches: 1.3.38; 1.3.58;
Update <machine/ieeefp.h> to use the C99 FE_* definitions instead of the
NetBSD defined ones. Redefine the NetBSD ones in terms of the C99 ones.
Step 1 to having <fenv.h>
 1.2 07-Jul-1999  danw branches: 1.2.138; 1.2.142; 1.2.144; 1.2.148;
reorder the fp_rnd constants to match the values used by the
powerpc fpu
 1.1 16-Apr-1997  thorpej branches: 1.1.18;
Definitions for IEEE floating point for NetBSD/powerpc.
 1.1.18.1 02-Aug-1999  thorpej Update from trunk.
 1.2.148.1 19-Oct-2008  haad Sync with HEAD.
 1.2.144.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.142.1 04-May-2009  yamt sync with head.
 1.2.138.1 28-Sep-2008  mjf Sync with HEAD.
 1.3.58.2 28-Aug-2017  skrll Sync with HEAD
 1.3.58.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.38.1 03-Dec-2017  jdolecek update from HEAD
 1.5.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.5.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.5.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.12 30-Aug-2022  rin Move FTYPE_* definitions from instr.h to fpu_emu.h.

They are not defined by architecture, and used only for FPU emulation.
 1.11 30-May-2022  rin Add routines to fix unaligned memory access for userland process.

Mainly intended for 403, which cannot handle unaligned memory access
at all (not only ones across page boundaries like 601).

For more details, see comments in fix_unaligned.c.
 1.10 29-May-2022  rin Fix insn field definitions for MD and MDS formats.

No one uses these yet.
 1.9 15-Jul-2020  rin Factor out emulation code for m[ft]msr in user mode from oea, and
adjust it for systems without FPU.

Now, it can be used from booke and ibm4xx in order to support fenv(3).
 1.8 27-Feb-2017  chs have fpsetmask() change the FE0/FE1 MSR bits to precise mode if any
FP exceptions are enabled. fix the kernel emulation of mfmsr and mtmsr
to use the correct opcodes for these instructions. ignore PSL_FE
(the FP enable bit) in the MSR that a user program tries to set,
since it will naturally be set for FP-using processes but
we can't let the user process manage that bit.
 1.7 01-Aug-2014  matt branches: 1.7.4; 1.7.8; 1.7.12;
Add OPC31_OR
 1.6 12-Feb-2011  matt branches: 1.6.14; 1.6.28;
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.5 18-Jan-2011  matt branches: 1.5.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.4 11-Dec-2005  christos branches: 1.4.100; 1.4.104; 1.4.106;
merge ktrace-lwp.
 1.3 27-Oct-2003  simonb Remove (the now non-compiling) support for 128bit FP emulation, which
isn't needed for PowerPC anyway.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.10; 1.1.26;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.26.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.10.1 13-Jun-2001  simonb file instr.h was added on branch nathanw_sa on 2001-06-13 06:01:49 +0000
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.104.4 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.4.104.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.4.104.2 07-Jan-2011  matt Move OPC_MFMSR definitions from trap.c
Add OPC_LWSYNC for booke.
 1.4.104.1 07-Jan-2011  matt Add fixup definitions.
 1.4.100.1 05-Mar-2011  rmind sync with head
 1.5.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.28.1 10-Aug-2014  tls Rebase.
 1.6.14.2 03-Dec-2017  jdolecek update from HEAD
 1.6.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.12.1 21-Apr-2017  bouyer Sync with HEAD
 1.7.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.7.4.1 28-Aug-2017  skrll Sync with HEAD
 1.5 13-Aug-2014  matt Include <sys/common_int_const.h> if __INTMAX_C_SUFFIX__ is defined.
 1.4 29-May-2010  tnozaki branches: 1.4.18;
fix wrong integer promotion rule(removed U suffix from UINT{8,16}_C).
see ISO/IEC 9899:1999 7.18.4.3.
 1.3 28-Apr-2008  martin branches: 1.3.20; 1.3.22;
Remove clause 3 and 4 from TNF licenses
 1.2 03-Nov-2002  matt branches: 1.2.108; 1.2.110; 1.2.112;
Add LP64 bits (copied from MIPS).
 1.1 14-Apr-2001  kleink branches: 1.1.2; 1.1.4; 1.1.12;
Add definitions of C99 integer constant macros.
 1.1.12.2 11-Nov-2002  nathanw Catch up to -current
 1.1.12.1 14-Apr-2001  nathanw file int_const.h was added on branch nathanw_sa on 2002-11-11 22:02:48 +0000
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 14-Apr-2001  bouyer file int_const.h was added on branch thorpej_scsipi on 2001-04-21 17:54:31 +0000
 1.2.112.2 11-Aug-2010  yamt sync with head.
 1.2.112.1 16-May-2008  yamt sync with head.
 1.2.110.1 18-May-2008  yamt sync with head.
 1.2.108.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.22.1 30-May-2010  rmind sync with head
 1.3.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.18.1 03-Dec-2017  jdolecek update from HEAD
 1.7 05-Mar-2018  christos int64 is long for _LP64
 1.6 01-Apr-2015  matt forgot to commit this when I updated netbsd64 in gcc.
Remove LP64 specific change and use the same types
when possible for IPL32 and LP64.
 1.5 13-Aug-2014  matt branches: 1.5.2;
include <sys/common_int_fmtio.h> if __INTPTR_FMTd__ is defined
 1.4 28-Apr-2008  martin branches: 1.4.44;
Remove clause 3 and 4 from TNF licenses
 1.3 03-Nov-2002  matt branches: 1.3.108; 1.3.110; 1.3.112;
Add LP64 bits (copied from MIPS).
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10;
Add definitions for C99 fastest minimum-width integer types.
 1.1 15-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 integer format conversion macros.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 15-Apr-2001  bouyer file int_fmtio.h was added on branch thorpej_scsipi on 2001-04-21 17:54:31 +0000
 1.2.10.2 11-Nov-2002  nathanw Catch up to -current
 1.2.10.1 26-Apr-2001  nathanw file int_fmtio.h was added on branch nathanw_sa on 2002-11-11 22:02:48 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.112.1 16-May-2008  yamt sync with head.
 1.3.110.1 18-May-2008  yamt sync with head.
 1.3.108.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.44.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 06-Apr-2015  skrll Sync with HEAD
 1.9 13-Aug-2014  matt Include <sys/common_init_limits.h> if __SIG_ATOMIC_MAX__ is defined.
 1.8 28-Apr-2008  martin branches: 1.8.44;
Remove clause 3 and 4 from TNF licenses
 1.7 17-Oct-2007  garbled branches: 1.7.16; 1.7.18; 1.7.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 31-Aug-2007  drochner Fix definitions of UCHAR_MAX/USHRT_MAX and related
types. C99 requires that these definitions promote to (signed/unsigned)
integer the same way as the types the definition is for. And since
unsigned char/short fit into an "int" on all our archs and thus promote
to signed int, the definitions must not be unsigned.
Fixes PR lib/31306 by Neil Booth.
 1.5 11-Dec-2005  christos branches: 1.5.30; 1.5.38; 1.5.44; 1.5.48; 1.5.50;
merge ktrace-lwp.
 1.4 08-May-2004  kleink branches: 1.4.12;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.3 03-Nov-2002  matt branches: 1.3.6;
Add LP64 limits.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10;
Add definitions for C99 fastest minimum-width integer types.
 1.1 15-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 specified-width integer type limits.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 15-Apr-2001  bouyer file int_limits.h was added on branch thorpej_scsipi on 2001-04-21 17:54:31 +0000
 1.2.10.2 11-Nov-2002  nathanw Catch up to -current
 1.2.10.1 26-Apr-2001  nathanw file int_limits.h was added on branch nathanw_sa on 2002-11-11 22:02:49 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.6.1 03-Aug-2004  skrll Sync with HEAD
 1.4.12.1 03-Sep-2007  yamt sync with head.
 1.5.50.1 06-Nov-2007  matt sync with HEAD
 1.5.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.5.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.5.38.1 03-Oct-2007  garbled Sync with HEAD
 1.5.30.1 09-Oct-2007  ad Sync with head.
 1.7.20.1 16-May-2008  yamt sync with head.
 1.7.18.1 18-May-2008  yamt sync with head.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.44.1 03-Dec-2017  jdolecek update from HEAD
 1.6 13-Aug-2014  matt include <sys/common_int_mwgwtypes.h> if __UINT_FAST64_TYPE__ is defined.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Dec-2005  perry branches: 1.4.74; 1.4.76; 1.4.78;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 03-Nov-2002  matt branches: 1.3.22;
Add LP64 bits (copied from MIPS).
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10;
Add definitions for C99 fastest minimum-width integer types.
 1.1 14-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 minimum-width and greatest-width integer types.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 14-Apr-2001  bouyer file int_mwgwtypes.h was added on branch thorpej_scsipi on 2001-04-21 17:54:31 +0000
 1.2.10.2 11-Nov-2002  nathanw Catch up to -current
 1.2.10.1 26-Apr-2001  nathanw file int_mwgwtypes.h was added on branch nathanw_sa on 2002-11-11 22:02:49 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.22.1 21-Jun-2006  yamt sync with head.
 1.4.78.1 16-May-2008  yamt sync with head.
 1.4.76.1 18-May-2008  yamt sync with head.
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.44.1 03-Dec-2017  jdolecek update from HEAD
 1.11 13-Aug-2014  matt Include <sys/common_int_types.h> if __UINTPTR_TYPE__ is defined.
 1.10 24-Dec-2005  perry branches: 1.10.122;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 25-May-2005  kleink branches: 1.8.2;
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.7 07-Aug-2003  agc branches: 1.7.6; 1.7.14;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 03-Nov-2002  matt branches: 1.6.6;
Add LP64 bits (copied from MIPS).
 1.5 28-Apr-2001  kleink branches: 1.5.8;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.4 12-Apr-2001  kleink Replace the 'unsigned __COMPILER_INT64__' construct with a new name,
__COMPILER_UINT64__, to be supplied - if such a case is made, it shouldn't
be assumed that the unsigned type-specifier may be applied to it.
 1.3 03-Jan-2001  takemura branches: 1.3.2;
replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.2 27-Jun-2000  kleink branches: 1.2.2;
Resolve some formatting nits; add __intptr_t and __uintptr_t.
 1.1 26-Jun-2000  kleink Add <machine/int_types.h>, which provides namespace-pure definitions
of exact-width integer types.
 1.2.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 27-Jun-2000  bouyer file int_types.h was added on branch thorpej_scsipi on 2000-11-20 20:31:09 +0000
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.8.2 11-Nov-2002  nathanw Catch up to -current
 1.5.8.1 28-Apr-2001  nathanw file int_types.h was added on branch nathanw_sa on 2002-11-11 22:02:50 +0000
 1.6.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.14.1 28-May-2005  tron Pull up revision 1.8 (requested by klein in ticket #346):
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.7.6.1 29-May-2005  riz Pull up revision 1.8 (requested by kleink in ticket #1555):
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.10.122.1 03-Dec-2017  jdolecek update from HEAD
 1.19 11-Jul-2022  martin PR 56922: disabel fast softints for powerpc for now.
 1.18 02-Mar-2021  rin Turn imask into static.

XXX
Other macro etc. in powerpc/intr.h should also be moved into
powerpc/pic/intr.c, or protected by __INTR_PRIVATE.
 1.17 16-Apr-2020  rin branches: 1.17.2;
Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.16 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.15 20-Feb-2020  rin branches: 1.15.4;
Fix !__HAVE_FAST_SOFTINTS build for debugging.
 1.14 24-Oct-2019  macallan branches: 1.14.2;
bump NIRQ to 256 since we're going to use vectors above 128
 1.13 19-Apr-2018  christos branches: 1.13.2; 1.13.6;
s/static inline/static __inline/g for consistency.
 1.12 19-Oct-2016  nonaka branches: 1.12.14;
Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.11 23-Aug-2013  matt branches: 1.11.6; 1.11.10;
Fix kern_softint.c errors (tested with WALNUT & EV64260)
 1.10 14-Jan-2012  phx branches: 1.10.6; 1.10.10;
Some PICs have the capability to define the interrupt's polarity (OpenPIC
for example). So the accepted interrupt types have been extended to:
- IST_EDGE_FALLING (which is the same as IST_EDGE)
- IST_EDGE_RISING (new)
- IST_LEVEL_LOW (is the same as IST_LEVEL)
- IST_LEVEL_HIGH (new)
Old code will continue to work without modification.
 1.9 20-Jun-2011  matt branches: 1.9.2; 1.9.6;
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.8 17-Jun-2011  matt intr.h must not include cpu due to deadly embrace with SOFTINT_COUNT.
Cleanup intr.h so MD definitions can overload common definitions.
Rototill pic/intr.c. Virtual IRQs can now be reclaimed. separate virq
from hwirq from picirq. Redo intr mask calculations.
tested on pmppc and macppc (MP).
 1.7 17-Jun-2011  matt Change from level to ipl since we aren't dealing a mask anymore, just a
simple value.
Fix intr_calculatemasks to deal with ipl isn't a mask. Let establish
and disestablish determine the highest ipl for the interrut source being
modified. No reason to recompute that for every source when only one changes
at a time. Only change idepth while in the loop.
 1.6 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 1.5 25-Apr-2010  kiyohara branches: 1.5.6;
Fix forgot to commit.
Support 64-bit imask for powerpc/pic.
 1.4 29-Apr-2008  martin branches: 1.4.20; 1.4.22;
Convert to new 2 clause license
 1.3 03-Dec-2007  ad branches: 1.3.14; 1.3.16; 1.3.18;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 04-May-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file intr.h was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.3 10-May-2007  garbled More cleanup:
1) Remove lcsplx, strayintr, and foosoft from all the converted ports.
None of this stuff is needed anymore.
2) because lcsplx is just "return spllower", just call spllower from
locore_subr.S instead.
3) Every port (except macppc) had a pretty similar cpu_configure(), so
take the common parts out and make a genppc_cpu_configure() in an attempt
to stop using imask[] outside of intr.c
 1.1.2.2 08-May-2007  garbled Make powerpc/intr.h more common than it previously was. Having done
that, delete all the duplicate entries from the 4 ports that have
converted to shared pic code. Also, commit a minor change to sandpoint
that I forgot to commit earlier (delete an unused variable)
 1.1.2.1 04-May-2007  macallan move some common interrupt-related stuff here
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file intr.h was added on branch matt-armv6 on 2007-11-06 23:20:34 +0000
 1.2.6.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.4.3 07-Dec-2007  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file intr.h was added on branch yamt-lazymbuf on 2007-10-27 11:27:45 +0000
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file intr.h was added on branch vmlocking on 2007-10-23 20:36:02 +0000
 1.3.18.2 11-Aug-2010  yamt sync with head.
 1.3.18.1 16-May-2008  yamt sync with head.
 1.3.16.1 18-May-2008  yamt sync with head.
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.22.1 30-May-2010  rmind sync with head
 1.4.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.6.1 18-Feb-2012  mrg merge to -current.
 1.9.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.9.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 28-Aug-2013  rmind sync with head
 1.10.6.2 03-Dec-2017  jdolecek update from HEAD
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.11.6.1 05-Dec-2016  skrll Sync with HEAD
 1.12.14.1 22-Apr-2018  pgoyette Sync with HEAD
 1.13.6.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #729):

sys/arch/powerpc/include/intr.h: revision 1.15

Fix !__HAVE_FAST_SOFTINTS build for debugging.
 1.13.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.2.1 29-Feb-2020  ad Sync with head.
 1.15.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.17.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.4 16-Feb-2006  perry branches: 1.4.158; 1.4.160;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.3 24-Dec-2005  perry branches: 1.3.2; 1.3.4; 1.3.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 16-Apr-1997  thorpej Update ipkdb's register handling, from Wolfgang Solfrank.
 1.1 16-Oct-1996  ws Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.1 18-Feb-2006  yamt sync with head.
 1.4.160.1 10-Jun-2019  christos Sync with HEAD
 1.4.158.1 28-Jul-2018  pgoyette Sync with HEAD
 1.2 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.1 30-Sep-1996  ws PowerPC port
 1.9 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.8 01-Jul-2011  dyoung branches: 1.8.2; 1.8.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.7 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.6 20-Aug-2009  dyoung branches: 1.6.10;
Declare genppc_isa_detach_hook().
 1.5 19-Aug-2009  dyoung Define genppc_isa_detach_hook() and isa_dmadestroy().
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 17-Oct-2007  garbled branches: 1.3.16; 1.3.18; 1.3.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.2 11-Dec-2005  christos branches: 1.2.30; 1.2.38; 1.2.48; 1.2.50; 1.2.52; 1.2.54;
merge ktrace-lwp.
 1.1 19-Oct-2003  matt branches: 1.1.4; 1.1.18;
Add powerpc-specific isa and isadma machdep code. (Merge common code from
prep and sandpoint and ...)
 1.1.18.1 27-Oct-2007  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 19-Oct-2003  skrll file isa_machdep.h was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.2.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.2.52.1 18-Oct-2007  yamt sync with head.
 1.2.50.1 06-Nov-2007  matt sync with HEAD
 1.2.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.2.38.1 07-May-2007  garbled Rewrite how shared isa is done slightly. This will allow the individual
ports to override the shared functions if needed. Also, implement
isa_intr_alloc, which needed to be done inside pic/intr.c because it
needs access to structs which are static to the file.
 1.2.30.1 23-Oct-2007  ad Sync with head.
 1.3.20.3 16-Sep-2009  yamt sync with head
 1.3.20.2 19-Aug-2009  yamt sync with head.
 1.3.20.1 16-May-2008  yamt sync with head.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.3.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.2.1 30-Oct-2012  yamt sync with head
 1.5 11-Dec-2005  christos branches: 1.5.104;
merge ktrace-lwp.
 1.4 17-Feb-2005  briggs Update to a kcore_hdr_t that is useful for OEA-style CPUs. Adding
support for Book-E and other CPUs will require updating this structure
appropriately.
Contributed by Wasabi Systems, Inc.
 1.3 03-Nov-2002  matt branches: 1.3.6; 1.3.14; 1.3.16;
Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.2 31-Aug-1998  tsubai branches: 1.2.30;
vm_offset_t --> [pv]addr_t
 1.1 30-Sep-1996  ws PowerPC port
 1.2.30.1 11-Nov-2002  nathanw Catch up to -current
 1.3.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.14.1 29-Apr-2005  kent sync with -current
 1.3.6.1 17-Feb-2005  skrll Sync with HEAD.
 1.5.104.1 26-Jul-2011  matt Include the battable, not just the contents of the bat registers.
 1.2 16-Oct-1996  ws Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.1 30-Sep-1996  ws PowerPC port
 1.21 02-Apr-2024  christos harmonize with the rest of MD limits files.
 1.20 21-Jan-2019  dholland Fix wrong scoping of {U,}LLONG_MAX. More cases, not just amd64.
PR 53298 from Roberto E. Vargas Caballero.
 1.19 21-Apr-2014  matt branches: 1.19.26; 1.19.28;
Since all our compilers support __DBL_* and __FLT_*, use them to define
{DBL,FLT}_{DIG,MIN,MAX}
 1.18 11-Apr-2013  christos branches: 1.18.4; 1.18.8;
add missing SSIZE_MIN
 1.17 28-Mar-2012  christos branches: 1.17.2;
- Normalize inclusion protection (remove)
- Move CHAR_{MIN,MAX} to a common file.
- Fix broken comments
 1.16 07-Jun-2010  tnozaki branches: 1.16.8; 1.16.12;
1. MB_LEN_MAX switch MD to MI.
2. unfortunately hppa's MB_LEN_MAX is defined incorrectly 6 instead of 32
so we have to add more setlocale(3) __RENAME func, __setlocale50.
3. move setlocale1.c and setlocale32.c to lib/libc/compat/locale/*
prepareing for next libc major crunk.
4. bump libc minor version.
 1.15 17-Oct-2007  garbled branches: 1.15.20; 1.15.40; 1.15.42;
Merge the ppcoea-renovation branch to HEAD.

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

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

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

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

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

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

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.10 03-Nov-2002  matt LP64 changes (copied from mips and changed CHAR_MIN/MAX to 0/0xffU).
 1.9 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.8 04-May-2001  simonb branches: 1.8.8;
Be consistent with limit constants:
- use "U" suffix for unsigned constants
- use "L" suffix for long constants
- use "UL" suffix for unsigned long constants
- use hexadecimal instead of decimal

Fixes build problems with vi (now that warnings/errors are enabled) on
mips, powerpc and arm platforms.
 1.7 08-Aug-2000  tshiozak branches: 1.7.2;
Preparation for the future introduction of multibyte locale.
- MB_LEN_MAX is increased to 32.
- To ensure binary compatibility for old executables
under multibyte locale, versioned setlocale is added.
- __mb_len_cur definision is added in setlocale.c
and enable it in stdlib.h .
It is also important for multibyte locale stuffs,
but I just forgot.
 1.6 07-Mar-2000  kleink branches: 1.6.2; 1.6.4;
Define ISO C99 (unsigned) long long (min, max) symbols.
 1.5 16-Nov-1998  mycroft branches: 1.5.10;
Add {LONG,WORD}_BIT and {DBL,FLT}_{DIG,MAX,MIN}.
 1.4 06-Aug-1998  kleink _POSIX_SOURCE -> _POSIX_C_SOURCE
 1.3 28-Jul-1998  thorpej Provide SSIZE_MAX.
 1.2 09-Jan-1998  perry multiple include protect machine/limits.h, fixes pr 4473 (from Mika Nystrom)
 1.1 30-Sep-1996  ws PowerPC port
 1.5.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.1 09-Aug-2000  tshiozak pull up the following changes (approved by thorpej):
> cvs rdiff -r1.9 -r1.10 basesrc/include/locale.h
> cvs rdiff -r1.45 -r1.46 basesrc/include/stdlib.h
> cvs rdiff -r1.16 -r1.17 basesrc/lib/libc/locale/Makefile.inc
> cvs rdiff -r1.17 -r1.18 basesrc/lib/libc/locale/setlocale.c
> cvs rdiff -r0 -r1.2 basesrc/lib/libc/locale/setlocale_sb.c
> cvs rdiff -r1.6 -r1.7 syssrc/sys/arch/alpha/include/limits.h
> cvs rdiff -r1.1 -r1.2 syssrc/sys/arch/arm26/include/limits.h
> cvs rdiff -r1.7 -r1.8 syssrc/sys/arch/arm32/include/limits.h
> cvs rdiff -r1.14 -r1.15 syssrc/sys/arch/i386/include/limits.h
> cvs rdiff -r1.12 -r1.13 syssrc/sys/arch/m68k/include/limits.h
> cvs rdiff -r1.13 -r1.14 syssrc/sys/arch/mips/include/limits.h
> cvs rdiff -r1.10 -r1.11 syssrc/sys/arch/pc532/include/limits.h
> cvs rdiff -r1.6 -r1.7 syssrc/sys/arch/powerpc/include/limits.h
> cvs rdiff -r1.2 -r1.3 syssrc/sys/arch/sh3/include/limits.h
> cvs rdiff -r1.11 -r1.12 syssrc/sys/arch/sparc/include/limits.h
> cvs rdiff -r1.7 -r1.8 syssrc/sys/arch/sparc64/include/limits.h
> cvs rdiff -r1.9 -r1.10 syssrc/sys/arch/vax/include/limits.h
>
> Outline:
>
> Preparation for the future introduction of multibyte locale.
> - MB_LEN_MAX is increased to 32.
> - To ensure binary compatibility for old executables
> under multibyte locale, versioned setlocale is added.
> - __mb_len_cur definision is added in setlocale.c
> and enable it in stdlib.h .
> It is also important for multibyte locale stuffs,
> but I just forgot.
 1.6.2.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.8.2 11-Nov-2002  nathanw Catch up to -current
 1.8.8.1 04-May-2001  nathanw file limits.h was added on branch nathanw_sa on 2002-11-11 22:02:51 +0000
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.1 03-Sep-2007  yamt sync with head.
 1.13.50.1 06-Nov-2007  matt sync with HEAD
 1.13.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.13.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.13.38.1 03-Oct-2007  garbled Sync with HEAD
 1.13.30.1 09-Oct-2007  ad Sync with head.
 1.15.42.1 03-Jul-2010  rmind sync with head
 1.15.40.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.15.20.1 11-Aug-2010  yamt sync with head.
 1.16.12.1 05-Apr-2012  mrg sync to latest -current.
 1.16.8.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.8.1 17-Apr-2012  yamt sync with head
 1.17.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.2.1 23-Jun-2013  tls resync from head
 1.18.8.1 10-Aug-2014  tls Rebase.
 1.18.4.1 18-May-2014  rmind sync with head
 1.19.28.1 10-Jun-2019  christos Sync with HEAD
 1.19.26.1 26-Jan-2019  pgoyette Sync with HEAD
 1.17 12-Feb-2022  riastradh __cpu_simple_lock(9): Omit needless barriers in init.

It is, and always has been, the caller's responsibility to ensure the
lock is initialized before it can be used -- otherwise the memory
could hold garbage; it is nonsensical to even attempt locking
operations on it before initialization.

So there's no need to issue explicit barriers here. The barrier
seems to have been introduced in sys/arch/alpha/alpha/lock_machdep.c
rev. 1.1 (since moved to inline asm in alpha/include/lock.h) and then
copied & pasted into several other architectures.
 1.16 13-Sep-2021  rin Fix IBM405 errata 77 workaround for __cpu_simple_lock{,_try}();
adjust labels so that dcbt is executed before stwcx. insn.
 1.15 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.14 29-Nov-2019  riastradh Nix mb_* on powerpc.
 1.13 17-Sep-2017  christos branches: 1.13.4; 1.13.8;
more const.
 1.12 28-Apr-2008  martin branches: 1.12.44;
Remove clause 3 and 4 from TNF licenses
 1.11 17-Oct-2007  garbled branches: 1.11.16; 1.11.18; 1.11.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.10 10-Sep-2007  skrll Merge nick-csl-alignment.
 1.9 09-Feb-2007  ad branches: 1.9.6; 1.9.14; 1.9.18; 1.9.22; 1.9.24;
Merge newlock2 to head.
 1.8 28-Dec-2005  perry branches: 1.8.20;
inline -> __inline
 1.7 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 26-Sep-2003  nathanw branches: 1.5.16;
Move __cpu_simple_lock_t and __SIMPLELOCK_{UN,}LOCKED to machine/types.h
so that they can be used in a namespace-friendly way.
 1.4 08-Jul-2000  tsubai branches: 1.4.2; 1.4.26;
Clear the reservation in __cpu_simple_lock_try even if it failed to lock.
(From ws@tools.de)
 1.3 06-Jul-2000  tsubai Implement powerpc spin lock functions.
 1.2 02-May-2000  thorpej Let each platform typedef the new __cpu_simple_lock_t, which should
be the most efficient type used for the atomic operations in the
simplelock structure, and should also be __volatile.
 1.1 29-Apr-2000  thorpej Require that each each MACHINE/MACHINE_ARCH supply a lock.h. This file
contains the values __SIMPLELOCK_LOCKED and __SIMPLELOCK_UNLOCKED, which
replace the old SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED. These files
are also required to supply inline functions __cpu_simple_lock(),
__cpu_simple_lock_try(), and __cpu_simple_unlock() if locking is to be
supported on that platform (i.e. if MULTIPROCESSOR is defined in the
_KERNEL case). Change these functions to take an int * (&alp->lock_data)
rather than the struct simplelock * itself.

These changes make it possible for userland to use the locking primitives
by including <machine/lock.h>.
 1.4.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.26.1 03-Aug-2004  skrll Sync with HEAD
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 08-Jul-2000  bouyer file lock.h was added on branch thorpej_scsipi on 2000-11-20 20:31:09 +0000
 1.5.16.3 27-Oct-2007  yamt sync with head.
 1.5.16.2 26-Feb-2007  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.8.20.1 28-Jan-2007  ad powerpc changes.
 1.9.24.1 06-Nov-2007  matt sync with HEAD
 1.9.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.9.18.1 15-Aug-2007  skrll Provide __SIMPLELOCK_{UN,}LOCKED_P and __cpu_simple_lock_{set,clear}
for all architectures.
 1.9.14.2 03-Oct-2007  garbled Sync with HEAD
 1.9.14.1 11-Sep-2007  macallan sync with HEAD
 1.9.6.1 09-Oct-2007  ad Sync with head.
 1.11.20.1 16-May-2008  yamt sync with head.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.11.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.44.1 03-Dec-2017  jdolecek update from HEAD
 1.13.8.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.13.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 04-Nov-2024  christos Undo previous lwp.h change.
 1.1 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.1 30-Nov-2024  christos branches: 1.1.4;
Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Nov-2024  perseant file lwp_private.h was added on branch perseant-exfatfs on 2025-08-02 05:56:00 +0000
 1.6 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.5 28-Apr-2008  martin branches: 1.5.22; 1.5.28;
Remove clause 3 and 4 from TNF licenses
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.76; 1.4.78;
merge ktrace-lwp.
 1.3 25-Jun-2005  christos the siginfo trap codes are mi.
 1.2 03-Dec-2003  manu branches: 1.2.4;
Move machine dependent definitions to machine dependent headers.
 1.1 11-Nov-2003  manu Implement mach_thread_get_state.
While we are here, try to tag machine dependent functions in header files.
also transformed darwin_ppc_*_state into mach_ppc_*_state, as this is
what they really are (COMPAT_DARWIN is on the top of COMPAT_MACH, not the
other way around)
 1.2.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 03-Dec-2003  skrll file mach_machdep.h was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.4.78.1 16-May-2008  yamt sync with head.
 1.4.76.1 18-May-2008  yamt sync with head.
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.22.1 31-May-2011  rmind sync with head
 1.3 03-May-2001  soren PPC machine type tags haven't been used for a while.
 1.2 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.1 16-Apr-1997  thorpej branches: 1.1.4;
Machine-type tags used to communicate the type of system we're running
on to the kernel. The boot program passes a boot args string plus
additional information like so:

/pci/scsi@3/disk@0,0:1/netbsd -s<NUL><esym><tag>

The post-<NUL> values are:

<esym> end of the kernel symbol table (32-bits)

<tag> machine type tag (32-bits)
 1.1.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.2 28-Apr-2008  martin branches: 1.2.22; 1.2.28;
Remove clause 3 and 4 from TNF licenses
 1.1 30-Oct-2002  manu branches: 1.1.2; 1.1.110; 1.1.112; 1.1.114;
Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.1.114.1 16-May-2008  yamt sync with head.
 1.1.112.1 18-May-2008  yamt sync with head.
 1.1.110.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 30-Oct-2002  nathanw file macho_machdep.h was added on branch nathanw_sa on 2002-11-11 22:02:52 +0000
 1.2.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.22.1 31-May-2011  rmind sync with head
 1.5 22-Oct-2014  joerg Support copysignl on PowerPC.
 1.4 19-Feb-2002  simonb branches: 1.4.166; 1.4.184;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.3 05-Feb-2000  kleink branches: 1.3.6; 1.3.10; 1.3.14;
Improve namespace test macros a bit.
 1.2 04-Jan-2000  kleink const -> __const and include <sys/cdefs.h> earlier; fixes PR lib/9052
by Takahiro Kambe.
 1.1 23-Dec-1999  kleink C99: Define a NAN macro in <math.h> which evaulates to a constant expression of
a single-precision quiet NaN; only to be defined on platforms that do support
this value.
 1.3.14.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.10.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 05-Feb-2000  bouyer file math.h was added on branch thorpej_scsipi on 2000-11-20 20:31:10 +0000
 1.4.184.1 25-May-2015  msaitoh Pull up following revision(s) (requested by joerg in ticket #790):
sys/arch/powerpc/include/math.h: revision 1.5
lib/libm/src/namespace.h: revision 1.13
lib/libm/arch/vax/n_support.S: revision 1.10
lib/libm/src/s_copysignl.c: revision 1.3
lib/libm/src/s_copysignl.c: revision 1.4
lib/libm/src/s_copysignl.c: revision 1.5
sys/arch/powerpc/include/ieee.h: revision 1.6
lib/libm/src/s_copysign.c: revision 1.12
lib/libm/src/s_copysign.c: revision 1.13
- Support copysignl on PowerPC.
- Define copysignl on !long double platforms. Be consistent in the use of
weak aliases.
- copysignl is also needed for PowerPC's double-double format, so special
case that. Functional support was added earlier, but not enabled.
 1.4.166.1 03-Dec-2017  jdolecek update from HEAD
 1.26 30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.25 04-Nov-2024  christos Undo previous lwp.h change.
 1.24 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.23 18-May-2024  thorpej branches: 1.23.2;
Clean up the <sys/ucontext.h> <-> <machine/mcontext.h> interface up
a little:
- Define _UC_MD_BIT* constants for the available machine-dependent bits,
and use those constants to define the machine-dependent bits as well
as the machine-independent bits that have machine-dependent values.
- Explicitly generate an error if _UC_TLSBASE, _UC_SETSTACK, or
_UC_CLRSTACK are not defined by <machine/mcontext.h>.
 1.22 04-Oct-2020  rin Add missing __{BEGIN,END}_DECLS in order to catch up with
sanitizer_linux_libcdep.cc rev 1.17:

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

Fix build with HAVE_GCC=9.
 1.21 22-Jun-2020  rin Fix previous; hide userland ABI details for kernel as suggested by joerg:

http://mail-index.netbsd.org/source-changes-d/2020/06/21/msg012745.html

- Revive __lwp_settcb(), and call _lwp_setprivate(2) from it.

- Keep l_private opaque pointer for kernel; store raw value of %r2 in it.
In the previous commit message, I wrote,

http://mail-index.netbsd.org/source-changes/2020/06/21/msg118524.html

> - Make sure that, like other ports, l_private represents address of tcb,
> not biased one as in %r2.

but, it turned out to be wrong. mips stores a biased address, at least.
It is userland responsibility to interpret returned values from
lwp_getprivate(2).
 1.20 21-Jun-2020  rin Fix inconsistency b/w kernel and userland recognitions of TLS, as well as
inconsistency whether it is biased or not in kernel.

- Obsolete __lwp_settcb() in order to let kernel know new TLS address via
_lwp_setprivate(2). Alternatively, we can call _lwp_setprivate(2) within
__lwp_settcb() like mips, but it is just double handling; we adjust %r2
appropriately in _lwp_setprivate(2) via cpu_lwp_setprivate().

- Make sure that, like other ports, l_private represents address of tcb,
not biased one as in %r2. This guarantees that the returned values from
_lwp_getprivate(2) and __lwp_getprivate_fast() are always same. Also,
we can obsolete PTRACE_LWP_GETPRIVATE() macro.

Now, *_pl_private tests in tests/lib/libc/sys successfully pass, while
no other tests become newly falling.
 1.19 21-Jun-2020  rin Fix SS_ONSTACK, which seems like broken since switched to siginfo.

Found by tests/lib/libc/sys/t_sigaltstack, which passes now, while
no other tests are not falling newly.

XXX
Shouldn't we turn _UC_{SET,CLR}STACK into MI?
 1.18 15-Feb-2018  kamil Introduce _UC_MACHINE_FP() as a macro

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

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


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

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

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

Once ia64 will mature, this should be revisited.

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


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

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

Proposed on tech-userlevel@.

Sponsored by <The NetBSD Foundation>
 1.17 12-Aug-2014  joerg branches: 1.17.12;
Avoid unncessary use of double in the kernel. With this change,
a LLVM build kernel fully works on TWRP1025.
 1.16 24-Jul-2014  joerg Let the assembler bail out if the immediate is too large instead of
truncating it.
 1.15 28-Feb-2014  matt branches: 1.15.2;
Add mcontext32_t
 1.14 11-Sep-2012  matt branches: 1.14.2; 1.14.4;
Add support for _UC_TLSBASE. Make sure to preserve backwards compat for
programs built before TLS support was added.
 1.13 12-Mar-2011  matt branches: 1.13.4;
Add __lwp_gettcb_fast and __lwp_settcb helper inline functions
 1.12 25-Feb-2011  joerg Be nicer to software that insists on -ansi and use __inline.
 1.11 24-Feb-2011  joerg Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

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

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.10 01-Feb-2011  matt Fix XER comment.
Add spe variants for vectors.
 1.9 18-Jan-2011  matt branches: 1.9.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.8 28-Apr-2008  martin branches: 1.8.22; 1.8.26; 1.8.28;
Remove clause 3 and 4 from TNF licenses
 1.7 11-Dec-2005  christos branches: 1.7.74; 1.7.76; 1.7.78;
merge ktrace-lwp.
 1.6 08-Oct-2003  thorpej Add some accessor macros for the ucontext:
* _UC_MACHINE_PC() - access the program counter
* _UC_MACHINE_INTRV() - access the integer return value register
* _UC_MACHINE_SET_PC() - set the program counter (this requires
special handling on some platforms).
 1.5 20-Jan-2003  matt branches: 1.5.2;
__greg_t should be an long, not int. (LP64 friendliness)
 1.4 20-Jan-2003  matt Kill all references to struct __gregs and use the _REG_xx names.
 1.3 20-Jan-2003  matt Add _REG_foo to ppc mcontext and use them instead of constants.
 1.2 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 05-Nov-2001  briggs branches: 1.1.2;
file mcontext.h was initially added on branch nathanw_sa.
 1.1.2.4 28-Dec-2001  nathanw Add a macro, _UC_MACHINE_SP(), to fetch the user stack pointer from
a ucontext_t.
 1.1.2.3 14-Nov-2001  briggs Back out last (DUMB!) change.
 1.1.2.2 13-Nov-2001  briggs alias sc_pc for debug pthreads code.
 1.1.2.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.78.1 16-May-2008  yamt sync with head.
 1.7.76.1 18-May-2008  yamt sync with head.
 1.7.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.26.1 11-Jan-2011  matt Add a _UC_POWERPC_SPE bit to indicate the vectors are from SPE.
 1.8.22.2 21-Apr-2011  rmind sync with head
 1.8.22.1 05-Mar-2011  rmind sync with head
 1.9.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.9.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.13.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.4.1 30-Oct-2012  yamt sync with head
 1.14.4.1 18-May-2014  rmind sync with head
 1.14.2.2 03-Dec-2017  jdolecek update from HEAD
 1.14.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.1 10-Aug-2014  tls Rebase.
 1.17.12.3 21-Mar-2018  martin Pull up the following, requested by kamil in ticket #552:

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

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

Add a dummy implementation of _UC_MACHINE_INTRV() for ia64.

Implement _UC_MACHINE_INTRV() for hppa.

Make the t_ucontext.c test more portable.

We now have _UC_MACHINE_FP.
 1.17.12.2 26-Feb-2018  snj revert ticket 552, which broke the build
 1.17.12.1 25-Feb-2018  snj Pull up following revision(s) (requested by kamil in ticket #552):
sys/arch/aarch64/include/mcontext.h: 1.2
sys/arch/alpha/include/mcontext.h: 1.9
sys/arch/amd64/include/mcontext.h: 1.19
sys/arch/arm/include/mcontext.h: 1.19
sys/arch/hppa/include/mcontext.h: 1.9
sys/arch/i386/include/mcontext.h: 1.14
sys/arch/ia64/include/mcontext.h: 1.6
sys/arch/m68k/include/mcontext.h: 1.10
sys/arch/mips/include/mcontext.h: 1.22
sys/arch/or1k/include/mcontext.h: 1.2
sys/arch/powerpc/include/mcontext.h: 1.18
sys/arch/riscv/include/mcontext.h: 1.5
sys/arch/sh3/include/mcontext.h: 1.11
sys/arch/sparc/include/mcontext.h: 1.14-1.17
sys/arch/sparc64/include/mcontext.h: 1.10
sys/arch/vax/include/mcontext.h: 1.9
tests/lib/libc/sys/Makefile: 1.50
tests/lib/libc/sys/t_ucontext.c: 1.2
Introduce _UC_MACHINE_FP() as a macro
_UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer.
Don't rely on this interface as a compiler might strip frame pointer or
optimize it making this interface unreliable.
For hppa assume a small frame context, for larger frames FP might be located
in a different register (4 instead of 3).
For ia64 there is no strict frame pointer, and registers might rotate.
Reuse 79 following:
./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79)
Once ia64 will mature, this should be revisited.
A macro can encapsulate a real function for extracting Frame Pointer on
more complex CPUs / ABIs.
For the remaining CPUs, reuse standard register as defined in appropriate ABI.
The direct users of this macro are LLVM and GCC with Sanitizers.
Proposed on tech-userlevel@.
Sponsored by <The NetBSD Foundation>
--
Improve _UC_MACHINE_FP() for SPARC/SPARC64
Introduce a static inline function _uc_machine_fp() that contains improved
caluclation of a frame pointer.
Algorithm:
uptr *stk_ptr;
# if defined (__arch64__)
stk_ptr = (uptr *) (*sp + 2047);
# else
stk_ptr = (uptr *) *sp;
# endif
*bp = stk_ptr[15];
Noted by <mrg>
--
Make _UC_MACHINE_FP() compile again and fix it so that it does not add
the offset twice.
--
fix _UC_MACHINE32_FP() -- use 32 bit pointer value so that [15] is
the right offset. do this by using __greg32_t, which is only in
the sparc64 version, and these are only useful there, so move them.
--
Add new tests in lib/libc/sys/t_ucontext
New tests:
- ucontext_sp
- ucontext_fp
- ucontext_pc
- ucontext_intrv
They test respectively:
- _UC_MACHINE_SP
- _UC_MACHINE_FP
- _UC_MACHINE_PC
- _UC_MACHINE_INTRV
These tests attempt to access and print the values from ucontext, without
interpreting the values.
This is a follow up of the _UC_MACHINE_FP() introduction.
These tests use PRIxREGISTER, and require to be built with -D_KERNTYPES.
Sponsored by <The NetBSD Foundation>
 1.23.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 12-Jul-2023  riastradh machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

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

XXX pullup-10
 1.6 29-Nov-2019  riastradh branches: 1.6.26;
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.
 1.5 29-Nov-2019  riastradh Nix mb_* on powerpc.
 1.4 28-Apr-2008  martin branches: 1.4.88;
Remove clause 3 and 4 from TNF licenses
 1.3 21-Nov-2007  yamt branches: 1.3.14; 1.3.16; 1.3.18;
make kmutex_t and krwlock_t smaller by killing lock id.
ok'ed by Andrew Doran.
 1.2 09-Feb-2007  ad branches: 1.2.4; 1.2.8; 1.2.24; 1.2.26; 1.2.30; 1.2.32;
Merge newlock2 to head.
 1.1 30-Jan-2007  ad branches: 1.1.2;
file mutex.h was initially added on branch newlock2.
 1.1.2.2 01-Feb-2007  ad Header file cleanup.
 1.1.2.1 30-Jan-2007  ad Add missing headers.
 1.2.32.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.30.1 21-Nov-2007  bouyer Sync with HEAD
 1.2.26.1 09-Jan-2008  matt sync with HEAD
 1.2.24.1 21-Nov-2007  joerg Sync with HEAD.
 1.2.8.1 03-Dec-2007  ad Sync with HEAD.
 1.2.4.3 07-Dec-2007  yamt sync with head
 1.2.4.2 26-Feb-2007  yamt sync with head.
 1.2.4.1 09-Feb-2007  yamt file mutex.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:53 +0000
 1.3.18.1 16-May-2008  yamt sync with head.
 1.3.16.1 18-May-2008  yamt sync with head.
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.26.1 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

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

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

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

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

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

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

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

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

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

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

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

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

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

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

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

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

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

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

ddb: Cast pointer to uintptr_t first before db_expr_t.

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

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

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

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

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

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

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

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

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

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

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

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

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

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

fix hppa and vax builds.

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

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

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

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

re-fix hppa builds.

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

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

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

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

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

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

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

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

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

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

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

Note that fls32 is 1-based and returns 0 for x=0.
 1.8 28-Feb-2014  matt Make this work.
 1.7 20-Jun-2011  matt branches: 1.7.2; 1.7.12; 1.7.16;
<arch/powerpc/... -> <powerpc/...
 1.6 10-Dec-2009  matt branches: 1.6.10;
Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.5 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.4 17-Oct-2007  garbled branches: 1.4.16; 1.4.18; 1.4.20; 1.4.22;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.3 16-Sep-2007  dsl Define netbsd32_uint64 for 64bit integers with the alignment requirement
of the corresponding 32bit architecture.
Use it for the 64bit items in netbsd32_statvfs so that the structure
doesn't collect 8byte alignment (and 4 bytes of trailing padding).
This replaces the 'packed' attribute which wasn't architecture specific
and would cause massive overheads accessing every member of sparc64.
Should allow the MIPS64 port do DTRT.
 1.2 16-Apr-2003  dsl branches: 1.2.18; 1.2.60; 1.2.68; 1.2.78; 1.2.80;
change 'data' arg of fp_ioctl to 'void *' to match file.h
 1.1 05-Feb-2003  matt Needed for compat_netbsd32.
 1.2.80.1 06-Nov-2007  matt sync with HEAD
 1.2.78.1 02-Oct-2007  joerg Sync with HEAD.
 1.2.68.1 03-Oct-2007  garbled Sync with HEAD
 1.2.60.1 09-Oct-2007  ad Sync with head.
 1.2.18.1 27-Oct-2007  yamt sync with head.
 1.4.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.20.2 11-Mar-2010  yamt sync with head
 1.4.20.1 04-May-2009  yamt sync with head.
 1.4.18.1 04-Jun-2008  yamt sync with head
 1.4.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.16.1 18-May-2014  rmind sync with head
 1.7.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5 27-Feb-2021  thorpej Un-do a bunch of misguided code sharing. It's not really shared if it's
full of platform-specific #ifdefs:
- ofwoea_batinit() is gone; just do what's needed early in macppc / ofppc
initppc() functions.
- Get a bunch of Mac-specific stuff out of ofwoea_initppc().
 1.4 04-Jun-2010  chs branches: 1.4.72;
fix some cosmetics.
 1.3 28-Apr-2008  martin branches: 1.3.20; 1.3.22;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 06-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file ofw_bus.h was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.2 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.1.2.1 06-Jun-2007  garbled Add include files for common oea ofw routines
 1.2.26.2 11-Aug-2010  yamt sync with head.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file ofw_bus.h was added on branch matt-armv6 on 2007-11-06 23:20:36 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file ofw_bus.h was added on branch yamt-lazymbuf on 2007-10-27 11:27:46 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file ofw_bus.h was added on branch vmlocking on 2007-10-23 20:36:03 +0000
 1.3.22.1 03-Jul-2010  rmind sync with head
 1.3.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.72.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 01-Jul-2011  dyoung Add new files involved in the bus.h->bus_defs.h/bus_funcs.h split.
 1.2 27-Feb-2021  thorpej Un-do a bunch of misguided code sharing. It's not really shared if it's
full of platform-specific #ifdefs:
- ofwoea_batinit() is gone; just do what's needed early in macppc / ofppc
initppc() functions.
- Get a bunch of Mac-specific stuff out of ofwoea_initppc().
 1.1 01-Jul-2011  dyoung branches: 1.1.66;
Add new files involved in the bus.h->bus_defs.h/bus_funcs.h split.
 1.1.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 13-Feb-2022  martin PR port-macppc/56091: on G5 macs we currently can not easily make
early serial console work, so keep the OF based "failsafe" console
but note that we would like to switch over.
Once zs attaches, use the new device mapping and do a belated init
of the zs console globals, and then switch over to real zs based
serial console.
 1.3 05-Mar-2021  thorpej Separate probing for the console device and initializing it, so that
ofwoea_initppc() can have more control over which of those steps are
performed during initialization. Probing happens before setting up
the exception vectors, initializing happens after.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.126;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 06-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file ofw_cons.h was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1 06-Jun-2007  garbled Add include files for common oea ofw routines
 1.2.126.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file ofw_cons.h was added on branch matt-armv6 on 2007-11-06 23:20:36 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file ofw_cons.h was added on branch yamt-lazymbuf on 2007-10-27 11:27:46 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file ofw_cons.h was added on branch vmlocking on 2007-10-23 20:36:04 +0000
 1.7 21-Sep-2025  thorpej Give each PowerPC OFW platform its own device_register(), which calls
into the common ofw_device_register(). ofppc's is a simple wrapper.

macppc's, on the other hand, takes care of looking up environmental
sensor descriptive information in the OFW device tree and adds those
properties directly to the sensor device property dictionaries. This
single implementation will replace the duplicated code that's scattered
across multiple macppc i2c controller drivers.
 1.6 24-Nov-2022  macallan move ofprint() to powerpc/ofw_machdep.c and make it official
now that console output uses locks it needs more of the kernel to function, so
for now use direct OF calls for earliest debug output
 1.5 02-Nov-2022  andvar fix various typos in comments and messages.
 1.4 02-Mar-2021  thorpej branches: 1.4.4;
- Add a boolean "ofwbootcons_suppress" that, when true, suppresses
ofwbootcons I/O (i.e. "doesn't call into OFW"). This allows
platform code to ensure that early console I/O doesn't occur in certain
critical sections.
- When printing the translations, put phys next to virt for easier
visual comparisons.
 1.3 28-Feb-2021  thorpej Bump OFW_MAX_TRANSLATIONS from 32 -> 48. 32 was already tight (at least
on my Macs), and having having translations for the kernel itself present
in the firmware's translation table bumped it over the 32-entry limit.
 1.2 19-Feb-2021  thorpej Shuffle around a couple of things that aren't particularly OEA-specific:

- Early bootstrap console initialization moves to ofw_machdep.c, and
is called a bit earlier, from ofw_bootstrap().

- Decoding the "translations" property from /chosen/mmu is specified
in the general OpenFirmware PowerPC bindings, and is not specific to
any particular PowerPC flavor. It's now decoded a bit earlier in
ofw_bootstrap().

The *interpretation* of the mode field of a translation is, however,
implementation-specific, so that remains in ofwoea_machdep.c.
 1.1 18-Feb-2021  thorpej Add an ofw_bootstrap() function, called during early bootstrap from
ofwinit() to perform additional early initialization in C code. Use
this to get the memory config while we're still running in the OpenFirmware
client environment, rather than waiting until we've started fiddling with
the system state.
 1.4.4.2 03-Apr-2021  thorpej Sync with HEAD.
 1.4.4.1 02-Mar-2021  thorpej file ofw_machdep.h was added on branch thorpej-futex on 2021-04-03 22:28:34 +0000
 1.8 01-Feb-2012  matt Use C89 function prototypes.
 1.7 14-Mar-2009  dsl branches: 1.7.12; 1.7.16;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.6 17-Oct-2007  garbled branches: 1.6.20; 1.6.28; 1.6.34;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 16-Feb-2006  perry branches: 1.5.24; 1.5.32; 1.5.42; 1.5.44; 1.5.46; 1.5.48;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.4 24-Dec-2005  perry branches: 1.4.2; 1.4.4; 1.4.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 05-Feb-2001  briggs branches: 1.3.2; 1.3.42;
Tsubai has convinced me that openpic_init() should remain machine-dependant
as the details might differ between archs, and passing the various options
leads to some clutter.
 1.2 04-Feb-2001  briggs Build with -Wall -Wetc.
 1.1 02-Feb-2001  briggs Split OpenPIC support into powerpc so ports only need minimal custom
configuration. openpic_init() now takes a single argument that is the
base of the OpenPIC register space.
 1.3.42.1 27-Oct-2007  yamt sync with head.
 1.3.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.1 05-Feb-2001  bouyer file openpic.h was added on branch thorpej_scsipi on 2001-02-11 19:11:34 +0000
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.4.2.1 18-Feb-2006  yamt sync with head.
 1.5.48.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.46.1 18-Oct-2007  yamt sync with head.
 1.5.44.1 06-Nov-2007  matt sync with HEAD
 1.5.42.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.32.1 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.5.24.1 23-Oct-2007  ad Sync with head.
 1.6.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.20.1 04-May-2009  yamt sync with head.
 1.7.16.1 18-Feb-2012  mrg merge to -current.
 1.7.12.1 17-Apr-2012  yamt sync with head
 1.8 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.7 17-Oct-2007  garbled branches: 1.7.2; 1.7.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 11-Dec-2005  christos branches: 1.6.30; 1.6.38; 1.6.48; 1.6.50; 1.6.52; 1.6.54;
merge ktrace-lwp.
 1.5 13-Feb-2004  wiz branches: 1.5.16;
Uppercase CPU, plural is CPUs.
 1.4 06-Aug-2002  chs branches: 1.4.6;
fix the calculation of the address of the IPI dispatch register.
 1.3 30-Aug-2001  briggs branches: 1.3.6; 1.3.14;
defines for OPENPIC_ICR / serial mode.
 1.2 05-Feb-2001  briggs branches: 1.2.2; 1.2.6;
Tsubai has convinced me that openpic_init() should remain machine-dependant
as the details might differ between archs, and passing the various options
leads to some clutter.
 1.1 02-Feb-2001  briggs Split OpenPIC support into powerpc so ports only need minimal custom
configuration. openpic_init() now takes a single argument that is the
base of the OpenPIC register space.
 1.2.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.6.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.1 05-Feb-2001  bouyer file openpicreg.h was added on branch thorpej_scsipi on 2001-02-11 19:11:35 +0000
 1.3.14.1 31-Aug-2002  gehenna catch up with -current.
 1.3.6.2 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.3.6.1 30-Aug-2001  nathanw file openpicreg.h was added on branch nathanw_sa on 2002-08-06 22:47:09 +0000
 1.4.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.6.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.2 21-Jan-2008  yamt sync with head
 1.5.16.1 27-Oct-2007  yamt sync with head.
 1.6.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.52.1 18-Oct-2007  yamt sync with head.
 1.6.50.2 23-Mar-2008  matt sync with HEAD
 1.6.50.1 06-Nov-2007  matt sync with HEAD
 1.6.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.38.1 10-Oct-2007  garbled Change pic_prepivr around a bit. Handle the default IRQ 7 from the 8259
better, and add a new motivr_get_irq(). The motorola machines require an
actual read from the 8259 for PCI irqs, so in that case, we read the
8259, and then read the IVR to ack the irq.

Move i8259_get_irq() to i8259_common.c for above.

Fix some minor typos in the chip id's for prep residual.

Fix ibmnws and prep to properly initialize the prep ivr depending on if
the machine is motorola, or IBM based.

Tested on a 7043 and an MTX604
 1.6.30.1 23-Oct-2007  ad Sync with head.
 1.7.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.7.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.34 31-May-2021  simonb Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include <machine/param.h>.
 1.33 06-Jul-2020  rin branches: 1.33.6;
Style and cosmetic changes. No binary changes intended.
 1.32 21-Feb-2020  rin Reduce UPAGES from 2 to 1 for ibm4xx, which was originally 1 and bumped
to 2 in rev 1.29:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/include/param.h#rev1.29

Since page size is 16KB on ibm4xx, USPACE is still 16KB, which is the
same size as on other powerpc processors.

This avoids kernel crash described in PR kern/54994. Also, even if the
PR is resolved, fork(2) easily fails with ENOMEM if UPAGES is 2, which
requires physically contiguous pages for u-area. No bad side effect is
observed as far as I can see.

XXX
Even with this commit, kern/54994 still critically affects other archs
with __HAVE_CPU_UAREA_ROUTINES, i.e., alpha, mips, powerpc/{oea,booke},
and riscv.
 1.31 07-Jan-2019  jdolecek branches: 1.31.6;
move DEV_BSIZE, DEV_BSHIFT out of MD param.h, they are same on all ports

also move BLKDEV_IOSIZE, MAXPHYS, but allow override since some ports
have different value (powerpc uses NBPG for BLKDEV_IOSIZE, sun2/sun3
have lower MAXPHYS)
 1.30 14-Jan-2017  christos branches: 1.30.14; 1.30.16;
belatedly fix constants for ppc64 (this does not define __arch64__ like sparc
does?)
 1.29 29-Jan-2013  kiyohara branches: 1.29.14; 1.29.18;
More stack for ibm4xx slow machines.
 1.28 23-Sep-2012  mrg increase powerpc NKMEMPAGES_MAX_DEFAULT to 256MB. remove the macppc
overrides that are now the same as the powerpc default.
 1.27 30-Jan-2012  matt branches: 1.27.2; 1.27.4; 1.27.6;
PowerPC wants 16-byte aligned stacks (for AltiVec).
 1.26 24-Jan-2012  christos Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently,
and avoid definining them in 10 different places if not needed.
 1.25 20-Jan-2012  joerg Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.24 20-Jun-2011  matt branches: 1.24.2; 1.24.6;
Cleanup powerpc param.h. If compiling a MODULE, ignore port-specific stuff.
Only include <machine/cpu.h> in <powerpc/param.h> at the end.
 1.23 05-Mar-2011  matt branches: 1.23.2;
If _KERNEL is not defined, force MACHINE to be "powerpc". Userland should be
using uname/sysctl to get this value.
 1.22 22-Mar-2010  mrg branches: 1.22.2;
default powerpc64 mbufs to 512 bytes, like other 64 bit platforms.
from dennis.c.ferguson@gmail.com in PR#43028.
 1.21 08-Feb-2010  joerg branches: 1.21.2;
Remove separate mb_map. The nmbclusters is computed at boot time based
on the amount of physical memory and limited by NMBCLUSTERS if present.
Architectures without direct mapping also limit it based on the kmem_map
size, which is used as backing store. On i386 and ARM, the maximum KVA
used for mbuf clusters is limited to 64MB by default.

The old default limits and limits based on GATEWAY have been removed.
key_registered_sb_max is hard-wired to a value derived from 2048
clusters.
 1.20 28-Aug-2006  yamt branches: 1.20.60; 1.20.80;
- remove unused bdbtofsb.
- move the following macros from MD headers to sys/param.h.
ctod
dtoc
ctob
btoc
dbtob
btodb
 1.19 11-Dec-2005  christos branches: 1.19.4; 1.19.8;
merge ktrace-lwp.
 1.18 09-Dec-2004  matt branches: 1.18.10;
Make MSIZE and MCLSHIFT overrideable in <machine/param.h>
 1.17 04-Mar-2003  matt branches: 1.17.2;
Re-arrange things in evbppc & powerpc to support OEA-based eval boards
in evbppc. OEA-based board(s) to be added later.
 1.16 03-Feb-2003  matt More cleanup for OLDPMAP.
 1.15 19-Jan-2003  matt ALIGN should use u_long, not u_int
 1.14 06-Sep-2002  matt Allow MAXPHYS to be overriden. Increase the default MSGBUFSIZE to 2 pages.
 1.13 09-Mar-2002  chs switch all mpc6xx powerpc ports to NEWPMAP by default.
the old pmap is still available with the OLDPMAP option.
 1.12 10-Jun-2001  tsubai branches: 1.12.2; 1.12.8;
Make the new pmap optional. Use the old (stable!) pmap by default.
 1.11 10-Jun-2001  briggs Up the default # of NMBCLUSTERS to 2048 (GATEWAY) & 1024 (non-GATEWAY)
from 512/256.
 1.10 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.9 30-May-2001  mrg use _KERNEL_OPT
 1.8 30-Jun-2000  itojun branches: 1.8.2;
raise MSIZE from 128 to 256.
- for sizeof(void *) == 8 arch, this is mandatory. MHLEN is too small
already (less than 80) and there are chances for unwanted packet loss due
to m_pullup restriction.
- for other cases, the change should avoid allocating clusters in most cases
(even when you have IPv4 IPsec tunnel, or IPv6 with moderate amount of
extension header)

portmasters: if your arch chokes with the change (high memory usage or
whatever), please backout the change for your arch.
 1.7 11-Feb-2000  thorpej branches: 1.7.4;
Update for the NKMEMPAGES changes.
 1.6 04-Dec-1999  ragge CL* discarding.
 1.5 16-Aug-1998  wrstuden branches: 1.5.12; 1.5.18;
As ovbcopy & bcopy are now done in terms of mem* routines, it makes
no sense to "#define ovbcopy bcopy".
 1.4 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.3 29-Apr-1998  thorpej Pull in opt_gateway.h as appropriate.
 1.2 24-Feb-1997  fvdl Define ALIGNED_POINTER
 1.1 30-Sep-1996  ws branches: 1.1.6;
PowerPC port
 1.1.6.1 12-Mar-1997  is Merge in changes from Trunk
 1.5.18.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.18.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.5.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.4.1 23-Jul-2000  itojun pullup from main trunc (approved by releng-1-5)

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

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

1.1 -> 1.2 syssrc/sys/arch/amigappc/include/param.h
1.13 -> 1.14 syssrc/sys/arch/arc/include/param.h
1.1 -> 1.2 syssrc/sys/arch/arm26/include/param.h
1.17 -> 1.18 syssrc/sys/arch/arm32/include/param.h
1.6 -> 1.7 syssrc/sys/arch/bebox/include/param.h
1.4 -> 1.5 syssrc/sys/arch/cobalt/include/param.h
1.4 -> 1.5 syssrc/sys/arch/evbsh3/include/param.h
1.2 -> 1.3 syssrc/sys/arch/hpcmips/include/param.h
1.40 -> 1.41 syssrc/sys/arch/i386/include/param.h
1.7 -> 1.8 syssrc/sys/arch/m68k/include/param.h
1.9 -> 1.10 syssrc/sys/arch/macppc/include/param.h
1.4 -> 1.5 syssrc/sys/arch/mmeye/include/param.h
1.6 -> 1.7 syssrc/sys/arch/newsmips/include/param.h
1.7 -> 1.8 syssrc/sys/arch/ofppc/include/param.h
1.23 -> 1.24 syssrc/sys/arch/pc532/include/param.h
1.32 -> 1.33 syssrc/sys/arch/pmax/include/param.h
1.7 -> 1.8 syssrc/sys/arch/powerpc/include/param.h
1.1 -> 1.2 syssrc/sys/arch/prep/include/param.h
1.1 -> 1.2 syssrc/sys/arch/sgimips/include/param.h
1.3 -> 1.4 syssrc/sys/arch/sh3/include/param.h
1.44 -> 1.45 syssrc/sys/arch/sparc/include/param.h
1.21 -> 1.22 syssrc/sys/arch/sparc64/include/param.h
1.43 -> 1.44 syssrc/sys/arch/vax/include/param.h
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.12.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.8.1 10-Jun-2001  nathanw file param.h was added on branch nathanw_sa on 2002-04-01 07:42:04 +0000
 1.12.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.17.2.1 18-Dec-2004  skrll Sync with HEAD.
 1.18.10.1 30-Dec-2006  yamt sync with head.
 1.19.8.1 03-Sep-2006  yamt sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.20.80.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.20.60.2 11-Aug-2010  yamt sync with head.
 1.20.60.1 11-Mar-2010  yamt sync with head
 1.21.2.2 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.21.2.1 30-May-2010  rmind sync with head
 1.22.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.23.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.24.6.1 18-Feb-2012  mrg merge to -current.
 1.24.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.24.2.2 30-Oct-2012  yamt sync with head
 1.24.2.1 17-Apr-2012  yamt sync with head
 1.27.6.3 03-Dec-2017  jdolecek update from HEAD
 1.27.6.2 25-Feb-2013  tls resync with head
 1.27.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.27.4.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.27.2.1 01-Oct-2012  riz Pull up following revision(s) (requested by mrg in ticket #575):
sys/arch/powerpc/include/param.h: revision 1.28
sys/arch/macppc/include/param.h: revision 1.20
increase powerpc NKMEMPAGES_MAX_DEFAULT to 256MB. remove the macppc
overrides that are now the same as the powerpc default.
 1.29.18.1 20-Mar-2017  pgoyette Sync with HEAD
 1.29.14.1 05-Feb-2017  skrll Sync with HEAD
 1.30.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.30.16.1 10-Jun-2019  christos Sync with HEAD
 1.30.14.1 18-Jan-2019  pgoyette Synch with HEAD
 1.31.6.1 29-Feb-2020  ad Sync with head.
 1.33.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.23 27-Oct-2021  christos Need frame.h
 1.22 18-Jan-2011  matt 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.21 24-Dec-2005  perry branches: 1.21.100; 1.21.104; 1.21.106;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.20 11-Dec-2005  christos merge ktrace-lwp.
 1.19 22-Feb-2005  matt branches: 1.19.4;
Don't clear PCB_FPU/PCB_ALTIVEC when releasing the FPU/AltiVec unit. Add
new flags to indicate whether the PCB currently owns the FPU/AltiVec unit.
 1.18 16-Apr-2004  matt branches: 1.18.4; 1.18.6;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.17 04-Apr-2004  matt The FP exception mode bits from the MSR will be stored in pcb_flags. From
there, they will copied to MSR as needed (when FP is enabled). They will be
cleared from the MSR when the lwp loses the FPU. Hence they need to be stored
someplace else.
 1.16 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.15 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.14 05-Mar-2003  matt branches: 1.14.2;
Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.13 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.12 19-Jan-2003  matt Cast to register_t instead of int to be nicer for LP64.
Simplify copyin/copyout/copyinstr/copyoutstr. Fix bug
where the user virtual address was not updated so that
if the user's buffer crossed a segment boundary, the
wrong data could be copied. Localize USER_SR to the
ILP32 version of setusr/unsetusr.
 1.11 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.10 28-Jul-2002  chs rearrange the PCB structure a bit so it's easier to look at in ddb.
 1.9 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.8 30-Apr-2001  martin branches: 1.8.2; 1.8.8; 1.8.16;
Avoid nesting structure declarations, where the nested structur is used at
the global level later. Besides stylistic matters, this actually breaks C++
programs (indirectly) using this header.
 1.7 22-Mar-2001  tsubai Merge my MP tree. At this point, Daystar dual 604 card (i.e. Power Macintosh
9500/180MP and 9600/200MP) runs at least into single-user mode, possibly
multi-user mode (not stable yet).
 1.6 25-Nov-2000  matt branches: 1.6.2;
Preliminary AltiVec support.
 1.5 06-Jul-2000  tsubai Make it compile with "options MULTIPROCESSOR".
 1.4 04-Jun-2000  tsubai branches: 1.4.2;
Add fpreg area in struct md_coredump.
 1.3 07-Dec-1999  danw branches: 1.3.2;
Fix "FPCSR" to "FPSCR". ("Floating Point Status and Control Register")
 1.2 22-Nov-1998  ws branches: 1.2.10; 1.2.16;
The last fix in trap.c missed R2.
And correct the size of the fault buffer while being here.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.10.3 27-Mar-2001  bouyer Sync with HEAD.
 1.2.10.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.4.2.1 01-May-2001  he Pull up revision 1.8 (via patch, requested by martin):
Avoid nesting structure declarations, to be friendly to C++ code.
 1.6.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.8.16.2 31-Aug-2002  gehenna catch up with -current.
 1.8.16.1 16-Jul-2002  gehenna catch up with -current.
 1.8.8.4 11-Nov-2002  nathanw Catch up to -current
 1.8.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.8.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.8.8.1 30-Apr-2001  briggs file pcb.h was added on branch nathanw_sa on 2001-11-05 19:46:17 +0000
 1.8.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.4.1 29-Apr-2005  kent sync with -current
 1.19.4.1 21-Jun-2006  yamt sync with head.
 1.21.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.104.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.21.104.1 07-Jan-2011  matt Extend faultbuf to include msr. Add a holder for usprg0
 1.21.100.1 05-Mar-2011  rmind sync with head
 1.15 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.14 19-Oct-2016  nonaka branches: 1.14.14;
Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.13 29-Mar-2014  christos branches: 1.13.6; 1.13.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.12 17-Aug-2011  matt branches: 1.12.2; 1.12.12; 1.12.16;
First pass of the new PCI MSI/MSI ABI definitions. (return EOPNOTSUPP for
now).
 1.11 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.10 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.9 13-Dec-2010  matt branches: 1.9.2;
Change definition of pc_bus_maxdevs to get a void * instead a pci_chipset_tag_t
to match its use in pci_bus_maxdevs. This makes it the same as pci_conf_read
and pci_conf_write.
Change all struct device * to device_t.
[Obviously nothing ever used the first argument to pc_bus_maxdevs since it
could have never worked because it wasn't being passed a pci_chipset_tag_t.]
 1.8 28-Apr-2008  martin branches: 1.8.22; 1.8.26;
Remove clause 3 and 4 from TNF licenses
 1.7 17-Jan-2008  garbled branches: 1.7.6; 1.7.8; 1.7.10;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.6 26-Dec-2007  mrg move
extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
where everyone can see it. fixes ofppc builds.
 1.5 25-Dec-2007  macallan get rid of macppc's private pci_bus_dma_tag
 1.4 26-Oct-2007  garbled branches: 1.4.2; 1.4.4; 1.4.6; 1.4.8; 1.4.12;
Add code to properly detect the interrupt mapping on the PegasosII, and any
other OFW machine that fails our first two methods.
 1.3 25-Oct-2007  garbled Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.2 17-Oct-2007  garbled branches: 1.2.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 01-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file pci_machdep.h was initially added on branch ppcoea-renovation.
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.6 21-Jun-2007  garbled Adapt for addition of pci_machdep_ofw.c
 1.1.2.5 09-May-2007  garbled Convert pmppc to generic pci. Also fix the prototype for
pci_conf_interrupt while I'm here.
 1.1.2.4 08-May-2007  rjs Move declarations to header.
 1.1.2.3 06-May-2007  macallan switch macppc over to generic PCI code from arch/powerpc/pci
 1.1.2.2 01-May-2007  garbled Add a generic pci_intr_map() function (looks like macppc and ibmnws use this)
 1.1.2.1 01-May-2007  garbled Add the generic pci_machdep.h header file, which allows a port to use the
generic pci functions.
 1.2.2.4 03-Dec-2007  ad Sync with HEAD.
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pci_machdep.h was added on branch vmlocking on 2007-10-23 20:36:04 +0000
 1.4.12.2 19-Jan-2008  bouyer Sync with HEAD
 1.4.12.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.8.1 26-Dec-2007  ad Sync with head.
 1.4.6.4 23-Mar-2008  matt sync with HEAD
 1.4.6.3 09-Jan-2008  matt sync with HEAD
 1.4.6.2 06-Nov-2007  matt sync with HEAD
 1.4.6.1 26-Oct-2007  matt file pci_machdep.h was added on branch matt-armv6 on 2007-11-06 23:20:37 +0000
 1.4.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.2.3 21-Jan-2008  yamt sync with head
 1.4.2.2 27-Oct-2007  yamt sync with head.
 1.4.2.1 26-Oct-2007  yamt file pci_machdep.h was added on branch yamt-lazymbuf on 2007-10-27 11:27:48 +0000
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.26.1 07-Jan-2011  matt Change bus_maxdevs to be passed pc->pc_conf_v instead pc (e.g. like the
rest of the conf calls).
 1.8.22.2 21-Apr-2011  rmind sync with head
 1.8.22.1 05-Mar-2011  rmind sync with head
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.16.1 18-May-2014  rmind sync with head
 1.12.12.2 03-Dec-2017  jdolecek update from HEAD
 1.12.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.13.6.1 05-Dec-2016  skrll Sync with HEAD
 1.14.14.1 22-Apr-2018  pgoyette Sync with HEAD
 1.10 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.9 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.8 20-Feb-2020  rin eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.7 30-Jan-2012  matt branches: 1.7.48; 1.7.52; 1.7.54;
Switch to using ANSI prototypes.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.16;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.5 16-Feb-2006  perry branches: 1.5.72; 1.5.80; 1.5.86;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.4 24-Dec-2005  perry branches: 1.4.2; 1.4.4; 1.4.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.3 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 27-May-2001  matt branches: 1.2.8; 1.2.40;
Change _MACHINE_PIO_H to _POWERPC_PIO_H
 1.1 05-Feb-2001  briggs branches: 1.1.2; 1.1.4;
Share a single pio.h instead of having 4 nearly-identical copies.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 05-Feb-2001  bouyer file pio.h was added on branch thorpej_scsipi on 2001-02-11 19:11:35 +0000
 1.2.40.1 21-Jun-2006  yamt sync with head.
 1.2.8.2 27-May-2001  matt Change _MACHINE_PIO_H to _POWERPC_PIO_H
 1.2.8.1 27-May-2001  matt file pio.h was added on branch nathanw_sa on 2001-05-27 20:59:16 +0000
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.4.2.1 18-Feb-2006  yamt sync with head.
 1.5.86.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.80.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.72.1 04-May-2009  yamt sync with head.
 1.6.16.1 18-Feb-2012  mrg merge to -current.
 1.6.12.1 17-Apr-2012  yamt sync with head
 1.7.54.1 29-Feb-2020  ad Sync with head.
 1.7.52.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #730):

sys/arch/powerpc/conf/files.powerpc: revision 1.93
sys/arch/powerpc/include/pio.h: revision 1.8
sys/arch/powerpc/pic/intr.c: revision 1.27
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.50
sys/arch/powerpc/powerpc/pio_subr.S: revision 1.17

Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)

-

eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.7.48.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.43 15-Dec-2023  rin powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.

Part of PR kern/57621
 1.42 07-May-2022  rin branches: 1.42.4;
Try to fix PV tracking support.

* For oea (with real PV tracking support):

Define __HAVE_PMAP_PV_TRACK. Otherwise, pmap_pv_init() is not called by
uvm_init().

* For booke and ibm4xx (without PV tracking support):

For MODULAR kernel and modules, define __HAVE_PMAP_PV_TRACK together with
PMAP_PV_TRACK_ONLY_STUBS, so that modules can be shared with oea.

Note that PMAP_PV_TRACK_ONLY_STUBS can be used even for oea,
as a compile-time option to strip real PV tracking support.
 1.41 16-Feb-2022  riastradh powerpc: Implement pv-tracking for unmanaged pages.

Needed for drm.
 1.40 06-Jul-2020  rin Fix comments. No binary changes.
 1.39 27-Jun-2020  rin Fix MODULAR support for ibm4xx by providing __nothing as VM_MDPAGE_INIT().
 1.38 20-Jun-2011  matt Readd powerpc/include/vmparam.h to the set lists
Export it to powerpc/include.h
Protect pmap.h and vmparam.h from getting an #error when included
from userland.
Export safe definitions of VM_MAXUSER_ADDRESS, VM_MIN_ADDRESS,
VM_MAX_ADDRESS when _RUMPKERNEL is defined.
 1.37 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.36 20-Jun-2011  matt Add #error for unknown PPC variant
Now that oea calls cpu_fixup_stubs, we don't need pmap_fixup_stubs.
 1.35 09-Mar-2010  matt branches: 1.35.8;
Include BookE version of pmap.h
 1.34 09-Dec-2008  pooka branches: 1.34.4;
Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

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

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.33 05-Aug-2006  sanjayl branches: 1.33.58; 1.33.62; 1.33.68; 1.33.70; 1.33.82;
1st cut of Powermac G5 support (uses bridge mode).
 1.32 05-Feb-2003  matt branches: 1.32.18; 1.32.32; 1.32.36;
Don't define pmap_t if _LOCORE is defined.
 1.31 04-Feb-2003  matt LKM's need a pmap_t typedef but there's no PPC_xxx to defined which pmap.h
to include. So just declare the pmap_t and don't do anything else.
 1.30 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.29 03-Feb-2003  matt More cleanup for OLDPMAP.
 1.28 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.27 22-Sep-2002  chs it really helps to get the stub right before cutting + pasting it 27 times.
alas, I did not. doh.
 1.26 22-Sep-2002  chs add pmap_remove_all() hook (empty on most platforms so far).
 1.25 23-Sep-2001  chs branches: 1.25.4;
implement pmap_wired_count().
 1.24 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.23 10-Jun-2001  tsubai branches: 1.23.2; 1.23.4;
Make the new pmap optional. Use the old (stable!) pmap by default.
 1.22 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.21 22-Apr-2001  thorpej Undo a misguided previous change to the pmap_update() API.
 1.20 22-Apr-2001  thorpej Give pmap_update() an argument (a pmap_t) so that it knows which
pmap it should be updating.
 1.19 21-Apr-2001  thorpej #define away pmap_update() in <machine/pmap.h> so that no function
call overhead is incurred as we start sprinkling pmap_update() calls
throughout the source tree (no pmaps currently defer operations, but
we are adding the infrastructure to allow them to do so).
 1.18 04-Feb-2001  briggs branches: 1.18.2;
Build with -Wall -Wetc.
 1.17 30-Mar-2000  jdolecek Prototype vtophys() before defining it. Needed for compilation with
-Wstrict prototypes on macppc.

Problem noted by Hans-Christian Becker <hcb@phc.chalmers.se> in private mail.
 1.16 12-Sep-1999  chs branches: 1.16.2;
eliminate the PMAP_NEW option by making it required for all ports.
ports which previously had no support for PMAP_NEW now implement
the pmap_k* interfaces as wrappers around the non-k versions.
 1.15 11-Jul-1999  tsubai Adapt pmap_extract() change.
 1.14 08-Jul-1999  thorpej Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.13 17-Jun-1999  thorpej pmap_change_wiring() -> pmap_unwire().
 1.12 16-Apr-1999  thorpej Use the same hack as pmap_zero_page() and pmap_copy_page() to provide
direct-mapped pool pages.
 1.11 05-Mar-1999  tsubai branches: 1.11.4;
Add RSS accounting.
 1.10 26-Feb-1999  tsubai Implement pmap_procwr().
(Not tested. gdb doesn't work on powerpc yet.)
 1.9 01-Sep-1998  tsubai Add some prototypes.
 1.8 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.7 25-Jul-1998  tsubai Make vtophys() return non-zero even if the addr < end.
 1.6 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.5 06-Jan-1998  thorpej Don't need __VM_PMAP_HACK anymore.
 1.4 03-Jan-1998  thorpej Now that all ports have pmap_activate(), and it has an identical interface,
prototype it in <vm/pmap.h>
 1.3 02-Jan-1998  thorpej Implement pmap_activate().
 1.2 16-May-1997  gwr Add #define __VM_PMAP_HACK as a temporary measure.
 1.1 30-Sep-1996  ws PowerPC port
 1.11.4.2 02-Aug-1999  thorpej Update from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.2.3 23-Apr-2001  bouyer Sync with HEAD.
 1.16.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.16.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.23.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.23.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.23.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.23.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.25.4.3 11-Nov-2002  nathanw Catch up to -current
 1.25.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.25.4.1 23-Sep-2001  nathanw file pmap.h was added on branch nathanw_sa on 2002-10-18 02:39:31 +0000
 1.32.36.1 11-Aug-2006  yamt sync with head
 1.32.32.1 09-Sep-2006  rpaulo sync with head
 1.32.18.1 30-Dec-2006  yamt sync with head.
 1.33.82.1 07-Jan-2011  matt Add booke support.
 1.33.70.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.68.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.33.62.2 11-Mar-2010  yamt sync with head
 1.33.62.1 04-May-2009  yamt sync with head.
 1.33.58.1 17-Jan-2009  mjf Sync with HEAD.
 1.34.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.35.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.42.4.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.2 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

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

* Removes the PMC code of ARM XSCALE.

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

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

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

* Removes the pmc_evid_t and pmc_ctr_t types.

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

pmc(9) is meant to be a general interface. Initially, the Intel XScale
counters are the only ones supported.
 1.1.204.1 10-Jun-2019  christos Sync with HEAD
 1.1.202.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 07-Aug-2002  jdolecek file pmc.h was added on branch kqueue on 2002-09-06 08:39:15 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 07-Aug-2002  gehenna file pmc.h was added on branch gehenna-devsw on 2002-08-31 13:45:46 +0000
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 07-Aug-2002  nathanw file pmc.h was added on branch nathanw_sa on 2002-08-13 02:18:45 +0000
 1.3 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 31-Jan-1997  thorpej Declare booted_device and booted_partition as "extern".
 1.1 30-Sep-1996  ws branches: 1.1.2;
PowerPC port
 1.1.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.4 27-Feb-2021  thorpej Don't put #ifdefs in prep_initppc(). Instead, let callers specify the
additional BAT-mapped regions they care about.
 1.3 28-Apr-2008  martin branches: 1.3.100;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 09-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file prep_bus.h was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1 09-May-2007  garbled Add a prep_bus.h and prep_machdep.c. These files contain a number of
common routines that all machines with a PReP memory map should have in
common. Note that the machine does not need to be a fully PReP compliant
machine to use these functions, just use the memory map.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file prep_bus.h was added on branch matt-armv6 on 2007-11-06 23:20:38 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file prep_bus.h was added on branch yamt-lazymbuf on 2007-10-27 11:27:48 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file prep_bus.h was added on branch vmlocking on 2007-10-23 20:36:05 +0000
 1.3.100.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 01-Jul-2011  dyoung Add new files involved in the bus.h->bus_defs.h/bus_funcs.h split.
 1.2 27-Feb-2021  thorpej Don't put #ifdefs in prep_initppc(). Instead, let callers specify the
additional BAT-mapped regions they care about.
 1.1 01-Jul-2011  dyoung branches: 1.1.66;
Add new files involved in the bus.h->bus_defs.h/bus_funcs.h split.
 1.1.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15 07-Mar-2021  rin For _LP64, disable members of struct mdproc just for compatible with
booke and ibm4xx, even if MODULAR or _MODULE is defined.

Fix build failure for evbppc64 due to CTASSERT in COND_SET_STRUCT,
which restricts sizeof(struct mdproc) < 31 for unknown reason...
 1.14 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.13 23-Aug-2013  matt branches: 1.13.42;
Get rid of MDLWP_USED{FPU,VEC}
 1.12 05-Jun-2011  matt branches: 1.12.2; 1.12.12; 1.12.16;
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.11 02-May-2011  matt branches: 1.11.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.10 18-Jan-2011  matt 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.9 14-Jan-2011  rmind branches: 1.9.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.8 21-Nov-2009  rmind branches: 1.8.4;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.7 16-Nov-2007  skrll branches: 1.7.18; 1.7.40;
s/proc/lwp/ in comment
 1.6 11-Dec-2005  christos branches: 1.6.30; 1.6.48; 1.6.50; 1.6.54; 1.6.56;
merge ktrace-lwp.
 1.5 10-Jul-2005  christos No point in declaring syscall_intern and syscall in a zillion places.
 1.4 18-Jan-2003  thorpej branches: 1.4.2; 1.4.18;
Merge the nathanw_sa branch.
 1.3 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.2 16-Apr-1997  thorpej branches: 1.2.36; 1.2.40; 1.2.48;
s/dummy/md_proc/
 1.1 30-Sep-1996  ws PowerPC port
 1.2.48.1 16-Jul-2002  gehenna catch up with -current.
 1.2.40.2 01-Aug-2002  nathanw Catch up to -current.
 1.2.40.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.2.36.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.18.2 07-Dec-2007  yamt sync with head
 1.4.18.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.56.1 19-Nov-2007  mjf Sync with HEAD.
 1.6.54.1 18-Nov-2007  bouyer Sync with HEAD
 1.6.50.1 09-Jan-2008  matt sync with HEAD
 1.6.48.1 21-Nov-2007  joerg Sync with HEAD.
 1.6.30.1 03-Dec-2007  ad Sync with HEAD.
 1.7.40.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.7.18.1 11-Mar-2010  yamt sync with head
 1.8.4.3 12-Jun-2011  rmind sync with head
 1.8.4.2 31-May-2011  rmind sync with head
 1.8.4.1 05-Mar-2011  rmind sync with head
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.16.1 28-Aug-2013  rmind sync with head
 1.12.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.42.1 03-Apr-2021  thorpej Sync with HEAD.
 1.10 02-Nov-2021  ryo fix profiling kernel build
 1.9 12-Sep-2013  joerg Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
 1.8 29-Apr-2011  matt branches: 1.8.4; 1.8.14; 1.8.18;
Use the wrtee inlines for booke.
 1.7 07-Jul-2006  ross branches: 1.7.84; 1.7.88; 1.7.90;
Add _LP64 version of _mcount for ppc64
 1.6 07-Feb-2002  briggs branches: 1.6.32; 1.6.46; 1.6.50; 1.6.58;
Update from thorpej:
* Define type and size of _mcount stub to make PIC code happy.
* Rename mcount to __mcount to get it out of the user namespace.
 1.5 18-Apr-2000  tsubai branches: 1.5.8; 1.5.12;
Make kernel profiling work.
 1.4 05-Mar-1999  tsubai branches: 1.4.8;
First-cut of profiling support.
XXX userland only, for now.
 1.3 16-Apr-1997  thorpej Yow, "what happened"? Anyhow, correct apparerent CVS botch, and fix
RCS ID.
 1.2 16-Apr-1997  thorpej Minimal profiling definitions - profiling doens't yet work.
 1.1 30-Sep-1996  ws PowerPC port
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.58.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.50.1 11-Aug-2006  yamt sync with head
 1.6.46.1 09-Sep-2006  rpaulo sync with head
 1.6.32.1 30-Dec-2006  yamt sync with head.
 1.7.90.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.88.1 18-Feb-2011  matt For BookE, PSL_DR/PSL_IR will never be set so we need our own MCOUNT_ENTER
MCOUNT_EXIT. And if we need to do that, might as well use wrtee to the work
(which will emit the right wrtee/wrteei instructions).
 1.7.84.1 31-May-2011  rmind sync with head
 1.8.18.1 18-May-2014  rmind sync with head
 1.8.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23 08-Feb-2024  andvar fix misplaced or missing "e" in words with "ment" ending (argument, implement,
increment, decrement, alignment), in comments, documentation, log messages.
 1.22 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.21 06-Jul-2020  rin branches: 1.21.2;
Style and cosmetic changes. No binary changes intended.
 1.20 06-Jul-2015  matt Remove PSL_SPV from BOOKE PSL_USERMOD
 1.19 28-Feb-2014  matt branches: 1.19.4; 1.19.6;
support PPC_OEA64
 1.18 20-Jun-2011  matt branches: 1.18.2; 1.18.8; 1.18.12; 1.18.16;
Fixup PSL handling to be tolerant of modules. Move evbppc psl changes
into powerpc psl.h
 1.17 02-May-2011  matt branches: 1.17.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.16 18-Jan-2011  matt 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.15 09-Mar-2010  matt branches: 1.15.2; 1.15.4;
Add BookE variation of MSR.
 1.14 05-Aug-2006  sanjayl branches: 1.14.62; 1.14.82; 1.14.86;
1st cut of Powermac G5 support (uses bridge mode).
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8;
merge ktrace-lwp.
 1.12 26-Jun-2004  kleink branches: 1.12.12;
On OEA, turn PSL_USER* into runtime values appropriate for the CPU model
we're executing on; besides dealing with the bits not implemented in the
601's MSR it also removes the silent failure behaviour when passing
PSL_VEC set on a CPU not implementing it.

Also, fix those masks for the 4xx again.
 1.11 26-Jun-2004  kleink Repair a sentence.
 1.10 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.9 04-Apr-2004  matt Be a lot more explicit about the MSR bits a user process can change.
 1.8 31-Jul-2003  matt add PSL_TGPR (for MPC603)
 1.7 14-Feb-2003  matt branches: 1.7.2;
Add PSL_PM
 1.6 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.5 19-Nov-2000  matt branches: 1.5.8;
Add AltiVec VEC bit.
 1.4 13-Feb-2000  tsubai Fix typo in comment.
 1.3 18-Dec-1999  thorpej Comment the MSR bits, and note which ones are not present on the PowerPC 601.
 1.2 16-Apr-1997  thorpej branches: 1.2.22; 1.2.28;
Garbage collect stuff now hidden my machine_vec.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.28.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.22.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.8.1 11-Nov-2002  nathanw Catch up to -current
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.12.1 30-Dec-2006  yamt sync with head.
 1.13.8.1 11-Aug-2006  yamt sync with head
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.86.2 11-Jan-2011  matt PSL_SPV is actually same value of PSL_VEC (must be a coincidence).
 1.14.86.1 07-Jan-2011  matt Add booke support.
 1.14.82.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.14.62.1 11-Mar-2010  yamt sync with head
 1.15.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.2.2 31-May-2011  rmind sync with head
 1.15.2.1 05-Mar-2011  rmind sync with head
 1.17.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18.16.1 18-May-2014  rmind sync with head
 1.18.12.2 03-Dec-2017  jdolecek update from HEAD
 1.18.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.8.4 18-May-2016  martin Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.29-1.30
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
(via patch)

Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.18.8.3 19-Nov-2015  bouyer Revert ticket 1310 (second try):
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.18.8.2 16-Nov-2015  bouyer Revert ticket 1310:
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.18.8.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.30
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revision 1.29
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/oea/altivec.c: revision 1.30
Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Don't reload if just re-enabling
Don't reload the FPU register if this is just a re-enable.
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.18.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.6.1 22-Sep-2015  skrll Sync with HEAD
 1.19.4.1 17-Jul-2015  snj Pull up following revision(s) (requested by matt in ticket #868):
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revisions 1.29, 1.30
sys/arch/powerpc/oea/altivec.c: revision 1.30
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
Add a check to make sure that if PSL_FP is set, we own the FPU.
--
Don't clear PSL_FP/PSL_VEC
--
Don't reload if just re-enabling
--
Don't reload the FPU register if this is just a re-enable.
--
Remove PSL_SPV from BOOKE PSL_USERMOD
--
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.21.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 05-Aug-2006  sanjayl 1st cut of Powermac G5 support (uses bridge mode).
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.8;
merge ktrace-lwp.
 1.7 16-Jan-2005  chs branches: 1.7.8;
implement pmap_wired_count(). fix some places we would forget to splx().
move the parts of pte.h that were used into pmap.c (since they were really
pmap-internal details) and delete ibm4xx/pte.h. other misc cleanup.
 1.6 03-Feb-2003  matt branches: 1.6.2; 1.6.10;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.5 09-Dec-2002  scw Changes/additions to support evbppc.
 1.4 12-Jun-2001  tsubai branches: 1.4.8;
Include powerpc/mpc6xx/{bat.h,pte.h} if PPC_MPC6XX is defined.
 1.3 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.2 31-Aug-1998  tsubai branches: 1.2.24;
vm_offset_t --> [pv]addr_t
 1.1 30-Sep-1996  ws PowerPC port
 1.2.24.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.2 11-Dec-2002  thorpej Sync with HEAD.
 1.4.8.1 12-Jun-2001  thorpej file pte.h was added on branch nathanw_sa on 2002-12-11 06:11:41 +0000
 1.6.10.1 29-Apr-2005  kent sync with -current
 1.6.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.7.8.1 30-Dec-2006  yamt sync with head.
 1.8.8.1 11-Aug-2006  yamt sync with head
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.19 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.18 15-Oct-2020  mgorny branches: 1.18.2;
Fix the machine-dependent ptrace requests to respect LWP number

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

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

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

Reviewed by kamil.
 1.17 21-Jun-2020  rin Fix inconsistency b/w kernel and userland recognitions of TLS, as well as
inconsistency whether it is biased or not in kernel.

- Obsolete __lwp_settcb() in order to let kernel know new TLS address via
_lwp_setprivate(2). Alternatively, we can call _lwp_setprivate(2) within
__lwp_settcb() like mips, but it is just double handling; we adjust %r2
appropriately in _lwp_setprivate(2) via cpu_lwp_setprivate().

- Make sure that, like other ports, l_private represents address of tcb,
not biased one as in %r2. This guarantees that the returned values from
_lwp_getprivate(2) and __lwp_getprivate_fast() are always same. Also,
we can obsolete PTRACE_LWP_GETPRIVATE() macro.

Now, *_pl_private tests in tests/lib/libc/sys successfully pass, while
no other tests become newly falling.
 1.16 24-Dec-2019  kamil Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO

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

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

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

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

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

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

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
 1.15 29-Nov-2019  martin Add illegal asm and breakpoint
 1.14 18-Jun-2019  kamil Introduce PTRACE_REG_FP() a helper macro to retrieve the frame pointer

The macro is dummy for ia64 (the FP register is unknown and can change
freely) and sparc/sparc64 (not stored in struct reg).
 1.13 08-Apr-2017  kamil branches: 1.13.14;
Add new ptrace(2) API: PT_SETSTEP & PT_CLEARSTEP

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

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

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

Define PT_*STEP only for platforms defining PT_STEP.

Add new ATF tests setstep[1234].

These ptrace(2) operations first appeared in FreeBSD.

Sponsored by <The NetBSD Foundation>
 1.12 15-Sep-2015  christos branches: 1.12.2; 1.12.4;
Provide access to pc/sp/syscall-return registers like we have for mcontext
 1.11 18-Jan-2011  matt branches: 1.11.16; 1.11.34;
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.10 04-Mar-2007  christos branches: 1.10.66; 1.10.70; 1.10.72;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26;
merge ktrace-lwp.
 1.8 06-May-2004  matt branches: 1.8.12;
Add PT_MACHDEP_STRINGS so that kdump(1) can print out the PowerPC-specific
ptrace requests.
 1.7 29-Jun-2003  fvdl branches: 1.7.2; 1.7.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.6 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.5 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.4 04-Jun-2000  tsubai Add PT_GETFPREGS and PT_SETFPREGS support.
 1.3 03-May-1999  tsubai branches: 1.3.2; 1.3.10;
PT_{STEP,GETREGS,SETREGS} support.
 1.2 05-Jan-1998  perry branches: 1.2.10;
RCSID Police.
 1.1 01-Oct-1996  ws Add some files that CVS missed somehow
These are empty for now, but are needed by MI code
 1.2.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.4.1 10-May-2004  tron Pull up revision 1.8 (requested by matt in ticket #278):
Add PT_MACHDEP_STRINGS so that kdump(1) can print out the
PowerPC-specific
ptrace requests.
 1.7.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.12.2 03-Sep-2007  yamt sync with head.
 1.8.12.1 21-Jun-2006  yamt sync with head.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.70.1 11-Jan-2011  matt Anything that applies to Altivec also applies SPE since to the common powerpc
code they share identical hooks.
 1.10.66.1 05-Mar-2011  rmind sync with head
 1.11.34.2 28-Aug-2017  skrll Sync with HEAD
 1.11.34.1 22-Sep-2015  skrll Sync with HEAD
 1.11.16.1 03-Dec-2017  jdolecek update from HEAD
 1.12.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.12.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.13.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.18.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.14 13-Aug-2021  andvar fix typos in words "pointer" and s/fram /frame/
 1.13 12-Aug-2021  andvar fix typos in "environment" word.
 1.12 24-Jan-2016  christos use __register_t
 1.11 12-Aug-2014  joerg branches: 1.11.2;
Avoid unncessary use of double in the kernel. With this change,
a LLVM build kernel fully works on TWRP1025.
 1.10 18-Jan-2011  matt branches: 1.10.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.9 08-Feb-2003  matt branches: 1.9.130; 1.9.134; 1.9.136;
Add comments to describe PowerPC64 ABI register usage.
 1.8 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.7 18-Apr-2002  matt branches: 1.7.2;
Use a common genassym.cf for all the PPC_MPC6XX ports. Add a makeoptions to
std.foo to indicate the directory to get genassym.cf from. Add an intrframe
to <powerpc/frame.h> and make trap_subr.S use symbolic offsets into it.
 1.6 04-Mar-2002  kleink VRSAVE is SPR 256, not 238.
 1.5 23-Nov-2000  matt branches: 1.5.4; 1.5.8;
Add comments and AltiVec reg state.
 1.4 04-Jun-2000  tsubai Add PT_GETFPREGS and PT_SETFPREGS support.
 1.3 03-May-1999  tsubai branches: 1.3.2; 1.3.10;
PT_{STEP,GETREGS,SETREGS} support.
 1.2 05-Jan-1998  perry branches: 1.2.10;
RCSID Police.
 1.1 01-Oct-1996  ws Add some files that CVS missed somehow
These are empty for now, but are needed by MI code
 1.2.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.5.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.5.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.2.1 16-Jul-2002  gehenna catch up with -current.
 1.9.136.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.134.1 07-Jan-2011  matt u_int32_t -> uint32_t
 1.9.130.1 05-Mar-2011  rmind sync with head
 1.10.16.1 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 19-Mar-2016  skrll Sync with HEAD
 1.2 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.1 30-Sep-1996  ws PowerPC port
 1.4 05-Feb-2003  nakayama Replace machine/rnd.h with more appropriate name to share it
with cycle counter based microtime in kern/kern_microtime.c.
 1.3 23-Jan-2003  kleink Correct inverted logic in comment.
 1.2 26-Mar-2002  kleink On the 601, construct the CPU counter value from the RTC[UL] registers.
 1.1 11-Jun-2000  tsubai branches: 1.1.4; 1.1.6; 1.1.10; 1.1.14;
Add cpu_counter().
 1.1.14.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.10.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 11-Jun-2000  bouyer file rnd.h was added on branch thorpej_scsipi on 2000-11-20 20:31:12 +0000
 1.1.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.4.1 11-Jun-2000  minoura file rnd.h was added on branch minoura-xpg4dl on 2000-06-22 17:02:40 +0000
 1.5 05-Jul-2013  joerg Fix header guard.
 1.4 28-Apr-2008  martin branches: 1.4.34; 1.4.44; 1.4.50;
Remove clause 3 and 4 from TNF licenses
 1.3 08-Apr-2008  garbled branches: 1.3.2; 1.3.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.2 28-Dec-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14;
Add one more convenience function to rtas, rtas_has_func, and add a
global int machine_has_rtas that can be used to decide if a machine has
rtas functionality or not. Take a crack at power off support for the
pegasos, which doesn't work right, probably due to a firmware bug.
 1.1 28-Dec-2007  garbled Rewrite the rtas_call command, to allow ports to call rtas directly from
outside rtas.c, by simply issuing the right token. This makes using the
rtas functionality much simpler.
 1.2.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.8.1 28-Dec-2007  mjf file rtas.h was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 28-Dec-2007  yamt file rtas.h was added on branch yamt-lazymbuf on 2008-01-21 09:38:22 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 28-Dec-2007  matt file rtas.h was added on branch matt-armv6 on 2008-01-09 01:47:49 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 28-Dec-2007  bouyer file rtas.h was added on branch bouyer-xeni386 on 2008-01-02 21:49:07 +0000
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.1 18-May-2008  yamt sync with head.
 1.4.50.1 28-Aug-2013  rmind sync with head
 1.4.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.34.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5 29-Nov-2019  riastradh Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade. The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by <sys/rwlock.h>.
 1.4 28-Apr-2008  martin branches: 1.4.88;
Remove clause 3 and 4 from TNF licenses
 1.3 21-Nov-2007  yamt branches: 1.3.14; 1.3.16; 1.3.18;
make kmutex_t and krwlock_t smaller by killing lock id.
ok'ed by Andrew Doran.
 1.2 09-Feb-2007  ad branches: 1.2.4; 1.2.8; 1.2.24; 1.2.26; 1.2.30; 1.2.32;
Merge newlock2 to head.
 1.1 30-Jan-2007  ad branches: 1.1.2;
file rwlock.h was initially added on branch newlock2.
 1.1.2.1 30-Jan-2007  ad Add missing headers.
 1.2.32.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.30.1 21-Nov-2007  bouyer Sync with HEAD
 1.2.26.1 09-Jan-2008  matt sync with HEAD
 1.2.24.1 21-Nov-2007  joerg Sync with HEAD.
 1.2.8.1 03-Dec-2007  ad Sync with HEAD.
 1.2.4.3 07-Dec-2007  yamt sync with head
 1.2.4.2 26-Feb-2007  yamt sync with head.
 1.2.4.1 09-Feb-2007  yamt file rwlock.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:53 +0000
 1.3.18.1 16-May-2008  yamt sync with head.
 1.3.16.1 18-May-2008  yamt sync with head.
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 16-Sep-1998  thorpej Back out previous; I'm punting PowerPC to tsubai or sakamoto.
 1.2 16-Sep-1998  thorpej Need 103 longs for jmp_buf now (128-bit signal mask, at the front of the
jump buffer).
 1.1 30-Sep-1996  ws PowerPC port
 1.26 29-Oct-2021  thorpej Define __HAVE_STRUCT_SIGCONTEXT regardless of its current visibility.
 1.25 27-Oct-2021  christos There is no sigcontext in ppc64
 1.24 27-Oct-2021  thorpej Make sigcontext13 visible only to _KERNEL. Make sigcontext visible only
to _LIBC and _KERNEL.
 1.23 26-Oct-2021  christos Merge all MD __sigaction14_sigtramp.c copies into one:
- sparc and sparc64 were not using version 0 sigcontext when there were
no arguments in the signal version. This was probably a bug.
- vax is using +1 the version numbers of the other archs.
- Only hppa was defining __LIBC12_SOURCE__ so it was getting a working
sigcontext before. all the other ports that supported sigcontext had
the compat code disabled.
[pointed out by thorpej, thanks!]
If we want to remove sigcontext support from userland at least now there
is less work to do so.
 1.22 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.21 29-Nov-2017  christos need sigtypes.h for sigset_t, since <sys/siginfo.h> includes this directly.
 1.20 19-Nov-2008  cegger branches: 1.20.26;
remove duplicate prototype which now conflicts with the prototype in <sys/signalvar.h>
 1.19 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.18 11-Dec-2005  christos branches: 1.18.74; 1.18.78; 1.18.84; 1.18.86;
merge ktrace-lwp.
 1.17 26-Mar-2004  drochner nothing cares about __HAVE_SIGINFO anymore, so nuke it
 1.16 27-Sep-2003  matt Define SIGTRAMP_VALID properly.
 1.15 26-Sep-2003  matt Add a machine-dependent SIGTRAMP_VALID macro which is used to test whether
a trampoline version is valid or not.
 1.14 25-Sep-2003  matt Deal with the constification of ksiginfo_t and sigset_t in signalling.
 1.13 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.12 28-Apr-2003  bjh21 branches: 1.12.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

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

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

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.11 02-Mar-2003  matt Restore MQ to trapframe from mcontext since it's in both.
 1.10 03-Feb-2003  matt Don't use trapframe in sigcontext. Instead define a new structure
utrapframe that fixed in size (and the same size as the trapframe
in NetBSD 1.5). This preserves binary compatibility for those programs
that dealt looked at sigcontexts.
 1.9 20-Jan-2003  matt Add _REG_foo to ppc mcontext and use them instead of constants.
 1.8 19-Jan-2003  matt Make this reflect reality.
 1.7 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6 03-Nov-2002  matt Change _MACHINE_foo_H_ to _POWERPC_foo_H_
 1.5 04-Jul-2002  thorpej Eliminate two unused sigframe members.
 1.4 14-Sep-1998  thorpej branches: 1.4.26; 1.4.30; 1.4.38;
sigset13_t -> int.
 1.3 13-Sep-1998  thorpej Make signal delivery work again.
 1.2 25-May-1998  kleink If any of _ANSI_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE are defined, don't
provide any identifiers other than sig_atomic_t.
 1.1 30-Sep-1996  ws PowerPC port
 1.4.38.1 16-Jul-2002  gehenna catch up with -current.
 1.4.30.3 16-Jan-2003  thorpej * Include <sys/sigtypes.h> rather than <sys/signal.h> in <sys/ucontext.h>.
* Define _UCONTEXT_TO_SIGCONTEXT() and _SIGCONTEXT_TO_UCONTEXT()
macros for converting a ucontext -> sigcontext and back again.
These macros in turn use machine-dependent macros _MCONTEXT_TO_SIGCONTEXT()
and _SIGCONTEXT_TO_MCONTEXT() provided by <machine/signal.h>.

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

Also note that the mcontext conversion may not be enough for all platforms
(m68k is a good example of this). These macros should be used only if
you really know what you're doing.
 1.4.30.2 11-Nov-2002  nathanw Catch up to -current
 1.4.30.1 01-Aug-2002  nathanw Catch up to -current.
 1.4.26.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.84.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.18.78.1 04-May-2009  yamt sync with head.
 1.18.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.20.26.1 03-Dec-2017  jdolecek update from HEAD
 1.1 23-Jul-2014  alnsn branches: 1.1.2; 1.1.6;
Rename sljitarch.h to sljit_machdep.h.
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 23-Jul-2014  tls file sljit_machdep.h was added on branch tls-maxphys on 2014-08-20 00:03:19 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 23-Jul-2014  tls file sljit_machdep.h was added on branch tls-earlyentropy on 2014-08-10 06:54:05 +0000
 1.4 23-Jul-2014  alnsn Rename sljitarch.h to sljit_machdep.h.
 1.3 22-Jul-2014  alnsn Cast to __syncicache() argument types.
 1.2 25-Nov-2013  alnsn branches: 1.2.2; 1.2.4; 1.2.6;
Use __syncicache() in sljit on powerpc.
 1.1 17-Nov-2013  alnsn Enable sljit and bpfjit on powerpc.
 1.2.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.1 25-Nov-2013  yamt file sljitarch.h was added on branch yamt-pagecache on 2014-05-22 11:40:04 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 25-Nov-2013  rmind file sljitarch.h was added on branch rmind-smpnet on 2014-05-18 17:45:22 +0000
 1.2.2.1 10-Aug-2014  tls Rebase.
 1.3 24-Aug-2013  matt struct cpu_info;
 1.2 23-Aug-2013  matt Fix kern_softint.c errors (tested with WALNUT & EV64260)
 1.1 14-Jun-2011  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.16; 1.1.20;
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.1.20.1 28-Aug-2013  rmind sync with head
 1.1.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.4.1 14-Jun-2011  matt file softint.h was added on branch matt-nb5-pq3 on 2011-10-14 17:21:26 +0000
 1.1.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.1 14-Jun-2011  cherry file softint.h was added on branch cherry-xenmp on 2011-06-23 14:19:31 +0000
 1.4 03-Dec-2007  ad Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.48; 1.3.50; 1.3.56;
merge ktrace-lwp.
 1.2 25-Mar-2004  matt branches: 1.2.4; 1.2.18;
Move data structures to softintr.c. Remove an unneeded if. Fix a typo.
 1.1 24-Mar-2004  matt Generic soft interrupt support for PowerPC ports.
 1.2.18.1 07-Dec-2007  yamt sync with head
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 25-Mar-2004  skrll file softintr.h was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.3.56.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.50.1 23-Mar-2008  matt sync with HEAD
 1.3.48.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.30.1 03-Dec-2007  ad Sync with HEAD.
 1.56 07-May-2022  rin Remove SPR_CCR0 from <powerpc/spr.h>; we already have it in
<powerpc/ibm4xx/spr.h>, together with other 4xx-specific SPRs.

Thanks uwe@ for pointing out.
 1.55 07-May-2022  rin Instead of hard-coding SPR# for CCR0, define SPR_CCR0 in
<powerpc/spr.h> and use it.

Idea from uwe@, thanks!
(and sorry for delayed response!)
 1.54 02-Nov-2021  ryo fix build with COPTS=-O0
 1.53 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.52 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.51 22-Mar-2018  macallan first step towards G5 SMP:
- only save/restore BATs on CPUs that have them
- treat HID0 as 64bit on 64bit CPUs
 1.50 21-Jan-2018  mrg branches: 1.50.2;
fix some logic errors in the previous and fix non-kernel builds.
 1.49 21-Jan-2018  mrg fix ofppc/pegasosII (and maybe others).

don't assume PPC_OEA64_BRIDGE means we have a 64 bit cpu (code
for 64 bit in bridge and normal 32 bit can co-exist due to
fixups the early boot code does has, and ofppc builds GENERIC
this way):
- fix mtmsr()/mfmsr() to use the right method based upon the
actually cpu booted on.
- fix cpu_setup() to have 32 bit and 64 bit hid0 variables
and operate on the right one based upon the current cpu.
restore a minor optimisation of not writing hid0 if it
didn't change.

in set_timebase() check if OF_finddevice("/cpus/@0") failed
and returned -1 before using it for OF_getprop().
 1.48 20-Jan-2018  simonb Add a copyright (approx 16.5 years later).
 1.47 07-Jul-2017  macallan fix tpyo
 1.46 07-Jul-2017  macallan add mfspr/mtspr methods suitable for 64bit SPRs on ppc970 in bridge mode
 1.45 25-Feb-2010  matt branches: 1.45.20; 1.45.38;
Split <powerpc/spr.h> into a common <powerpc/spr.h> and <powerpc/XXX/spr.h>
where XXX is ibm4xx or oea.
 1.44 23-Feb-2008  matt branches: 1.44.4; 1.44.24; 1.44.28;
Add some 440 definitions
 1.43 31-Dec-2007  garbled branches: 1.43.2; 1.43.6;
Add a bunch of PVR values for a variety of processors. Taken from
various manuals, and linux.
 1.42 17-Oct-2007  garbled branches: 1.42.2; 1.42.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.41 25-Jun-2007  aymeric branches: 1.41.10;
Recognize the Freescale G2 cores: initialize cache line size, and doze mode
While there, fix the way the major version of a PowerPC processor is computed
 1.40 05-Aug-2006  sanjayl branches: 1.40.14; 1.40.16; 1.40.22;
1st cut of Powermac G5 support (uses bridge mode).
 1.39 06-Jul-2006  scw Fix the entries for SPR_DC_ADR and SPR_DC_DAT.
 1.38 24-Dec-2005  perry branches: 1.38.4; 1.38.8; 1.38.16;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.37 15-Nov-2005  matt Add MPC5200 SVR definition
 1.36 21-Jan-2005  matt branches: 1.36.8; 1.36.14;
Add MPC7448 and change MPC745x_P macro to deal with it.
 1.35 20-Jan-2005  matt Add MPC7447A (0x8003)
 1.34 06-Dec-2004  briggs branches: 1.34.4;
Minor (old) patch from me to correct CPU ID of 604e vs. 604ev.
Tested by Tim Kelly.
Also patched from Tim to
- Delay longer for second CPU spinup.
- Only attempt to print CPU speed and cache configuration on certain
CPU types.
 1.33 20-Sep-2004  scw MPC8xx DC_CST is SPR 0x238, not 0x230.
Reported by Jared Momose in private email.
 1.32 09-Oct-2003  matt Add support for MPC74[45]7
 1.31 23-Sep-2003  shige Add IBM405GPr PVR.
 1.30 17-Aug-2003  chs add some 745x-specific MSSCR0 bits.
 1.29 04-Apr-2003  matt branches: 1.29.2;
MMCRx register definitions should not be prefixed by SPR_
 1.28 04-Apr-2003  matt Add two missing L2CLK speeds.
 1.27 14-Mar-2003  matt Condition ({ ... }) by __GNUC__. Remove redundant SPR_IBAT0U definiton.
 1.26 26-Feb-2003  jklos Added configuration entries for L3CR_CONFIG for L3 caches on 745x
accelerators. Thanks to Monroe Williams.
 1.25 14-Aug-2002  matt Add a bunch of mpc8xx SPR definitions.
 1.24 11-Aug-2002  simonb Add some IBM 4xx CPU PVR values; sort PVRs numerically.
White space nits.
 1.23 10-Aug-2002  matt Add IBM Power3 CPUID.
 1.22 08-Aug-2002  matt Add SPR_ASR from OEA-64. Change mfspr to use register_t.
 1.21 06-Aug-2002  chs add the MSSCR0 register and some more L2CR fields.
 1.20 01-Jul-2002  matt Add VRSAVE.
 1.19 20-Jun-2002  matt Add IBM750FX (0x7000)
 1.18 19-Jun-2002  briggs Include the Processor ID for the MPC8245.
 1.17 03-Apr-2002  matt branches: 1.17.2; 1.17.4;
Add some MPC745x L3CR cache definitions.
 1.16 03-Mar-2002  matt Add MPC7455
 1.15 03-Mar-2002  nathanw Add bit definitions for the MMCR's, and event numbers for the events
that are common to the G3 and G4.
 1.14 03-Mar-2002  nathanw Correct the SPR numbers of PMC3 and PMC4.
SIA wasn't retconned, but the SPR number was wrong. Re-add it, and add
USIA.
 1.13 03-Mar-2002  nathanw Delete the retconned SIAR SPR.
 1.12 03-Mar-2002  nathanw Add MPC7xx/7xxx performance monitor control registers (MMCR0-2, UMMCR0-2).
 1.11 03-Mar-2002  nathanw Add bit definitions for the MPC750 thermal management registers.
 1.10 05-Feb-2002  kleink Add MPC601 MQ and RTCU/RTCL SPRs.
 1.9 02-Dec-2001  thorpej Add PVR processor type fields for IBM 405GP and IBM 405L.
 1.8 29-Oct-2001  simonb branches: 1.8.2;
Include bit definitions for the Debug Status Register; from Artem Belevich
at Riverstone Networks.
 1.7 16-Sep-2001  wiz branches: 1.7.2;
Spell 'occurred' with two 'r's.
 1.6 30-Aug-2001  matt branches: 1.6.2;
Add new 7450 SPRs
 1.5 26-Aug-2001  matt Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.4 23-Jun-2001  matt branches: 1.4.2;
Use __asm __volatile. Use _POWERPC_SPR_H_
Add PTE_RO/PTE_RW for old pmap.
 1.3 22-Jun-2001  matt DMISS/DCMP/HASH1/HASH2/IMISS/ICMP/RPA are also valid on the MPC6XX
(specially the 603 and maybe the 601)
 1.2 19-Jun-2001  simonb branches: 1.2.2;
Move the DSISR SPR bit definitions from <powerpc/mpc6xx/pte.h> to
<powerpc/spr.h>. Remove unused ISI/SRR1 bit definitions.
 1.1 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.4.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.6.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.7.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.8.2.9 27-Aug-2002  nathanw Catch up to -current.
 1.8.2.8 13-Aug-2002  nathanw Catch up to -current.
 1.8.2.7 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.8.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.8.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.8.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.8.2.1 29-Oct-2001  nathanw file spr.h was added on branch nathanw_sa on 2002-01-08 00:27:10 +0000
 1.17.4.2 21-Jun-2002  lukem Pull up revision 1.19 (requested by matt in ticket #332):
Add IBM750FX (0x7000)
 1.17.4.1 20-Jun-2002  lukem Pull up revision 1.18 (requested by briggs in ticket #324):
Include the Processor ID for the MPC8245.
 1.17.2.2 31-Aug-2002  gehenna catch up with -current.
 1.17.2.1 16-Jul-2002  gehenna catch up with -current.
 1.29.2.7 11-Dec-2005  christos Sync with head.
 1.29.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.29.2.5 18-Dec-2004  skrll Sync with HEAD.
 1.29.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.34.4.1 29-Apr-2005  kent sync with -current
 1.36.14.1 22-Nov-2005  yamt sync with head.
 1.36.8.5 27-Feb-2008  yamt sync with head.
 1.36.8.4 21-Jan-2008  yamt sync with head
 1.36.8.3 03-Sep-2007  yamt sync with head.
 1.36.8.2 30-Dec-2006  yamt sync with head.
 1.36.8.1 21-Jun-2006  yamt sync with head.
 1.38.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.38.8.1 11-Aug-2006  yamt sync with head
 1.38.4.1 09-Sep-2006  rpaulo sync with head
 1.40.22.2 02-Aug-2007  macallan sync with HEAD
 1.40.22.1 26-Jun-2007  garbled Sync with HEAD.
 1.40.16.1 11-Jul-2007  mjf Sync with head.
 1.40.14.1 15-Jul-2007  ad Sync with head.
 1.41.10.3 23-Mar-2008  matt sync with HEAD
 1.41.10.2 09-Jan-2008  matt sync with HEAD
 1.41.10.1 06-Nov-2007  matt sync with HEAD
 1.42.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.42.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.43.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.43.2.1 24-Mar-2008  keiichi sync with head.
 1.44.28.1 07-Jan-2011  matt Split spr.h into generic PPC <powerpc/spr.h> and chip-specific
<powerpc/XXX/spr.h> (XXX=oea, ibm4xx, booke)
 1.44.24.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.44.4.1 11-Mar-2010  yamt sync with head
 1.45.38.1 28-Aug-2017  skrll Sync with HEAD
 1.45.20.1 03-Dec-2017  jdolecek update from HEAD
 1.50.2.2 22-Apr-2018  pgoyette Sync with HEAD
 1.50.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.18 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.17 01-Jul-2011  mrg add GCC 4.5 support
 1.16 21-Jun-2008  gmcgarry Add stdargs support for pcc.
 1.15 11-Dec-2005  christos branches: 1.15.74; 1.15.78; 1.15.80; 1.15.82;
merge ktrace-lwp.
 1.14 24-Sep-2003  matt Define va_list as __builtin_va_list for GCC 3.x. Change stdarg macros
appropriately. (this is committed from a system run a kernel and userland
built with these changes).
 1.13 28-Apr-2003  bjh21 branches: 1.13.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

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

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

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.12 18-Jan-2003  matt Add LP64 support.
 1.11 04-Dec-2002  thorpej Revert my previous GCC 3.3-related changes; GCC 3.3 has been fixed
to handle our stdarg/varargs ABI for PowerPC.
 1.10 25-Oct-2002  thorpej Make these work with GCC 3.x.
 1.9 01-Jun-2002  tsubai Add gcc 3.x version.
 1.8 31-May-2001  tsubai branches: 1.8.2; 1.8.8; 1.8.16;
One more gcc-2.95 issue.
 1.7 30-May-2001  tsubai Add gcc-2.95 version.
 1.6 16-May-2001  simonb If _SOFT_FLOAT is defined, pull floating point va_args from the GPR
area and not the FPR area (by having the double argument type test
always fail).

Fixes problems using <stdarg.h> with -msoft-float.
 1.5 27-Feb-2000  tsubai branches: 1.5.6;
Rewrite stdarg/varargs.
 1.4 03-Feb-2000  kleink Add a C99-style va_copy macro.
 1.3 02-Dec-1998  tsubai branches: 1.3.10;
Adapt to gcc change (calling sequence).
 1.2 16-Apr-1997  thorpej Use new va-ppc.h
 1.1 30-Sep-1996  ws PowerPC port
 1.3.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.16.1 15-Jul-2002  gehenna catch up with -current.
 1.8.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.8.8.3 11-Nov-2002  nathanw Catch up to -current
 1.8.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.8.8.1 31-May-2001  nathanw file stdarg.h was added on branch nathanw_sa on 2002-06-20 03:40:32 +0000
 1.8.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.82.1 27-Jun-2008  simonb Sync with head.
 1.15.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.78.1 04-May-2009  yamt sync with head.
 1.15.74.1 29-Jun-2008  mjf Sync with HEAD.
 1.14 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.13 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.12 18-Jul-2012  matt branches: 1.12.2; 1.12.4;
Define the MPC8XX traps
 1.11 24-May-2008  phx branches: 1.11.32;
Make oea_init() support systems with high-vector configurations (i.e exception
vectors at 0xfff00000), and trap_subr.S allows the kernel to be in a memory
region which is not reachable by absolute branch instructions (ba and bla).

High-vector support can be enabled by option PPC_HIGH_VEC, and long-branches
to the kernel are enabled by the option DISTANT_KERNEL.
 1.10 05-Aug-2006  sanjayl branches: 1.10.58; 1.10.60; 1.10.62; 1.10.64;
1st cut of Powermac G5 support (uses bridge mode).
 1.9 26-Apr-2003  wiz branches: 1.9.18; 1.9.32; 1.9.36;
Management, not managment. Mostly from jmc@openbsd.
 1.8 19-May-2002  augustss Handle the "aligment" fault generated by DCBZ when the cache is off.
That way you can run the processor with caches off.
 1.7 22-Feb-2002  kleink branches: 1.7.8;
Handle the 601's Run Mode/Trace Exception as well.
 1.6 13-Jun-2001  simonb branches: 1.6.2; 1.6.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.5 20-Nov-2000  tsubai branches: 1.5.2;
Thermal Management Interrupt is available on 750, too.
 1.4 19-Nov-2000  matt Add G4 specific exceptions (include AltiVec).
 1.3 25-May-2000  is Prepare for AmigaPPC.
 1.2 19-Jan-2000  danw Fill in the alignment trap handler a bit: now it can fix unaligned
floating point loads and stores (to work around a gcc bug), but will
still cause a bus error on other sorts of unaligned accesses.
 1.1 30-Sep-1996  ws branches: 1.1.22; 1.1.28;
PowerPC port
 1.1.28.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.22.1 20-Jan-2000  he Pull up revision 1.2 (requested by danw):
Add (the beginnings of) an unaligned access handler for the
powerpc, to get around the fact that gcc currently generates bad
floating point copies sometimes, which breaks various things,
 1.5.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.8.3 20-Jun-2002  nathanw Catch up to -current.
 1.6.8.2 28-Feb-2002  nathanw Catch up to -current.
 1.6.8.1 13-Jun-2001  nathanw file trap.h was added on branch nathanw_sa on 2002-02-28 04:11:26 +0000
 1.6.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.8.1 30-May-2002  gehenna Catch up with -current.
 1.9.36.1 11-Aug-2006  yamt sync with head
 1.9.32.1 09-Sep-2006  rpaulo sync with head
 1.9.18.1 30-Dec-2006  yamt sync with head.
 1.10.64.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.62.1 04-May-2009  yamt sync with head.
 1.10.60.1 04-Jun-2008  yamt sync with head
 1.10.58.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.32.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.32.1 30-Oct-2012  yamt sync with head
 1.12.4.1 18-May-2014  rmind sync with head
 1.12.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.66 01-Apr-2021  simonb Whitespace: #define<tab>
 1.65 23-Jan-2021  christos branches: 1.65.2;
Document via __HAVE_BUS_SPACE_8 platforms that implement bus_space_*_8
 1.64 22-Jun-2020  rin branches: 1.64.2;
Fix previous; hide userland ABI details for kernel as suggested by joerg:

http://mail-index.netbsd.org/source-changes-d/2020/06/21/msg012745.html

- Revive __lwp_settcb(), and call _lwp_setprivate(2) from it.

- Keep l_private opaque pointer for kernel; store raw value of %r2 in it.
In the previous commit message, I wrote,

http://mail-index.netbsd.org/source-changes/2020/06/21/msg118524.html

> - Make sure that, like other ports, l_private represents address of tcb,
> not biased one as in %r2.

but, it turned out to be wrong. mips stores a biased address, at least.
It is userland responsibility to interpret returned values from
lwp_getprivate(2).
 1.63 21-Jun-2020  rin Fix inconsistency b/w kernel and userland recognitions of TLS, as well as
inconsistency whether it is biased or not in kernel.

- Obsolete __lwp_settcb() in order to let kernel know new TLS address via
_lwp_setprivate(2). Alternatively, we can call _lwp_setprivate(2) within
__lwp_settcb() like mips, but it is just double handling; we adjust %r2
appropriately in _lwp_setprivate(2) via cpu_lwp_setprivate().

- Make sure that, like other ports, l_private represents address of tcb,
not biased one as in %r2. This guarantees that the returned values from
_lwp_getprivate(2) and __lwp_getprivate_fast() are always same. Also,
we can obsolete PTRACE_LWP_GETPRIVATE() macro.

Now, *_pl_private tests in tests/lib/libc/sys successfully pass, while
no other tests become newly falling.
 1.62 16-Apr-2020  rin Discard __HAVE_UNLOCKED_PMAP for 4xx; 4xx is uniprocessor architecture,
and everything gets more than 10 times slower by __HAVE_UNLOCKED_PMAP.

Note that we support three supervisor-level architectures for powerpc:
oea, booke, and 4xx. We have three different implementations of pmap as
a result. Whereas oea and booke support multiprocessor, 4xx does not.
 1.61 22-Mar-2020  ad branches: 1.61.2;
Temporarily mark hppa, mips, powerpc and riscv with __HAVE_UNLOCKED_PMAP,
for the benefit of UVM.

These need some pmap changes to support concurrent faults on the same
object. I have changes to do just that, but they're a work in progress.
 1.60 06-Dec-2019  mrg revert this change from early this year. it appears the
changes macallan@ commited to fix FIRMWORKSBUGS issues
in openfirmware() have fixed the hangs seen on PegasosII.

hooray!

---
Log Message:
workaround a problem with the pegasos firmware interface:
attempting to use /dev/openfirm on this machine hangs hard.

this isn't a new problem, and i've been meaning to try to
figure it out for years, but it's become a problem since
the xf86-video-radeon driver gained code to look for the
macppc model using this interface.

this is why xorg-server 1.18 and 1.20 hang recently on the
pegasosII.

this change is fairly ugly but i couldn't think of a less
ugly method to avoid /dev/openfirm working just on this
one platform. introduce new __OPENFIRMIO_OPEN_CHECK_BROKEN
macro and associated __openfirmio_open_check_broken(), and
use them in the new openfirmopen() to fail opens.

include proplib.h in macppc and ofppc autoconf.h since they
use it.
---
 1.59 07-Apr-2019  thorpej Detangle some of the PowerPC CPU configuration spaghetti.
 1.58 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.57 08-Jan-2019  mrg workaround a problem with the pegasos firmware interface:
attempting to use /dev/openfirm on this machine hangs hard.

this isn't a new problem, and i've been meaning to try to
figure it out for years, but it's become a problem since
the xf86-video-radeon driver gained code to look for the
macppc model using this interface.

this is why xorg-server 1.18 and 1.20 hang recently on the
pegasosII.


this change is fairly ugly but i couldn't think of a less
ugly method to avoid /dev/openfirm working just on this
one platform. introduce new __OPENFIRMIO_OPEN_CHECK_BROKEN
macro and associated __openfirmio_open_check_broken(), and
use them in the new openfirmopen() to fail opens.

include proplib.h in macppc and ofppc autoconf.h since they
use it.
 1.56 27-Jan-2017  christos branches: 1.56.12; 1.56.14;
remove __HAVE_COMPAT_NETBSD32
 1.55 26-Jan-2017  christos provide __HAVE_COMPAT_NETBSD32 and fix multiple include protection consistently.
 1.54 24-Jan-2016  christos branches: 1.54.2; 1.54.4;
expose __register32_t for frame.h
 1.53 23-Jan-2016  christos expose the kernel types for standalone code.
 1.52 23-Jan-2016  christos Hide {p,v}{addr,size}_t and register_t (and a couple more types that
are machine-specific) from userland unless _KERNEL/_KMEMUSER and a
new _KERNTYPES variables is defined. The _KERNTYPES should be fixed
for many subsystems that should not be using it (rump)...
 1.51 27-Aug-2015  pooka Fix PTHREAD_FOO_INITIALIZER for C++ by not using volatile in the relevant
pthread types in C++ builds, attempt 2.

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

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

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

Based on the patch from Christos in lib/49989.
 1.50 14-Dec-2014  chs fix powerpc TLS problems by removing the hacks for PPC EABI.
the kernel no longer treats R2 specially and its use as
the TLS register is now handled entirely in userland.
 1.49 18-Mar-2014  riastradh branches: 1.49.4; 1.49.6;
Merge riastradh-drm2 to HEAD.
 1.48 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.47 26-May-2012  matt branches: 1.47.2; 1.47.4; 1.47.10;
Add __HAVE_RAS support. Do it in userret.
 1.46 17-Jul-2011  dyoung branches: 1.46.2; 1.46.6; 1.46.8;
Enable new-style <sys/bus.h> on several PowerPC ports supporting PCI
buses. Make non-inline implementations of bus_space(9) and bus_dma(9)
routines and move them to appropriate .c files.

This may leave amigappc in a bad state, sorry. Fortunately, it will be
easy to repair by imitating the bus.h -> bus_{defs,funcs}.h split in
some other PowerPC port.
 1.45 23-Jun-2011  matt Switch to using the common <common/pmap/tlb/tlb.h>
 1.44 14-Jun-2011  matt Add mm_md_kernacc and now kmem tools work again.
 1.43 13-Jun-2011  matt Add __HAVE_CPU_UAREA_ROUTINES support so that uareas will be direct-mapped.
(This avoids the nasty tlb recursion problem on ibm4xx as well on mpc85xx).
 1.42 12-Jun-2011  matt need mm_md_direct_mapped_phys support.
 1.41 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.40 02-May-2011  matt branches: 1.40.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.39 07-Apr-2011  matt Get rid of cpu_lwp_setprivate since it's not needed on powerpc.
 1.38 12-Mar-2011  matt Add TLS defines.
 1.37 24-Feb-2011  joerg Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

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

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.36 22-Dec-2010  matt branches: 1.36.2; 1.36.4;
Add a define __HAVE_CPU_DATA_FIRST which means that cpu_data is the first
member in struct cpu_info.
 1.35 07-Jul-2010  chs implement cpu_lwp_setprivate() on several platforms.
 1.34 11-Dec-2009  matt branches: 1.34.2; 1.34.4;
Add PRIx{P,V}{ADDR,SIZE}, PRIu{P,V}SIZE, and PRIxREGISTER{,32,64} for all
(except where they will be added via merge). These should be used to print
{p,v}{addr,size}_t and register*_t as appropriate.
 1.33 31-Jan-2008  matt branches: 1.33.10; 1.33.32;
Add register{32,64}_t
 1.32 20-Jan-2008  joerg Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.31 08-Jan-2008  joerg Finish conversion of ppc and evbppc to timecounter.
Tested by simonb@ on WALNUT.
 1.30 29-Nov-2007  ad branches: 1.30.6;
__HAVE_ATOMIC64_OPS if 64-bit
 1.29 17-Oct-2007  garbled branches: 1.29.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.28 17-May-2007  yamt branches: 1.28.8; 1.28.10;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.27 05-Aug-2006  sanjayl branches: 1.27.10; 1.27.14; 1.27.16; 1.27.22;
1st cut of Powermac G5 support (uses bridge mode).
 1.26 24-Dec-2005  perry branches: 1.26.4; 1.26.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.25 11-Dec-2005  christos merge ktrace-lwp.
 1.24 26-Sep-2003  nathanw branches: 1.24.16;
Move __cpu_simple_lock_t and __SIMPLELOCK_{UN,}LOCKED to machine/types.h
so that they can be used in a namespace-friendly way.
 1.23 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.22 21-Jul-2003  hannken Typo: __HAVE_BITENDIAN_BITOPS -> __HAVE_BIGENDIAN_BITOPS
 1.21 18-Jul-2003  matt Elimindate MD setrunqueue/remrunqueue (which were out-of-date compared to
the canonical versions in kern_synch.c). Define __HAVE_BIGENDIAN_BITOPS
so the canonical versions will be used but will store priorities in the
desired (MSB) order for PowerPC (which allows the use of the cntlzw (count
leading zeroes, word) instruction in locore_subr.S to find the proper
priority).
 1.20 28-Apr-2003  bjh21 branches: 1.20.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

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

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

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.19 18-Jan-2003  matt Make register_t. Change the printfs in trap.c to match.
 1.18 16-Jan-2003  matt A small LP64 fix.
 1.17 22-Sep-2002  simonb Use "#define\t" instead of "#define ".
 1.16 22-Sep-2002  gmcgarry Add __HAVE_MD_RUNQUEUE flag for MD code to override MI run queue primitives.
 1.15 14-Aug-2002  matt Prepare for PPC64. Use register_t for mtmsr/mfmsr since the msr on PPC64
is 64bits wide. Define proper types for PPC64 if _LP64 is defined.
 1.14 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.13 28-Feb-2002  simonb branches: 1.13.8;
Use "#define<tab>".
 1.12 28-Apr-2001  kleink branches: 1.12.2; 1.12.8;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.11 04-Mar-2001  matt branches: 1.11.2;
Nuke vm_offset_t, vm_size_t from powerpc.
 1.10 03-Jan-2001  takemura replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.9 11-Jun-2000  tsubai Add cpu_counter().
 1.8 13-Aug-1998  eeh branches: 1.8.12; 1.8.20;
Merge paddr_t changes into the main branch.
 1.7 14-Jun-1998  kleink branches: 1.7.2;
GC the unused `physadr' type, which was not able to hold a complete physical
address on 2 architectures anyhow. Also, move the definition of the `label_t'
type inside _KERNEL protection, since it is specific to the in-kernel
setjmp()/longjmp() implementations.
 1.6 23-Feb-1998  mycroft Clean up, add physadr.
 1.5 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.4 05-Nov-1997  thorpej Mark uses of long long with /* LONGLONG */ for lint. From
Chris Demetriou <cgd@pa.dec.com>.
 1.3 16-Apr-1997  thorpej branches: 1.3.8;
Nuke __BROKEN_INDIRECT_CONFIG
 1.2 05-Dec-1996  cgd First step inn removing config_scan() and the hacks that gave devices
on indirect-config busses a (permanent) softc that they could share
between 'match' and 'attach' routines:

Define __BROKEN_INDIRECT_CONFIG so that old autoconfiguration
interfaces are used, until drivers are converted to use the new
interfaces (actually, converted back to use the _older_ interfaces)
which prohibit indirect configuration devices from receiving a softc
in their match routine that they can share with their attach routine.
 1.1 30-Sep-1996  ws PowerPC port
 1.3.8.1 05-Nov-1997  thorpej Update from trunk: Mark usese of long long with /* LONGLONG */ for lint.
 1.7.2.2 12-Aug-1998  eeh Protect XOPEN and POSIX code from vm_offset_t, paddr_t, vaddr_t, vm_size_t, psize_t, and vsize_t.
 1.7.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.8.20.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.12.3 12-Mar-2001  bouyer Sync with HEAD.
 1.8.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.8.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.8.6 17-Jan-2003  thorpej Sync with HEAD.
 1.12.8.5 18-Oct-2002  nathanw Catch up to -current.
 1.12.8.4 27-Aug-2002  nathanw Catch up to -current.
 1.12.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.12.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.8.1 28-Apr-2001  nathanw file types.h was added on branch nathanw_sa on 2002-04-01 07:42:05 +0000
 1.12.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.13.8.2 31-Aug-2002  gehenna catch up with -current.
 1.13.8.1 16-Jul-2002  gehenna catch up with -current.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.24.16.5 04-Feb-2008  yamt sync with head.
 1.24.16.4 07-Dec-2007  yamt sync with head
 1.24.16.3 03-Sep-2007  yamt sync with head.
 1.24.16.2 30-Dec-2006  yamt sync with head.
 1.24.16.1 21-Jun-2006  yamt sync with head.
 1.26.8.1 11-Aug-2006  yamt sync with head
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.22.2 02-Aug-2007  macallan sync with HEAD
 1.27.22.1 22-May-2007  matt Update to HEAD.
 1.27.16.1 11-Jul-2007  mjf Sync with head.
 1.27.14.3 03-Dec-2007  ad Sync with HEAD.
 1.27.14.2 03-Dec-2007  ad Sync with HEAD.
 1.27.14.1 27-May-2007  ad Sync with head.
 1.27.10.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.28.10.3 23-Mar-2008  matt sync with HEAD
 1.28.10.2 09-Jan-2008  matt sync with HEAD
 1.28.10.1 06-Nov-2007  matt sync with HEAD
 1.28.8.1 03-Dec-2007  joerg Sync with HEAD.
 1.29.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.29.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.30.6.2 23-Jan-2008  bouyer Sync with HEAD.
 1.30.6.1 08-Jan-2008  bouyer Sync with HEAD
 1.33.32.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.33.32.1 07-Jan-2011  matt Add PRIx{P,V}{ADDR,SIZE} and PRIxREGISTER
 1.33.10.2 11-Aug-2010  yamt sync with head.
 1.33.10.1 11-Mar-2010  yamt sync with head
 1.34.4.4 12-Jun-2011  rmind sync with head
 1.34.4.3 31-May-2011  rmind sync with head
 1.34.4.2 21-Apr-2011  rmind sync with head
 1.34.4.1 05-Mar-2011  rmind sync with head
 1.34.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.40.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.46.8.1 13-Jun-2012  riz Pull up following revision(s) (requested by matt in ticket #340):
sys/arch/powerpc/include/types.h: revision 1.47
sys/arch/powerpc/include/userret.h: revision 1.24
Add __HAVE_RAS support. Do it in userret.
 1.46.6.1 02-Jun-2012  mrg sync to latest -current.
 1.46.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.46.2.1 30-Oct-2012  yamt sync with head
 1.47.10.1 23-Jul-2013  riastradh sync with HEAD
 1.47.4.1 28-Aug-2013  rmind sync with head
 1.47.2.2 03-Dec-2017  jdolecek update from HEAD
 1.47.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.6.4 05-Feb-2017  skrll Sync with HEAD
 1.49.6.3 19-Mar-2016  skrll Sync with HEAD
 1.49.6.2 22-Sep-2015  skrll Sync with HEAD
 1.49.6.1 06-Apr-2015  skrll Sync with HEAD
 1.49.4.1 31-Dec-2014  snj Pull up following revision(s) (requested by chs in ticket #364):
lib/libc/tls/tls.c: revision 1.8
libexec/ld.elf_so/tls.c: revision 1.10
sys/arch/powerpc/include/types.h: revision 1.50
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.44
fix powerpc TLS problems by removing the hacks for PPC EABI.
the kernel no longer treats R2 specially and its use as
the TLS register is now handled entirely in userland.
 1.54.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.54.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.56.14.3 21-Apr-2020  martin Sync with HEAD
 1.56.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.56.14.1 10-Jun-2019  christos Sync with HEAD
 1.56.12.1 18-Jan-2019  pgoyette Synch with HEAD
 1.61.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.64.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.65.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.31 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.30 06-Jul-2015  matt Don't clear PSL_FP/PSL_VEC
 1.29 06-Jul-2015  matt Add a check to make sure that if PSL_FP is set, we own the FPU.
 1.28 10-Mar-2014  matt branches: 1.28.4; 1.28.6;
same typo
 1.27 10-Mar-2014  matt Typo
 1.26 09-Mar-2014  matt Make sure to clear PSL_SE before going to usermode on BOOKE
Revert back to testing PSL_SE in the trapframe and not mdlwp md_flags
 1.25 09-Mar-2014  matt Don't test for PSL_SE in tf_srr1 since will be cleared on the next exception.
Keep a copy of it in l_md.md_flags which will be preserved.
 1.24 26-May-2012  matt branches: 1.24.2; 1.24.4;
Add __HAVE_RAS support. Do it in userret.
 1.23 17-May-2012  matt Add an KASSERT to check that PSL_PR is always set.
 1.22 27-Sep-2011  jym branches: 1.22.2; 1.22.6; 1.22.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.21 20-Jun-2011  matt Explicitly include <powerpc/psl.h>
 1.20 02-May-2011  matt branches: 1.20.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.19 19-Feb-2011  matt Compare ci_veclwp against &lwp0, not NULL.
 1.18 17-Feb-2011  matt 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.17 18-Jan-2011  matt branches: 1.17.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.16 21-Nov-2009  rmind branches: 1.16.4; 1.16.6;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.15 06-Nov-2007  simonb branches: 1.15.18; 1.15.40;
Fix unused variable warning for the non-FPU/altivec case.
 1.14 05-Nov-2007  ad branches: 1.14.2;
Don't set l_usrpri / spc_curpriority here. mi_userret() does it.
 1.13 16-Feb-2006  perry branches: 1.13.24; 1.13.42; 1.13.44; 1.13.48;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.12 24-Dec-2005  perry branches: 1.12.2; 1.12.4; 1.12.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 16-Apr-2004  hannken branches: 1.10.12;
Make it compile when PPC_HAVE_FPU is not defined.
 1.9 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.8 06-Apr-2004  matt When seeing if the FP or VEC unit has been stolen by another process, check
PSL_{FP|VEC} instead of PCB_{FP|VEC}. The former will only be set if the
process owned the {FP,VEC} unit when it trapped into the kernel. The latter
would be set if the lwp ever used the {FP,VEC} unit.
 1.7 04-Apr-2004  matt When returning back to user mode, if the lwp has lost the FPU, not only
clear PSL_FP bit (to force a FPU Unavailable exception) but clear
PSL_FE0 and PSL_FE1 so that the FP execption mode is changes to ignore.
This will prevent spurious FP exceptions being made when the running lwp
doesn't own the FPU.
 1.6 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.5 31-Oct-2003  cl Reduce code duplication by adding mi_userret() in sys/userret.h
containing signal posting, kernel-exit handling and sa_upcall processing.

XXX the pc532, sparc, sparc64 and vax ports should have their
XXX userret() code rearranged to use this.
 1.4 18-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 08-Aug-2002  chs branches: 1.3.2; 1.3.4;
it's PPC_HAVE_FPU, not PPC_HAS_FPU.
also, include the headers that turn on FPU and AltiVec features
in case no one else does.
 1.2 06-Aug-2002  chs branches: 1.2.2;
actually we shouldn't hold kernel_lock while calling postsig().
 1.1 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.2.2.6 26-Sep-2002  nathanw Change "if (l->l_flag & L_SA_UPCALL)" to "while (l->l_flag & L_SA_UPCALL)"
in userret() functions or equivalent, to permit delivery of multiple upcalls
in a single kernel entry.

XXX It's getting crowded in here. Collapsing posting signals, upcalls, and
XXX kernel-exit handling into one mechanism would be nice.
 1.2.2.5 09-Aug-2002  nathanw Pull up PPC_HAVE_FPU fix.
 1.2.2.4 06-Aug-2002  nathanw A little more LWP.
 1.2.2.3 06-Aug-2002  nathanw Finish LWPifying.
 1.2.2.2 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.2.2.1 06-Aug-2002  nathanw file userret.h was added on branch nathanw_sa on 2002-08-06 22:47:10 +0000
 1.3.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.4.1 08-Aug-2002  jdolecek file userret.h was added on branch kqueue on 2002-09-06 08:39:18 +0000
 1.3.2.2 31-Aug-2002  gehenna catch up with -current.
 1.3.2.1 08-Aug-2002  gehenna file userret.h was added on branch gehenna-devsw on 2002-08-31 13:45:46 +0000
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.12.2 15-Nov-2007  yamt sync with head.
 1.10.12.1 21-Jun-2006  yamt sync with head.
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.12.2.1 18-Feb-2006  yamt sync with head.
 1.13.48.1 13-Nov-2007  bouyer Sync with HEAD
 1.13.44.1 06-Nov-2007  matt sync with HEAD
 1.13.42.1 06-Nov-2007  joerg Sync with HEAD.
 1.13.24.2 03-Dec-2007  ad Sync with HEAD.
 1.13.24.1 03-Dec-2007  ad Sync with HEAD.
 1.14.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.15.40.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.15.40.1 07-Jan-2011  matt Deal with the trapframe changes.
 1.15.18.1 11-Mar-2010  yamt sync with head
 1.16.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.4.2 31-May-2011  rmind sync with head
 1.16.4.1 05-Mar-2011  rmind sync with head
 1.17.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.20.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.8.5 18-May-2016  martin Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.29-1.30
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
(via patch)

Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.22.8.4 19-Nov-2015  bouyer Revert ticket 1310 (second try):
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.22.8.3 16-Nov-2015  bouyer Revert ticket 1310:
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.22.8.2 15-Nov-2015  bouyer Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.30
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revision 1.29
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/oea/altivec.c: revision 1.30
Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Don't reload if just re-enabling
Don't reload the FPU register if this is just a re-enable.
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.22.8.1 13-Jun-2012  riz Pull up following revision(s) (requested by matt in ticket #340):
sys/arch/powerpc/include/types.h: revision 1.47
sys/arch/powerpc/include/userret.h: revision 1.24
Add __HAVE_RAS support. Do it in userret.
 1.22.6.1 02-Jun-2012  mrg sync to latest -current.
 1.22.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.22.2.2 30-Oct-2012  yamt sync with head
 1.22.2.1 23-May-2012  yamt sync with head.
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.2 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.6.1 22-Sep-2015  skrll Sync with HEAD
 1.28.4.1 17-Jul-2015  snj Pull up following revision(s) (requested by matt in ticket #868):
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revisions 1.29, 1.30
sys/arch/powerpc/oea/altivec.c: revision 1.30
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
Add a check to make sure that if PSL_FP is set, we own the FPU.
--
Don't clear PSL_FP/PSL_VEC
--
Don't reload if just re-enabling
--
Don't reload the FPU register if this is just a re-enable.
--
Remove PSL_SPV from BOOKE PSL_USERMOD
--
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.7 27-Feb-2000  tsubai Rewrite stdarg/varargs.
 1.6 09-Feb-2000  tsubai Change va_arg definition when __lint__ is defined.
 1.5 03-Feb-2000  kleink Add a C99-style va_copy macro.
 1.4 02-Dec-1998  tsubai branches: 1.4.10;
Adapt to gcc change (calling sequence).
 1.3 05-Jan-1998  perry RCSID Police.
 1.2 16-Apr-1997  thorpej Update to varargs/stdarg implementation; conform to the SVR4 calling
convention.
 1.1 30-Sep-1996  ws PowerPC port
 1.4.10.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.10 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.9 04-Dec-2002  thorpej Revert my previous GCC 3.3-related changes; GCC 3.3 has been fixed
to handle our stdarg/varargs ABI for PowerPC.
 1.8 25-Oct-2002  thorpej Make these work with GCC 3.x.
 1.7 01-Jun-2002  tsubai Add gcc 3.x version.
 1.6 30-May-2001  tsubai branches: 1.6.2; 1.6.8; 1.6.16;
Add gcc-2.95 version.
 1.5 27-Feb-2000  tsubai branches: 1.5.6;
Rewrite stdarg/varargs.
 1.4 03-Feb-2000  kleink Add a C99-style va_copy macro.
 1.3 02-Dec-1998  tsubai branches: 1.3.10;
Adapt to gcc change (calling sequence).
 1.2 16-Apr-1997  thorpej Use new va-ppc.h
 1.1 30-Sep-1996  ws PowerPC port
 1.3.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.16.1 15-Jul-2002  gehenna catch up with -current.
 1.6.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.6.8.3 11-Nov-2002  nathanw Catch up to -current
 1.6.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.6.8.1 30-May-2001  nathanw file varargs.h was added on branch nathanw_sa on 2002-06-20 03:40:32 +0000
 1.6.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.27 15-Dec-2023  rin powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621
 1.26 11-May-2022  andvar branches: 1.26.4;
s/varible/variable/
 1.25 06-Jan-2021  rin Drop unused headers. No functional changes intended.
 1.24 06-Jul-2020  rin branches: 1.24.2;
Correct #ifdef; _MODULE not _MODULAR here.

Now __HAVE_PMAP_PHYSSEG is defined correctly for modules, which was
missing accidentally.
 1.23 27-Jun-2020  rin Restrict {MIN,MAX}_PAGE_SIZE for MODULAR || _MODULE, which makes
non-MODULAR kernel a little bit efficient.

They are also exposed to userland for jemalloc.
 1.22 29-Mar-2019  christos Go back to not always defining PAGE_{SIZE,SHIFT,MASK}
 1.21 27-Mar-2019  christos Provide the (max) defaults for page size for userland.
 1.20 23-Jun-2017  joerg branches: 1.20.6;
Recommit exec_subr.c revision 1.79:
Always include a 1MB guard area beyond the end of stack. While ASLR will
normally create a guard area as well, this provides a deterministic area
for all binaries.

Mitigates the rest of CVE-2017-1000374 and CVE-2017-1000375 from
Qualys.

Additionally, change VM_DEFAULT_ADDRESS_TOPDOWN to include
user_stack_guard_size in the size reservation.
 1.19 18-Oct-2014  snj branches: 1.19.2; 1.19.12;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.18 25-Jan-2014  christos delete VM_DEFAULT_ADDRESS; some of those should be GC'ed because they match
the default definition.
 1.17 23-Feb-2012  matt branches: 1.17.2; 1.17.4;
Export MIN_PAGE_SIZE and MAX_PAGE_SIZE for modular kernels.
 1.16 20-Jun-2011  matt branches: 1.16.2; 1.16.4; 1.16.8; 1.16.10;
Readd powerpc/include/vmparam.h to the set lists
Export it to powerpc/include.h
Protect pmap.h and vmparam.h from getting an #error when included
from userland.
Export safe definitions of VM_MAXUSER_ADDRESS, VM_MIN_ADDRESS,
VM_MAX_ADDRESS when _RUMPKERNEL is defined.
 1.15 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.14 20-Jun-2011  matt Don't export USER_SR if _MODULE is defined.
Add a common <powerpc/vmparam.h> like we have for <powerpc/pmap.h>
 1.13 16-Feb-2000  tsubai Unused. (PR 9424)
 1.12 11-Feb-2000  thorpej Update for the NKMEMPAGES changes.
 1.11 04-Dec-1999  ragge CL* discarding.
 1.10 02-May-1999  kleink branches: 1.10.2; 1.10.8;
Garbage-collect VM_MBUF_SIZE leftover.
 1.9 23-Mar-1999  thorpej branches: 1.9.4;
VM_MBUF_SIZE is in terms of MCLBYTES, not CLBYTES.
 1.8 16-Jan-1999  chuck MNN is no longer optional, remove old code
 1.7 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.6 08-Jul-1998  thorpej Define one page free list, and put all pages on it.
 1.5 05-Jun-1998  sakamoto Merge in MACHINE_NEW_NONCONTIG support and some fix from Tsubai-San.
UVM support.
 1.4 18-Feb-1998  mycroft Fix typo.
 1.3 12-Jun-1997  mrg bring mrg-vm-swap2 onto mainilne.
 1.2 16-Apr-1997  thorpej branches: 1.2.2;
Always define MACHINE_NONCONTIG.
 1.1 30-Sep-1996  ws branches: 1.1.4;
PowerPC port
 1.1.4.1 12-Feb-1997  mrg initial work for dynamic swap additions.
 1.2.2.1 04-May-1997  mrg re-merge mrg-vm-swap into -current, and call it mrg-vm-swap2.
 1.9.4.2 06-Aug-1999  chs take an initial guess at UBC parameters.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.16.10.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #255):
sys/arch/powerpc/include/vmparam.h: revision 1.17
Export MIN_PAGE_SIZE and MAX_PAGE_SIZE for modular kernels.
 1.16.8.1 24-Feb-2012  mrg sync to -current.
 1.16.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.4.1 17-Apr-2012  yamt sync with head
 1.16.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.16.2.1 20-Jun-2011  cherry file vmparam.h was added on branch cherry-xenmp on 2011-06-23 14:19:31 +0000
 1.17.4.1 18-May-2014  rmind sync with head
 1.17.2.2 03-Dec-2017  jdolecek update from HEAD
 1.17.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.12.1 31-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #234):
sys/arch/amd64/include/vmparam.h: revision 1.43
sys/kern/exec_subr.c: revision 1.79
lib/libpthread/pthread_int.h: revision 1.94
sys/arch/mips/include/vmparam.h: revision 1.58
sys/arch/mips/include/vmparam.h: revision 1.59
lib/libpthread/TODO: revision 1.19
sys/arch/powerpc/include/vmparam.h: revision 1.20
sys/arch/riscv/include/vmparam.h: revision 1.2
sys/arch/riscv/include/vmparam.h: revision 1.3
sys/arch/i386/include/vmparam.h: revision 1.85
tests/lib/libpthread/t_join.c: revision 1.9
sys/uvm/uvm_meter.c: revision 1.66
sys/uvm/uvm_param.h: revision 1.36
sys/kern/exec_subr.c: revision 1.80
sys/uvm/uvm_param.h: revision 1.37
sys/kern/exec_subr.c: revision 1.81
sys/kern/exec_subr.c: revision 1.82
lib/libpthread/pthread_attr_getguardsize.3: revision 1.4
lib/libpthread/pthread.c: revision 1.148
lib/libpthread/pthread_attr.c: revision 1.17
sys/arch/amd64/include/vmparam.h: revision 1.42
Always include a 1MB guard area beyond the end of stack. While ASLR will
normally create a guard area as well, this provides a deterministic area
for all binaries.
Mitigates the rest of CVE-2017-1000374 and CVE-2017-1000375 from
Qualys.
Revert for the moment, creates problems on i386.
Recommit exec_subr.c revision 1.79:
Always include a 1MB guard area beyond the end of stack. While ASLR will
normally create a guard area as well, this provides a deterministic area
for all binaries.
Mitigates the rest of CVE-2017-1000374 and CVE-2017-1000375 from
Qualys.
Additionally, change VM_DEFAULT_ADDRESS_TOPDOWN to include
user_stack_guard_size in the size reservation.
Update VM_DEFAULT_ADDRESS32_TOPDOWN to include guard area.
Export the guard size of the main thread via vm.guard_size. Add a
complementary writable sysctl for the initial guard size of threads
created via pthread_create. Let the existing attribut accessors do the
right thing. Raise the default guard size for threads to 64KB.
 1.19.2.1 28-Aug-2017  skrll Sync with HEAD
 1.20.6.1 10-Jun-2019  christos Sync with HEAD
 1.24.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.26.4.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 11-Dec-2005  christos branches: 1.2.74; 1.2.76; 1.2.78;
merge ktrace-lwp.
 1.1 08-May-2004  kleink branches: 1.1.2;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 08-May-2004  skrll file wchar_limits.h was added on branch ktrace-lwp on 2004-08-03 10:39:29 +0000
 1.2.78.1 16-May-2008  yamt sync with head.
 1.2.76.1 18-May-2008  yamt sync with head.
 1.2.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.1 09-Mar-2010  matt branches: 1.1.2; 1.1.6; 1.1.8;
Add initial versions of these for BookE.
 1.1.8.4 07-Jan-2011  matt Fix cut & paste error.
 1.1.8.3 07-Jan-2011  matt Add usr/include/powerpc/booke and usr/include/powerpc/booke/spr.h
 1.1.8.2 07-Jan-2011  matt Descend into the booke include diretory
 1.1.8.1 09-Mar-2010  matt file Makefile was added on branch matt-nb5-pq3 on 2011-01-07 02:11:36 +0000
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 09-Mar-2010  uebayasi file Makefile was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file Makefile was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.2 01-Apr-2010  matt Change booke_intr.h to intr.h since <powerpc/booke/intr.h> will be unique
enough.
 1.1 09-Mar-2010  matt branches: 1.1.2; 1.1.4;
Add initial versions of these for BookE.
 1.1.4.1 30-May-2010  rmind sync with head
 1.1.2.3 11-Aug-2010  yamt sync with head.
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file booke_intr.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.21 06-Jul-2020  rin Include missing opt_multiprocessor.h.
 1.20 07-Apr-2019  thorpej Detangle some of the PowerPC CPU configuration spaghetti.
 1.19 19-Apr-2018  christos branches: 1.19.2;
s/static inline/static __inline/g for consistency.
 1.18 16-Jun-2015  matt branches: 1.18.16;
This needs to define PRIxPTE too.
 1.17 02-Oct-2012  christos branches: 1.17.14;
move common tlb stuff to uvm
 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 01-Aug-2012  matt Export dump_trapframe.
 1.14 29-Jul-2012  matt Add command line processing from uboot
bootm $loadaddr [opts] [device]
where opts is -[advqs] and device is the boot device.
cpu_rootconf will now wait a bit for devices to appear until the boot device
appears.
 1.13 27-Jul-2012  matt Fix -fno-common fallout.
 1.12 30-Jun-2011  matt branches: 1.12.2;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.11 29-Jun-2011  matt Declare cpu_hatch_data
 1.10 23-Jun-2011  matt Switch to using the common <common/pmap/tlb/tlb.h>
 1.9 20-Jun-2011  matt Explicitly include <powerpc/psl.h>
 1.8 15-Jun-2011  matt Move booke_fixup_stubs() to fixup.c and rename it to cpu_fixup_stubs().
This makes it easier for other PPC variants to use it.
 1.7 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.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 17-Feb-2011  matt branches: 1.5.2; 1.5.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.4 16-Feb-2011  matt Add little endian bus_space_tags.
Note highest memory in cpu_softc.
 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 cpuvar.h 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 02-Aug-2011  matt Pull in changes from -current to get ehci at cpunode working.
 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.3 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.5.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.2.3 12-Jun-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 cpuvar.h was added on branch rmind-uvmplock on 2011-03-05 20:51:37 +0000
 1.12.2.1 30-Oct-2012  yamt sync with head
 1.16.2.2 03-Dec-2017  jdolecek update from HEAD
 1.16.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.14.1 22-Sep-2015  skrll Sync with HEAD
 1.18.16.1 22-Apr-2018  pgoyette Sync with HEAD
 1.19.2.1 10-Jun-2019  christos Sync with HEAD
 1.17 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.16 27-Dec-2014  nonaka Added SPI register definitions.
 1.15 27-Dec-2014  nonaka Preliminary support for P1023.
 1.14 26-Jul-2012  matt branches: 1.14.2; 1.14.16;
Add ESDHC DCR definitions
 1.13 18-Jul-2012  matt Add P1025 support to the PCI truth tables.
P1025 only has two PCIe ports, not 3.
 1.12 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.11 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.10 02-Aug-2011  matt branches: 1.10.2;
Add some more DDR register definitions
 1.9 30-Jun-2011  matt Add LSOR register
 1.8 09-Jun-2011  matt Correct definitions of USB_SNOOP registers. Add USB_CONTROL register.
 1.7 28-May-2011  matt branches: 1.7.2;
Add Boot Page PTR Register definitions.
 1.6 02-May-2011  matt Add LBC FCM defintions (for NAND).
 1.5 16-Mar-2011  matt Fix various nits related to P2020 support.
 1.4 16-Feb-2011  matt branches: 1.4.2;
Add USB_SNOOP1/2 related definitions
 1.3 08-Feb-2011  matt Add some P2020 / MPC856x definitions.
 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 e500reg.h 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 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.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.4.2.5 12-Jun-2011  rmind sync with head
 1.4.2.4 31-May-2011  rmind sync with head
 1.4.2.3 21-Apr-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 e500reg.h was added on branch rmind-uvmplock on 2011-03-05 20:51:37 +0000
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.2.1 30-Oct-2012  yamt sync with head
 1.14.16.1 06-Apr-2015  skrll Sync with HEAD
 1.14.2.1 03-Dec-2017  jdolecek update from HEAD
 1.9 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.8 06-Jul-2020  rin e500_cpunode_submatch() should be declared regardless of _KERNEL_OPT.
 1.7 27-Nov-2012  matt 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.6 27-Jul-2012  matt branches: 1.6.2;
Fix -fno-common fallout.
 1.5 29-Mar-2012  matt Add e500_tlb_minimize prototype.
 1.4 29-Jun-2011  matt branches: 1.4.2; 1.4.6; 1.4.8;
Add some e500 MP prototypes.
 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 e500var.h 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.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 e500var.h was added on branch rmind-uvmplock on 2011-03-05 20:51:37 +0000
 1.4.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.4.6.1 05-Apr-2012  mrg sync to latest -current.
 1.4.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.4.2.2 30-Oct-2012  yamt sync with head
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.6.2.1 25-Feb-2013  tls resync with head
 1.12 05-Nov-2024  andvar s/UCP/UDP/ in comments.
 1.11 26-Feb-2024  andvar branches: 1.11.2;
s/Transmi /Transmit / in comments.
 1.10 11-May-2022  andvar fix various typos in comments.
 1.9 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.8 26-Feb-2015  nonaka Added some register definitions for multi-queue.
 1.7 26-Feb-2015  nonaka fix offset value of RBASEn.
 1.6 17-Feb-2015  nonaka Added Interrupt coalescing support.
 1.5 17-Jul-2012  matt branches: 1.5.2; 1.5.16;
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.4 07-May-2012  matt Preserve some MACCFG2 bits
 1.3 09-Jun-2011  matt branches: 1.3.2; 1.3.6; 1.3.8;
Fix ATTR register definitions
 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 etsecreg.h 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.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 etsecreg.h was added on branch rmind-uvmplock on 2011-03-05 20:51:37 +0000
 1.3.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.3.6.1 02-Jun-2012  mrg sync to latest -current.
 1.3.2.2 30-Oct-2012  yamt sync with head
 1.3.2.1 23-May-2012  yamt sync with head.
 1.5.16.1 06-Apr-2015  skrll Sync with HEAD
 1.5.2.1 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 12-Sep-2022  rin PR port-powerpc/56922

__HAVE_FAST_SOFTINTS is broken for powerpc.
Disable it temporarily also for booke.
 1.12 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.11 19-Apr-2018  christos branches: 1.11.2;
s/static inline/static __inline/g for consistency.
 1.10 19-Oct-2016  nonaka branches: 1.10.14;
Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.9 23-Jan-2015  nonaka branches: 1.9.2;
ddb MP support
 1.8 19-May-2014  rmind branches: 1.8.4;
Implement MI IPI interface with cross-call support.
 1.7 29-Mar-2014  christos branches: 1.7.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.6 21-Jun-2011  matt branches: 1.6.2; 1.6.12; 1.6.16;
forward declare cpu_info and trapframe.
 1.5 15-Jun-2011  matt Add IST_PULSE and intr_typename (converts IST_* to a name).
 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 08-Feb-2011  matt branches: 1.3.2;
Add IPI/cpu_send_ipi to intrsw.
 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 01-Apr-2010  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Change booke_intr.h to intr.h since <powerpc/booke/intr.h> will be unique
enough.
 1.1.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.8.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.1.8.1 01-Apr-2010  matt file intr.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 01-Apr-2010  yamt file intr.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:34 +0000
 1.1.4.4 12-Jun-2011  rmind sync with head
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 01-Apr-2010  rmind file intr.h was added on branch rmind-uvmplock on 2010-05-30 05:17:03 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 01-Apr-2010  uebayasi file intr.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.16.1 18-May-2014  rmind sync with head
 1.6.12.2 03-Dec-2017  jdolecek update from HEAD
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.2.1 10-Aug-2014  tls Rebase.
 1.8.4.2 05-Dec-2016  skrll Sync with HEAD
 1.8.4.1 06-Apr-2015  skrll Sync with HEAD
 1.9.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.10.14.1 22-Apr-2018  pgoyette Sync with HEAD
 1.11.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 30-Jun-2011  matt branches: 1.2.2;
Add prototypes for lbc_* routines.
 1.1 28-May-2011  matt branches: 1.1.2; 1.1.6;
Move obio softc definitions to a header so it can use by children of obio.
 1.1.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 28-May-2011  jruoho file obiovar.h was added on branch jruoho-x86intr on 2011-06-06 09:06:28 +0000
 1.1.2.2 31-May-2011  rmind sync with head
 1.1.2.1 28-May-2011  rmind file obiovar.h was added on branch rmind-uvmplock on 2011-05-31 03:04:14 +0000
 1.2.2.2 26-Jul-2011  matt Back port improvements from -HEAD.
 1.2.2.1 30-Jun-2011  matt file obiovar.h was added on branch matt-nb5-pq3 on 2011-07-26 03:35:25 +0000
 1.7 27-Dec-2014  nonaka Preliminary support for P1023.
 1.6 15-Jul-2012  matt branches: 1.6.2; 1.6.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.5 02-Aug-2011  matt branches: 1.5.2;
MPC8544 don't any onchip irqs of 20/21
 1.4 27-May-2011  matt Fix P20x0_ONCHIPBITMAP to reflect latest P2020RM.
 1.3 08-Feb-2011  matt Add MPC8555/41, MPC8568/67, and P2020 variations.
 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 01-Apr-2010  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
OpenPIC register defintions used by e500 booke.
 1.1.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.8.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.1.8.1 01-Apr-2010  matt file openpicreg.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 01-Apr-2010  yamt file openpicreg.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:34 +0000
 1.1.4.4 31-May-2011  rmind sync with head
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 01-Apr-2010  rmind file openpicreg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:03 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 01-Apr-2010  uebayasi file openpicreg.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.5.2.1 30-Oct-2012  yamt sync with head
 1.6.16.1 06-Apr-2015  skrll Sync with HEAD
 1.6.2.1 03-Dec-2017  jdolecek update from HEAD
 1.25 28-Sep-2023  skrll #define<space> -> #define<tab> for consistency
 1.24 20-Dec-2020  skrll Support __HAVE_PMAP_PV_TRACK in sys/uvm/pmap based pmaps (aka common pmap)
 1.23 07-Aug-2020  skrll branches: 1.23.2;
Provide a pmap_segtab_deactivate for symmetry with pmap_segtab_activate
and use it in pmap_deactivate

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

Provide empty (for now) pmap_md_xtab_{,de}activate functions on the
platforms that use sys/uvm/pmap
 1.22 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.21 08-Apr-2020  skrll Simplify #ifdefs
 1.20 12-Mar-2020  thorpej If we're going to consult the MULTIPROCESSOR option, we should pull in
"opt_multiprocessor.h".
 1.19 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.18 19-Apr-2018  christos branches: 1.18.2;
s/static inline/static __inline/g for consistency.
 1.17 24-Dec-2016  cherry branches: 1.17.14;
Tell mpc85xx about uvm_hotplug(9)

Should fix the evbppc build breakage.
 1.16 11-Jul-2016  matt branches: 1.16.2;
Adapt to common pmap changes.
 1.15 26-Jan-2015  nonaka Avoid race condition between PTE update and TLB miss walk.
 1.14 03-Apr-2014  matt branches: 1.14.6;
Add PMAP_TLB_FLUSH_ASID_ON_RESET define
 1.13 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.12 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.11 02-Oct-2012  christos branches: 1.11.2; 1.11.8;
move common tlb stuff to uvm
 1.10 09-Jul-2012  matt branches: 1.10.2;
Use pmap_segtab_t
 1.9 29-Mar-2012  matt Add vsize_t to pmap_md_{un,}map_poolpage.
Add pmap_kvptefill prototype.
Slightly change pmap_bootstrap prototype.
 1.8 30-Jun-2011  matt branches: 1.8.2; 1.8.6; 1.8.8;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 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 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 17-Feb-2011  matt branches: 1.4.2; 1.4.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.3 08-Feb-2011  matt BookE needs PMAP_NEEDS_PROCWR (for ptrace breakpoints)
 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 pmap.h 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.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 08-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 17-Feb-2011  rmind file pmap.h was added on branch rmind-uvmplock on 2011-03-05 20:51:37 +0000
 1.8.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.8.6.1 05-Apr-2012  mrg sync to latest -current.
 1.8.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.8.2.2 30-Oct-2012  yamt sync with head
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.10.2.3 03-Dec-2017  jdolecek update from HEAD
 1.10.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.8.1 23-Jul-2013  riastradh sync with HEAD
 1.11.2.2 18-May-2014  rmind sync with head
 1.11.2.1 28-Aug-2013  rmind sync with head
 1.14.6.3 05-Feb-2017  skrll Sync with HEAD
 1.14.6.2 05-Oct-2016  skrll Sync with HEAD
 1.14.6.1 06-Apr-2015  skrll Sync with HEAD
 1.16.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.14.1 22-Apr-2018  pgoyette Sync with HEAD
 1.18.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.23.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.11 22-Aug-2020  skrll Remove pte_zero_p and simply check against 0.
 1.10 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.9 24-Jun-2017  skrll branches: 1.9.4;
Provide a pte_set
 1.8 11-Jul-2016  matt Adapt to common pmap changes.
 1.7 11-Jun-2015  matt Add PRIxPTE and pte_value(pt_entry_t) for printing the value of a PTE.
Add pte_zero_p(pt_entry_t) to check that a PTE has been zeroed.
 1.6 30-Jun-2011  matt branches: 1.6.12; 1.6.30;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.5 23-Jun-2011  matt Redo how the pte_*wire* inlines work. Now pmap.c makes no assuming about
what type pt_entry_t. It can now be a scalar or a union/struct.
 1.4 23-Jun-2011  matt Switch to using the common <common/pmap/tlb/tlb.h>
 1.3 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.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 09-Mar-2010  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add initial versions of these for BookE.
 1.1.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.8.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.1.8.1 09-Mar-2010  matt file pte.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 09-Mar-2010  uebayasi file pte.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.1.4.1 05-Mar-2011  rmind sync with head
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file pte.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.2.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.30.3 28-Aug-2017  skrll Sync with HEAD
 1.6.30.2 05-Oct-2016  skrll Sync with HEAD
 1.6.30.1 22-Sep-2015  skrll Sync with HEAD
 1.6.12.1 03-Dec-2017  jdolecek update from HEAD
 1.9.4.1 22-Apr-2018  pgoyette Sync with HEAD
 1.15 05-Dec-2021  msaitoh s/seach/search/
 1.14 03-Aug-2021  andvar Fix various typos in comments. Also add missing NetBSD RCS Id in some of these files.
 1.13 27-Dec-2014  nonaka Added MMUv2 define.
 1.12 20-Dec-2014  nonaka Added P1023/P1017.
 1.11 01-Aug-2012  matt branches: 1.11.2; 1.11.16;
Fix some copy&paste bugs.
 1.10 18-Jul-2012  matt Add some more PVRs and SVRs
 1.9 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.8 09-Jul-2012  matt Add some e500mc/e5500 machines.
 1.7 05-Jun-2011  matt branches: 1.7.2;
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 29-Apr-2011  matt branches: 1.6.2;
Add some P10xx SVRs
 1.5 16-Feb-2011  matt Add MPC8533 SVR. Fix DBCR0 IAC bits
 1.4 08-Feb-2011  matt Add more MPC85xx SVRs.
Fix/add debug register definitions.
 1.3 18-Jan-2011  matt branches: 1.3.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.2 01-Apr-2010  matt branches: 1.2.2; 1.2.4; 1.2.6;
Fix some TCR definitions.
 1.1 09-Mar-2010  matt branches: 1.1.2; 1.1.4;
Add initial versions of these for BookE.
 1.1.4.4 12-Jun-2011  rmind sync with head
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 30-May-2010  rmind sync with head
 1.1.2.3 11-Aug-2010  yamt sync with head.
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file spr.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.2.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.2.4.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.1 01-Apr-2010  matt file spr.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.2.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.2.1 01-Apr-2010  uebayasi file spr.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.3.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.3.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.2.1 30-Oct-2012  yamt sync with head
 1.11.16.1 06-Apr-2015  skrll Sync with HEAD
 1.11.2.1 03-Dec-2017  jdolecek update from HEAD
 1.2 18-Jan-2011  matt 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 09-Mar-2010  matt branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add initial versions of these for BookE.
 1.1.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.1.8.1 09-Mar-2010  matt file trap.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 09-Mar-2010  uebayasi file trap.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.1.4.1 05-Mar-2011  rmind sync with head
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file trap.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.10 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.9 17-Apr-2021  rin Sync MAXfoo params with oea:

MAXTSIZ: 512MB -> 128MB
MAXDSIZ: 3.25GB -> 1GB

There should be no particular reasons for having different values.
 1.8 17-Apr-2021  rin PR port-powerpc/56107

Decrease MAXSSIZ from ~256MB to 32MB (same as oea).

This fixes tests in /usr/tests/usr.bin/make, that run with "ulimit -v 200000",
fail with "Cannot map anonymous memory".

Although I'm not fully convinced whether this limit is reasonable or not,
old MAXSSIZ of ~256MB is too much anyway.
 1.7 02-Oct-2012  christos branches: 1.7.52;
move common tlb stuff to uvm
 1.6 09-Jul-2012  matt branches: 1.6.2;
Allow the use of the full 4GB address space.
 1.5 20-Jun-2011  matt branches: 1.5.2;
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.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 18-Jan-2011  matt branches: 1.3.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.2 06-Nov-2010  uebayasi branches: 1.2.2; 1.2.4;
Remove incomplete, never worked dynamic run-time memory registration
(uvm_page_physload(9)). This functionality will be re-added later.
 1.1 09-Mar-2010  matt branches: 1.1.2; 1.1.4; 1.1.6;
Add initial versions of these for BookE.
 1.1.6.3 27-May-2010  uebayasi VM_PHYSSEG_NOADD is no more.
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 09-Mar-2010  uebayasi file vmparam.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.1.4.2 12-Jun-2011  rmind sync with head
 1.1.4.1 05-Mar-2011  rmind sync with head
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 09-Mar-2010  yamt file vmparam.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.2.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.2.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.2.2.2 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 06-Nov-2010  matt file vmparam.h was added on branch matt-nb5-pq3 on 2011-01-07 01:26:20 +0000
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.2.1 30-Oct-2012  yamt sync with head
 1.6.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.7.52.1 17-Apr-2021  thorpej Sync with HEAD.
 1.6 25-Feb-2010  matt Split <powerpc/spr.h> into a common <powerpc/spr.h> and <powerpc/XXX/spr.h>
where XXX is ibm4xx or oea.
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.98; 1.5.102;
merge ktrace-lwp.
 1.4 19-Jan-2005  chs ibm4xx/pte.h is no more.
 1.3 26-Nov-2002  lukem branches: 1.3.6; 1.3.14;
Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.2 10-Apr-2002  briggs Install cpu.h. Noted in PR port-powerpc/16285 from smi@sm.sony.co.jp.
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.3 11-Dec-2002  thorpej Sync with HEAD.
 1.1.8.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.8.1 13-Jun-2001  nathanw file Makefile was added on branch nathanw_sa on 2002-04-17 00:04:12 +0000
 1.1.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.14.1 29-Apr-2005  kent sync with -current
 1.3.6.1 24-Jan-2005  skrll Sync with HEAD.
 1.5.102.1 07-Jan-2011  matt Add spr.h
 1.5.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.78.1 11-Mar-2010  yamt sync with head
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file amcc405ex.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:34 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file amcc405ex.h was added on branch rmind-uvmplock on 2010-05-30 05:17:03 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file amcc405ex.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.4 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.3 15-Jun-2003  fvdl branches: 1.3.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.2 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.1 09-Dec-2002  scw branches: 1.1.2;
Changes/additions to support evbppc.
 1.1.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 09-Dec-2002  thorpej file bus.h was added on branch nathanw_sa on 2002-12-11 06:11:42 +0000
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.27 02-Nov-2021  ryo fix build with COPTS=-O0
 1.26 31-May-2021  simonb Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include <machine/param.h>.
 1.25 30-Mar-2021  rin branches: 1.25.2;
Convert walnut to use powerpc/ibm4xx/openbios.
No functional changes.
 1.24 30-Mar-2021  rin G/C bootpath.
 1.23 29-Mar-2021  rin Set com(4) frequency in ibm4xx_device_register() in order to dedup codes.
 1.22 19-Apr-2018  christos branches: 1.22.14; 1.22.16;
s/static inline/static __inline/g for consistency.
 1.21 27-Jul-2012  matt branches: 1.21.38;
Fix some -fno-common fallout
 1.20 20-Jun-2011  matt branches: 1.20.2;
Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.19 20-Jun-2011  matt Explicitly include <powerpc/psl.h>
 1.18 18-Jun-2011  matt Move PVR definitions to <powerpc/ibm4xx/spr.h>
No need to include <powerpc/cpu.h> in <powerpc/ib4xx/cpu.h>
 1.17 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.16 18-Jan-2011  matt branches: 1.16.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.15 18-Mar-2010  kiyohara branches: 1.15.2;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.14 14-Mar-2009  dsl branches: 1.14.2; 1.14.4;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.13 31-Aug-2006  freza branches: 1.13.60; 1.13.68; 1.13.74; 1.13.82;
* add PVR values for Xilinx 405 cores
* don't try to decode vendor-specific PVR, print raw value instead.
* panic() if we see cache wasn't probed, we'd crash later anyway.
* rework the way PVR gets translated to core name.
* while there, normalize printf format ("%s: ...", device_xname(self), ...).

OK by matt@
 1.12 05-May-2006  thorpej Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10; 1.11.12;
merge ktrace-lwp.
 1.10 21-Jan-2005  shige branches: 1.10.8;
Add consinit() and md_consinit funcptr to ibm4xx/machdep.c.
Rename consinit() to obs405_consinit() at evbppc/obs405/consinit.c.

Set md_consinit to obs405_consinit() at initppc().
Consinit fuction calls a function stored at md_consinit pointer.
 1.9 18-Jan-2005  shige Arrange some machine-dependent code.
- ibm40x_machdep.c: ibm40x specific
. ibm40x_memsize_init
. mem_regions
. other functions are moved to machdep.c or ibm4xx_machdep.c.
- ibm4xx_machdep.c: ibm4xx specific
. ibm4xx_init (moved from ibm40x_machdep.c)
. ibm4xx_install_extint (moved from ibm40x_machdep.c)
. ibm4xx_cpu_startup (moved from ibm40x_machdep.c:ibm4xx_startup)
. ibm4xx_dumpsys
 1.8 17-Jan-2005  shige Remove openbios dependent code from ibm4xx/ibm40x dependent module.
 1.7 13-Jan-2005  shige branches: 1.7.2;
Add externs:
- md_device_register (func ptr)
- ibm4xx_device_register (func)
 1.6 23-Sep-2003  shige branches: 1.6.6;
Add IBM40x specific machdep functions.
 1.5 13-Jun-2003  msaitoh branches: 1.5.2;
Add support IBM 405GPr
 1.4 11-Aug-2002  simonb Define the 4xx PVR values in one place only.
 1.3 13-May-2002  matt branches: 1.3.2; 1.3.6;
Remove redundant declarations.
 1.2 15-Mar-2002  eeh branches: 1.2.4;
Use properties to pass around board-specific information rather than a
structure.
 1.1 13-Mar-2002  eeh Add this file.
 1.2.4.4 13-Aug-2002  nathanw Catch up to -current.
 1.2.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.1 15-Mar-2002  nathanw file cpu.h was added on branch nathanw_sa on 2002-04-01 07:42:05 +0000
 1.3.6.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.1 13-May-2002  jdolecek file cpu.h was added on branch kqueue on 2002-06-23 17:39:43 +0000
 1.3.2.1 31-Aug-2002  gehenna catch up with -current.
 1.5.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.5.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.6.1 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.7.2.1 29-Apr-2005  kent sync with -current
 1.10.8.2 30-Dec-2006  yamt sync with head.
 1.10.8.1 21-Jun-2006  yamt sync with head.
 1.11.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.10.1 11-May-2006  elad sync with head
 1.11.8.2 03-Sep-2006  yamt sync with head.
 1.11.8.1 24-May-2006  yamt sync with head.
 1.11.6.1 01-Jun-2006  kardel Sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.13.82.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.13.74.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.68.1 28-Apr-2009  skrll Sync with HEAD.
 1.13.60.2 11-Aug-2010  yamt sync with head.
 1.13.60.1 04-May-2009  yamt sync with head.
 1.14.4.2 05-Mar-2011  rmind sync with head
 1.14.4.1 30-May-2010  rmind sync with head
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.20.2.1 30-Oct-2012  yamt sync with head
 1.21.38.1 22-Apr-2018  pgoyette Sync with HEAD
 1.22.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.22.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.25.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.3 13-Mar-2002  eeh Delete this file. It's only relevent to 405gp.
 1.2 29-Aug-2001  simonb branches: 1.2.6;
Gah, fix a number of channel status/select bitfields.
 1.1 13-Jun-2001  simonb branches: 1.1.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.6.1 29-Aug-2001  nathanw file dcr.h was added on branch nathanw_sa on 2002-04-01 07:42:05 +0000
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 30-May-2006  freza branches: 1.3.60; 1.3.62; 1.3.64;
Remove duplicate definitions of mfdcr()/mtdcr() in favor of a single one
in cpu.h

OK Matt Thomas
 1.2 24-Dec-2005  perry branches: 1.2.4; 1.2.6; 1.2.8; 1.2.14;
bare asm -> __asm
 1.1 11-Mar-2003  hannken branches: 1.1.18;
Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.1.18.1 21-Jun-2006  yamt sync with head.
 1.2.14.1 19-Jun-2006  chap Sync with head.
 1.2.8.1 26-Jun-2006  yamt sync with head.
 1.2.6.1 01-Jun-2006  kardel Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.3.64.1 16-May-2008  yamt sync with head.
 1.3.62.1 18-May-2008  yamt sync with head.
 1.3.60.1 02-Jun-2008  mjf Sync with HEAD.
 1.6 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.5 30-May-2006  freza branches: 1.5.64; 1.5.78; 1.5.84; 1.5.86;
Remove duplicate definitions of mfdcr()/mtdcr() in favor of a single one
in cpu.h

OK Matt Thomas
 1.4 24-Dec-2005  perry branches: 1.4.4; 1.4.6; 1.4.8; 1.4.14;
bare asm -> __asm
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 27-Jul-2003  simonb branches: 1.2.16;
Whitespace alignment nits.
 1.1 13-Mar-2002  eeh branches: 1.1.4; 1.1.10; 1.1.16;
405gp-specific DCRs.
 1.1.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 13-Mar-2002  jdolecek file dcr405gp.h was added on branch kqueue on 2002-06-23 17:39:44 +0000
 1.1.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.1 13-Mar-2002  nathanw file dcr405gp.h was added on branch nathanw_sa on 2002-04-01 07:42:05 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.4.14.1 19-Jun-2006  chap Sync with head.
 1.4.8.1 26-Jun-2006  yamt sync with head.
 1.4.6.1 01-Jun-2006  kardel Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.86.1 30-May-2010  rmind sync with head
 1.5.84.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.78.1 24-Oct-2010  jym Sync with HEAD
 1.5.64.1 11-Aug-2010  yamt sync with head.
 1.6 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.5 30-May-2006  freza branches: 1.5.64; 1.5.78; 1.5.84; 1.5.86;
Remove duplicate definitions of mfdcr()/mtdcr() in favor of a single one
in cpu.h

OK Matt Thomas
 1.4 24-Dec-2005  perry branches: 1.4.4; 1.4.6; 1.4.8; 1.4.14;
bare asm -> __asm
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 17-Dec-2004  shige branches: 1.2.2; 1.2.12;
Substitute PPC405_ with PPC_IBM405_.
 1.1 01-Dec-2004  shige Add header file for IBM405XX(AMCC405XX) Device Control Registers.
 1.2.12.1 21-Jun-2006  yamt sync with head.
 1.2.2.2 18-Dec-2004  skrll Sync with HEAD.
 1.2.2.1 17-Dec-2004  skrll file dcr405xx.h was added on branch ktrace-lwp on 2004-12-18 09:31:26 +0000
 1.4.14.1 19-Jun-2006  chap Sync with head.
 1.4.8.1 26-Jun-2006  yamt sync with head.
 1.4.6.1 01-Jun-2006  kardel Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.86.1 30-May-2010  rmind sync with head
 1.5.84.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.78.1 24-Oct-2010  jym Sync with HEAD
 1.5.64.1 11-Aug-2010  yamt sync with head.
 1.4 02-Apr-2021  rin Add bit-field definitions for DCR_SDRAM0_B[0-3]CR registers.
 1.3 21-Nov-2013  kiyohara branches: 1.3.42; 1.3.44;
Support Synopsys DesigneWave OTG on PowerPC 405EX.
 1.2 06-Nov-2010  uebayasi branches: 1.2.8; 1.2.18; 1.2.22;
More registers to support IBM405GPr "External Bus".
 1.1 18-Mar-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 18-Mar-2010  yamt file dcr4xx.h was added on branch yamt-nfs-mp on 2010-08-11 22:52:34 +0000
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 18-Mar-2010  rmind file dcr4xx.h was added on branch rmind-uvmplock on 2010-05-30 05:17:03 +0000
 1.1.2.3 11-Aug-2010  uebayasi Implement 405GPr's "External Bus" as exb(4).
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 18-Mar-2010  uebayasi file dcr4xx.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.2.22.1 18-May-2014  rmind sync with head
 1.2.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.8.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.44.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3.42.1 03-Apr-2021  thorpej Sync with HEAD.
 1.11 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.10 11-Dec-2005  christos branches: 1.10.78; 1.10.98; 1.10.100;
merge ktrace-lwp.
 1.9 23-Sep-2003  shige Add some PCI definitions listed in evbppc/include/walnut.h.
 1.8 13-Aug-2002  simonb branches: 1.8.6;
Use "ibm4xx" instead of "galaxy"; galaxy was an early code name for the
405GP.
 1.7 13-Aug-2002  simonb Split out device register definitions to their own files as the are
common across many of the 4xx parts. Leaves ibm405gp.h with device
address information specific to the 405GP CPU. Now allows opb.c to
support multiple 4xx CPU types.
 1.6 11-Aug-2002  simonb Define the 4xx PVR values in one place only.
 1.5 21-Oct-2001  simonb branches: 1.5.4; 1.5.12;
Fix typo, noted by Artem Belevich.
 1.4 14-Aug-2001  simonb Fix typo, noted by UCHIYAMA Yasushi in private mail.
 1.3 25-Jun-2001  simonb branches: 1.3.2;
Fix typo in emac0 base address.
 1.2 24-Jun-2001  simonb Move 405GP registers, addresses and other info to ibm405gp.h. Leave only
board-specific addresses and other info in walnut.h.
 1.1 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.3.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.5.12.1 31-Aug-2002  gehenna catch up with -current.
 1.5.4.3 27-Aug-2002  nathanw Catch up to -current.
 1.5.4.2 13-Aug-2002  nathanw Catch up to -current.
 1.5.4.1 21-Oct-2001  nathanw file ibm405gp.h was added on branch nathanw_sa on 2002-08-13 02:18:46 +0000
 1.8.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.6.1 03-Aug-2004  skrll Sync with HEAD
 1.10.100.1 30-May-2010  rmind sync with head
 1.10.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.78.1 11-Aug-2010  yamt sync with head.
 1.21 20-Jun-2011  matt Change IBM4xx to use the common powerpc PIC framework.
Consolidate most ibm4xx initppc function into ibm4xx_init
and Make all IBM4xx use it.
Change explora to use initppc instead of bootstrap.
 1.20 12-May-2011  kiyohara branches: 1.20.2;
Fix spl0(). Our IPL_NONE is not 0.
 1.19 18-Jan-2011  matt 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.18 24-Apr-2010  kiyohara branches: 1.18.2;
Support 64-bit imask for powerpc/pic.
 1.17 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.16 28-Apr-2008  martin branches: 1.16.20; 1.16.22; 1.16.26;
Remove clause 3 and 4 from TNF licenses
 1.15 03-Dec-2007  ad branches: 1.15.14; 1.15.16; 1.15.18;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.14 21-Dec-2006  yamt branches: 1.14.6; 1.14.22; 1.14.24; 1.14.30;
merge yamt-splraiseipl branch.

- finish implementing splraiseipl (and makeiplcookie).
http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
- complete workqueue(9) and fix its ipl problem, which is reported
to cause audio skipping.
- fix netbt (at least compilation problems) for some ports.
- fix PR/33218.
 1.13 27-Sep-2006  freza Make sure we mask statclock timer on ibm4xx systems. This avoids
pthread "related" panics like:

panic: remrunqueue: bit 18 not set
Stopped in pid 479.3 (exsprite) at netbsd:cpu_Debugger+0x10: lwz
r
0, r1, 0x14
db> bt
0x869abe00: at panic+0x1b4
0x869abe50: at remrunqueue+0x80
0x869abe60: at mi_switch+0x114
0x869abea0: at sa_unblock_userret+0x4e8
0x869abee0: at syscall_plain+0x224
0x869abf40: user SC trap #93 by 0x41949810: srr1=0xc030
r1=0x445fff40 cr=0x40000002 xer=0 ctr=0x41aae208 esr=0 pid=0x36

While there, cleanup IPL_ definitions somewhat and fix interrupt mask
calculation per spl(9).

OK by matt@
 1.12 30-Jun-2006  freza branches: 1.12.4; 1.12.6;
Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.11 31-Dec-2005  hannken branches: 1.11.2; 1.11.6; 1.11.14;
Fix a typo introduced in revision 1.8:

- #define splraiseipl(x) splraise(x)
+ #define splraiseipl(x) splraise(imask[x])

Approved by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.10 24-Dec-2005  perry branches: 1.10.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 27-Nov-2005  yamt implement splraiseipl() for the following ports.
evbppc, evbmips, evbsh3, hp700, mac68k, vax, x68k.
 1.7 04-Sep-2005  kiyohara branches: 1.7.6;
Support the 'PCMCIA adapter BOX' for OpenBlockS266.
 1.6 26-Nov-2003  simonb branches: 1.6.14; 1.6.16;
Fix some white space nits.
 1.5 26-Nov-2003  simonb Remove the prototype for the non-existent intr_md_register() function.
 1.4 03-Sep-2003  matt Move CLKF_BASEPRI to machine specific <intr.h> file since it depends on
the encoding of the spl for the port.
 1.3 05-Aug-2003  simonb Note that the used interrupt bits are 405GP specific.
Fix a tyop.
 1.2 16-Jun-2003  thorpej branches: 1.2.2;
Rename IPL_IMP -> IPL_VM.
 1.1 04-Mar-2003  matt Re-arrange things in evbppc & powerpc to support OEA-based eval boards
in evbppc. OEA-based board(s) to be added later.
 1.2.2.5 11-Dec-2005  christos Sync with head.
 1.2.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.3 07-Dec-2007  yamt sync with head
 1.6.16.2 30-Dec-2006  yamt sync with head.
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.6.14.1 14-Sep-2005  tron Apply patch (requested by shige in ticket #763):
Synchronize OpenBlockS266 port with NetBSD-current for enhanced stability.
 1.7.6.1 29-Nov-2005  yamt sync with head.
 1.10.2.1 15-Jan-2006  yamt sync with head.
 1.11.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.6.1 11-Aug-2006  yamt sync with head
 1.11.2.1 09-Sep-2006  rpaulo sync with head
 1.12.6.2 22-Oct-2006  yamt sync with head
 1.12.6.1 20-Sep-2006  yamt implement new api for evbppc.
 1.12.4.2 12-Jan-2007  ad Sync with head.
 1.12.4.1 18-Nov-2006  ad Sync with head.
 1.14.30.1 08-Dec-2007  mjf Sync with HEAD.
 1.14.24.1 09-Jan-2008  matt sync with HEAD
 1.14.22.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.14.6.1 03-Dec-2007  ad Sync with HEAD.
 1.15.18.2 11-Aug-2010  yamt sync with head.
 1.15.18.1 16-May-2008  yamt sync with head.
 1.15.16.1 18-May-2008  yamt sync with head.
 1.15.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.26.1 07-Jan-2011  matt Remove CLKF_BASEPRI (it's obsolete).
 1.16.22.3 31-May-2011  rmind sync with head
 1.16.22.2 05-Mar-2011  rmind sync with head
 1.16.22.1 30-May-2010  rmind sync with head
 1.16.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1 13-Jun-2001  simonb branches: 1.1.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file mal405gp.h was added on branch nathanw_sa on 2001-06-13 06:01:50 +0000
 1.3 30-Mar-2021  rin Remove unused "startkernel" argument for openbios_board_init().
 1.2 11-Dec-2005  christos branches: 1.2.178; 1.2.180;
merge ktrace-lwp.
 1.1 17-Jan-2005  shige branches: 1.1.2; 1.1.10; 1.1.14;
Add openbios-board related modules.
- openbios.c
getting board data memory image from openbios.
setting all board data to board properties database.
- board_prop.c
initialize board properties database.
(set/get board properties [macros in ibm4xx/cpu.h])
 1.1.14.2 15-Sep-2005  riz Pull up following revision(s) (requested by shige in ticket #5820):
distrib/evbppc/md-kernel/Makefile 1.3 via patch
etc/etc.evbppc/Makefile.inc 1.3 via patch
sys/arch/evbppc/conf/files.obs405 1.5-1.8 via patch
sys/arch/evbppc/conf/OPENBLOCKS266 1.22,1.25 via patch
sys/arch/evbppc/include/obs266.h 1.1 (new)
sys/arch/evbppc/include/obs405.h 1.1-1.5 (new)
sys/arch/evbppc/include/rbus_machdep.h 1.1 (new)
sys/arch/evbppc/obs405/consinit.c 1.2-1.4
sys/arch/evbppc/obs405/dev/x1226.c deleted
sys/arch/evbppc/obs405/dev/x1226reg.h deleted
sys/arch/evbppc/obs405/machdep.c deleted
sys/arch/evbppc/obs405/obs266_autoconf.c 1.1 (new)
sys/arch/evbppc/obs405/obs266_machdep.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_autoconf.c 1.1 (new, plus patch)
sys/arch/evbppc/obs405/obs405_machdep.c 1.1 (new)
sys/arch/evbppc/obs405/rbus_machdep.c 1.1 (new)
sys/arch/powerpc/conf/files.ibm4xx 1.6-1.7
sys/arch/powerpc/ibm4xx/board_prop.c 1.1 (new)
sys/arch/powerpc/ibm4xx/dev/com_opb.c 1.12
sys/arch/powerpc/ibm4xx/dev/comopbvar.h 1.1 (new)
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c 1.3-1.4
sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c 1.1-1.2 (new)
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c 1.1-1.3 (new)
sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c 1.2-1.3
sys/arch/powerpc/ibm4xx/openbios/openbios.c 1.1 (new)
sys/arch/powerpc/include/ibm4xx/cpu.h 1.7-1.10
sys/arch/powerpc/include/ibm4xx/openbios.h 1.1 (new)

Update OpenBlockS266 support to more modern, stable sources.
 1.1.14.1 17-Jan-2005  riz file openbios.h was added on branch netbsd-2 on 2005-09-15 14:28:44 +0000
 1.1.10.2 29-Apr-2005  kent sync with -current
 1.1.10.1 17-Jan-2005  kent file openbios.h was added on branch kent-audio2 on 2005-04-29 11:28:20 +0000
 1.1.2.2 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.1 17-Jan-2005  skrll file openbios.h was added on branch ktrace-lwp on 2005-01-24 08:34:27 +0000
 1.2.180.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.178.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 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.6 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.5 04-Apr-2011  dyoung branches: 1.5.2;
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 11-Dec-2005  christos branches: 1.4.100; 1.4.106;
merge ktrace-lwp.
 1.3 04-Sep-2005  kiyohara Support the 'PCMCIA adapter BOX' for OpenBlockS266.
 1.2 02-Aug-2004  tacha branches: 1.2.10; 1.2.12;
remove obsolete "pci_enumerate_bus" definition.
 1.1 04-Mar-2003  matt branches: 1.1.2;
Re-arrange things in evbppc & powerpc to support OEA-based eval boards
in evbppc. OEA-based board(s) to be added later.
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2.12.1 21-Jun-2006  yamt sync with head.
 1.2.10.1 14-Sep-2005  tron Apply patch (requested by shige in ticket #763):
Synchronize OpenBlockS266 port with NetBSD-current for enhanced stability.
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.100.1 21-Apr-2011  rmind sync with head
 1.5.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22 28-Sep-2023  skrll Trailing whitespace.
 1.21 14-Mar-2020  ad pmap_remove_all(): Return a boolean value to indicate the behaviour. If
true, all mappings have been removed, the pmap is totally cleared out, and
UVM can then avoid doing the work to call pmap_remove() for each map entry.
If false, either nothing has been done, or some helpful arch-specific voodoo
has taken place.
 1.20 05-Mar-2020  rin Retire tlbpid_t (u_short):

- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).

XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.
 1.19 17-Jul-2019  skrll branches: 1.19.2;
Spell endianness correctly in comments
 1.18 19-Apr-2018  christos branches: 1.18.2;
s/static inline/static __inline/g for consistency.
 1.17 30-Jun-2011  matt branches: 1.17.52;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.16 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.15 18-Jan-2011  matt branches: 1.15.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.14 09-Dec-2008  pooka branches: 1.14.6; 1.14.8;
Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

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

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.13 21-Feb-2007  thorpej branches: 1.13.42; 1.13.46; 1.13.52; 1.13.54; 1.13.66;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.12 24-Dec-2005  perry branches: 1.12.26;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 16-Jan-2005  chs branches: 1.10.8;
implement pmap_wired_count(). fix some places we would forget to splx().
move the parts of pte.h that were used into pmap.c (since they were really
pmap-internal details) and delete ibm4xx/pte.h. other misc cleanup.
 1.9 31-Aug-2004  simonb branches: 1.9.4;
Remove the unused MKTTE macro.
 1.8 17-Aug-2003  chs remove an unused proto.
 1.7 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.6 02-Apr-2003  thorpej branches: 1.6.2;
Use PAGE_SIZE rather than NBPG.
 1.5 22-Sep-2002  chs it really helps to get the stub right before cutting + pasting it 27 times.
alas, I did not. doh.
 1.4 22-Sep-2002  chs add pmap_remove_all() hook (empty on most platforms so far).
 1.3 13-Mar-2002  eeh pmap improvements:

Remove the cache flush routines that have been moved to cpu.c

Make sure we clear out the unused PA bits in the TTE which causes breakage
on some MMU models.
 1.2 11-Sep-2001  eeh branches: 1.2.4;
Implement pmap_growkernel().
 1.1 13-Jun-2001  simonb branches: 1.1.2; 1.1.4;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.1.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.1 11-Sep-2001  nathanw file pmap.h was added on branch nathanw_sa on 2002-04-01 07:42:05 +0000
 1.6.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.6.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.2 03-Sep-2004  skrll Sync with HEAD
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.10.8.2 26-Feb-2007  yamt sync with head.
 1.10.8.1 21-Jun-2006  yamt sync with head.
 1.12.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.13.66.1 07-Jan-2011  matt PMAP_NC -> PMAP_NOCACHE.
 1.13.54.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.52.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.46.1 04-May-2009  yamt sync with head.
 1.13.42.1 17-Jan-2009  mjf Sync with HEAD.
 1.14.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.6.1 05-Mar-2011  rmind sync with head
 1.15.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.52.1 22-Apr-2018  pgoyette Sync with HEAD
 1.18.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.19.2.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #773):

sys/arch/powerpc/ibm4xx/pmap.c: revision 1.81
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.82
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.83
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.84
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.85
sys/arch/powerpc/include/ibm4xx/tlb.h: revision 1.6
sys/arch/powerpc/include/ibm4xx/pmap.h: revision 1.20

Misc non-critical fixes.
- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style

ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.

pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.

Retire tlbpid_t (u_short):
- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).
XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.

Fix pmap_procwr().
While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.
 1.2 16-Jan-2005  chs implement pmap_wired_count(). fix some places we would forget to splx().
move the parts of pte.h that were used into pmap.c (since they were really
pmap-internal details) and delete ibm4xx/pte.h. other misc cleanup.
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.24; 1.1.32;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.32.1 29-Apr-2005  kent sync with -current
 1.1.24.1 17-Jan-2005  skrll Sync with HEAD.
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file pte.h was added on branch nathanw_sa on 2001-06-13 06:01:50 +0000
 1.5 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.4 05-Mar-2021  rin Add 403 family processors other than 403GCX.
 1.3 18-Jun-2011  matt branches: 1.3.66;
Move PVR definitions to <powerpc/ibm4xx/spr.h>
No need to include <powerpc/cpu.h> in <powerpc/ib4xx/cpu.h>
 1.2 18-Mar-2010  kiyohara branches: 1.2.2; 1.2.4; 1.2.10;
Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.1 25-Feb-2010  matt branches: 1.1.2; 1.1.4;
Split <powerpc/spr.h> into a common <powerpc/spr.h> and <powerpc/XXX/spr.h>
where XXX is ibm4xx or oea.
 1.1.4.1 30-May-2010  rmind sync with head
 1.1.2.3 11-Aug-2010  yamt sync with head.
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 25-Feb-2010  yamt file spr.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:50 +0000
 1.2.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.2 07-Jan-2011  matt Split spr.h into generic PPC <powerpc/spr.h> and chip-specific
<powerpc/XXX/spr.h> (XXX=oea, ibm4xx, booke)
 1.2.4.1 18-Mar-2010  matt file spr.h was added on branch matt-nb5-pq3 on 2011-01-07 01:34:23 +0000
 1.2.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.2.1 18-Mar-2010  uebayasi file spr.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.3.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 30-Mar-2021  rin G/C misleading <evbppc/tlb.h>. Use <powerpc/ibm4xx/tlb.h> directly.
 1.6 05-Mar-2020  rin branches: 1.6.4; 1.6.6;
Retire tlbpid_t (u_short):

- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).

XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.
 1.5 19-Apr-2018  christos branches: 1.5.2; 1.5.6;
s/static inline/static __inline/g for consistency.
 1.4 16-Oct-2006  kiyohara branches: 1.4.142;
* convert ibm4xx-based evbppc from reserved-TLB entry allocation to recently
introduced ppc4xx_tlb_reserve() API.
 1.3 31-Aug-2006  freza branches: 1.3.2; 1.3.4;
* ppc4xx_tlb_reserve(): allocate "reserved" TLB entries dynamically
* ppc4xx_tlb_mapiodev(): resolve pa to va from reserved TLB entries

OK by matt@

XXX we'll keep TLB_NRESERVED defined until we fix explora to use new API
 1.2 12-Jul-2006  simonb Remove unused ppc4xx_tlb_unpin() function.
 1.1 13-Jun-2001  simonb branches: 1.1.8; 1.1.40; 1.1.54; 1.1.58; 1.1.66;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.66.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.58.2 03-Sep-2006  yamt sync with head.
 1.1.58.1 11-Aug-2006  yamt sync with head
 1.1.54.1 09-Sep-2006  rpaulo sync with head
 1.1.40.1 30-Dec-2006  yamt sync with head.
 1.1.8.2 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1.8.1 13-Jun-2001  simonb file tlb.h was added on branch nathanw_sa on 2001-06-13 06:01:51 +0000
 1.3.4.1 22-Oct-2006  yamt sync with head
 1.3.2.1 18-Nov-2006  ad Sync with head.
 1.4.142.1 22-Apr-2018  pgoyette Sync with HEAD
 1.5.6.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #773):

sys/arch/powerpc/ibm4xx/pmap.c: revision 1.81
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.82
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.83
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.84
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.85
sys/arch/powerpc/include/ibm4xx/tlb.h: revision 1.6
sys/arch/powerpc/include/ibm4xx/pmap.h: revision 1.20

Misc non-critical fixes.
- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style

ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.

pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.

Retire tlbpid_t (u_short):
- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).
XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.

Fix pmap_procwr().
While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.
 1.5.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.12 27-Mar-2019  christos fix protection
 1.11 13-Feb-2017  skrll branches: 1.11.14;
G/C VM_MAX_KERNEL_BUF
 1.10 23-Feb-2015  joerg branches: 1.10.2; 1.10.4;
Use default PAGER_MAP_DEFAULT_SIZE for ARM and PowerPC, exception
acorn26. This bumps the KVA reservation from 4MB to 16MB and avoids
long hangs on my Cubietruck under IO. acorn26 is kept as it does have a
ridiculous low 32MB KVA limit.
 1.9 20-Jun-2011  matt branches: 1.9.12; 1.9.30;
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.8 06-Nov-2010  uebayasi branches: 1.8.6;
Merge from uebayasi-xip:
 1.60.2.5 14-Aug-2010  uebayasi Teach TLB miss handler (pmap_tlbmiss()) to map "Expansion ROM" area as
PA == VA. Now we don't need to reserve a TLB entry for it.
 1.7 06-Nov-2010  uebayasi Remove incomplete, never worked dynamic run-time memory registration
(uvm_page_physload(9)). This functionality will be re-added later.
 1.6 06-Mar-2009  joerg branches: 1.6.2; 1.6.4;
Remove SHMMAXPGS from all kernel configs. Dynamically compute the
initial limit as 1/4 of the physical memory. Ensure the limit is at
least 1024 pages, the old default on most platforms.
 1.5 25-Oct-2007  yamt branches: 1.5.20; 1.5.28; 1.5.34;
defparam PAGER_MAP_SIZE.
 1.4 02-Apr-2003  thorpej branches: 1.4.18; 1.4.60; 1.4.78; 1.4.80; 1.4.84;
Use PAGE_SIZE rather than NBPG.
 1.3 01-Apr-2003  thorpej Make PAGE_SIZE, PAGE_SHIFT, and PAGE_MASK compile-time constants for
PowerPC processors.
 1.2 04-Mar-2003  matt Re-arrange things in evbppc & powerpc to support OEA-based eval boards
in evbppc. OEA-based board(s) to be added later.
 1.1 03-Feb-2003  matt Move ibm4xx vmparam.h to powerpc/include/ibm4xx directory. Add a stub
vmparam.h to choose the right vmparam. This is needed so evbppc can host
both ibm4xx and oea based eval boards.
 1.4.84.1 13-Nov-2007  bouyer Sync with HEAD
 1.4.80.1 06-Nov-2007  matt sync with HEAD
 1.4.78.1 28-Oct-2007  joerg Sync with HEAD.
 1.4.60.1 03-Dec-2007  ad Sync with HEAD.
 1.4.18.1 27-Oct-2007  yamt sync with head.
 1.5.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.20.1 04-May-2009  yamt sync with head.
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.6.2.3 14-Aug-2010  uebayasi Teach TLB miss handler (pmap_tlbmiss()) to map "Expansion ROM" area as
PA == VA. Now we don't need to reserve a TLB entry for it.
 1.6.2.2 11-Aug-2010  uebayasi Hook pmap_physseg_{init,fini} on powerpc/ibm4xx.
 1.6.2.1 26-Apr-2010  uebayasi Remove the unfinished code to add a memory segment after uvm_page_init().
It doesn't even compile.

(In the future, we should allocate struct vm_page [] on the added memory
segment for NUMA's sake.)
 1.8.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.30.2 28-Aug-2017  skrll Sync with HEAD
 1.9.30.1 06-Apr-2015  skrll Sync with HEAD
 1.9.12.1 03-Dec-2017  jdolecek update from HEAD
 1.10.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.10.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.11.14.1 10-Jun-2019  christos Sync with HEAD
 1.1 17-Jul-2012  matt branches: 1.1.4;
MPC8xx SPR defintions
 1.1.4.2 30-Oct-2012  yamt sync with head
 1.1.4.1 17-Jul-2012  yamt file spr.h was added on branch yamt-pagecache on 2012-10-30 17:20:12 +0000
 1.2 25-Feb-2010  matt Split <powerpc/spr.h> into a common <powerpc/spr.h> and <powerpc/XXX/spr.h>
where XXX is ibm4xx or oea.
 1.1 03-Feb-2003  matt branches: 1.1.108; 1.1.128; 1.1.132;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.1.132.1 07-Jan-2011  matt Add spr.h
 1.1.128.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.108.1 11-Mar-2010  yamt sync with head
 1.20 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.19 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.18 06-Jul-2014  mrg make sure struct bat is aligned to 8 bytes as we shift them 3 bits.

fixes PReP lossage as reported on port-powerpc and port-prep.
thanks to makoto@ki.nu and kiyohara@netbsd.
 1.17 15-Feb-2012  macallan branches: 1.17.6; 1.17.20;
make BATs >256MB work, now macppc works again on 745x CPUs as well
ok riz
 1.16 15-Feb-2012  matt When making BATU, use (BAT_XBL|BAT_BL) for the extended bat lengths.
 1.15 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.14 20-Jun-2011  matt branches: 1.14.2; 1.14.6;
Include <powerpc/psl.h>
 1.13 21-Jul-2009  nisimura branches: 1.13.10;
protect C constructs from assembler source inclusion.
 1.12 28-Apr-2008  martin branches: 1.12.22;
Remove clause 3 and 4 from TNF licenses
 1.11 23-Feb-2008  matt branches: 1.11.2; 1.11.4;
Add BAT_VA2IDX to abstract out the va to index calculation.
 1.10 23-Feb-2008  matt Add BAT_WIMG and some XBL aware BAT_BL_{512,1G,2G,4G} macros.
 1.9 05-Feb-2008  garbled branches: 1.9.2; 1.9.6;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.8 05-Aug-2006  sanjayl branches: 1.8.34; 1.8.40;
1st cut of Powermac G5 support (uses bridge mode).
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.8;
merge ktrace-lwp.
 1.6 21-Jan-2005  matt branches: 1.6.8;
Add extended BAT block size definitions.
 1.5 14-Mar-2003  matt branches: 1.5.2; 1.5.10;
Add _LOCORE protection.
 1.4 06-Feb-2003  matt Add oea_iobat_remove(paddr_t).
 1.3 05-Feb-2003  matt Make _LP64 friendly.
 1.2 05-Feb-2003  matt Make things a bit more LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.1 24-Jan-2005  skrll Sync with HEAD.
 1.6.8.3 27-Feb-2008  yamt sync with head.
 1.6.8.2 11-Feb-2008  yamt sync with head.
 1.6.8.1 30-Dec-2006  yamt sync with head.
 1.7.8.1 11-Aug-2006  yamt sync with head
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.40.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.34.1 23-Mar-2008  matt sync with HEAD
 1.9.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.2.1 24-Mar-2008  keiichi sync with head.
 1.11.4.2 19-Aug-2009  yamt sync with head.
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.22.1 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.13.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.6.1 18-Feb-2012  mrg merge to -current.
 1.14.2.1 17-Apr-2012  yamt sync with head
 1.17.20.1 10-Aug-2014  tls Rebase.
 1.17.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6 26-Feb-2021  thorpej Split cpu_model_init() into cpu_features_probe() and cpu_features_enable()
so that early bootstrap can do those two steps independently, if needed.

Continue to provide a cpu_model_init() wrapper for now.
 1.5 22-Mar-2018  macallan branches: 1.5.14;
provide a wrapper for mapiodev() - if we have BATs just use the paddr, if
we don't then actually map it
 1.4 28-Apr-2008  martin branches: 1.4.86;
Remove clause 3 and 4 from TNF licenses
 1.3 23-Feb-2008  matt branches: 1.3.2; 1.3.4; 1.3.6;
Add a XBSEN flag for large BATs
 1.2 14-Feb-2008  matt branches: 1.2.2; 1.2.4; 1.2.8;
Add multiple inclusion protection.
add oeacpufeat.
 1.1 05-Feb-2008  garbled branches: 1.1.2;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.1.2.3 27-Feb-2008  yamt sync with head.
 1.1.2.2 11-Feb-2008  yamt sync with head.
 1.1.2.1 05-Feb-2008  yamt file cpufeat.h was added on branch yamt-lazymbuf on 2008-02-11 14:59:28 +0000
 1.2.8.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.1 03-Apr-2008  mjf Sync with HEAD.
 1.2.4.1 24-Mar-2008  keiichi sync with head.
 1.2.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.2.1 14-Feb-2008  mjf file cpufeat.h was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.3.6.1 16-May-2008  yamt sync with head.
 1.3.4.1 18-May-2008  yamt sync with head.
 1.3.2.2 23-Mar-2008  matt sync with HEAD
 1.3.2.1 23-Feb-2008  matt file cpufeat.h was added on branch matt-armv6 on 2008-03-23 02:04:17 +0000
 1.4.86.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.5.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15 10-Mar-2024  rillig powerpc/hid: fix snprintb format for HID0_970_BITMASK_U
 1.14 20-Jan-2024  jmcneill fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
 1.13 06-Jul-2020  rin branches: 1.13.20;
Include missing opt_ppcarch.h.
 1.12 16-Feb-2018  macallan add a few pp970-specific bits
 1.11 07-Jul-2017  macallan add bits & masks for ppc970 HID0
 1.10 22-Sep-2013  matt branches: 1.10.6;
Define HID1_{SYNCBE,ABE} for the 7450
 1.9 25-May-2008  phx branches: 1.9.32; 1.9.42; 1.9.48;
Better call it HID0_BTCD, as in prep, mvmeppc and rs6000 locore.
 1.8 25-May-2008  phx Added HID0[BTAC] bit for the 604.
 1.7 11-Dec-2005  christos branches: 1.7.74; 1.7.76; 1.7.78; 1.7.80;
merge ktrace-lwp.
 1.6 21-Jan-2005  matt Add some HID1 definitions and HID0_XBSEN for 7455+ processors.
 1.5 21-Jan-2005  matt Correct BHTCLR/XAEN definitions.
 1.4 11-Jan-2005  chs branches: 1.4.2;
enable powersave mode on 7450 and family.
also, the HID0_DOZE bit in this context doesn't mean "doze",
it's actually "enable extra BATs". add an alias for this bit
and use it as appropriate.
 1.3 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.2 29-Mar-2003  matt branches: 1.2.2;
Add 7450 LRSTK and FOLD bits.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.2.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.2.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.7.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.78.1 04-May-2009  yamt sync with head.
 1.7.76.1 04-Jun-2008  yamt sync with head
 1.7.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.48.1 18-May-2014  rmind sync with head
 1.9.42.2 03-Dec-2017  jdolecek update from HEAD
 1.9.42.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.32.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.6.1 28-Aug-2017  skrll Sync with HEAD
 1.13.20.1 03-Feb-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #561):

etc/etc.evbppc/Makefile.inc: revision 1.15
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.2
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.3
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.2
distrib/utils/embedded/files/evbppc_wii_icon.png: revision 1.1
usr.sbin/sysinst/arch/evbppc/md.h: revision 1.4
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.4
sys/arch/evbppc/wii/dev/viio.h: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.5
sys/arch/evbppc/wii/dev/mainbus.h: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.2
distrib/utils/embedded/conf/wii.conf: revision 1.3
sys/dev/sdmmc/sdhcvar.h: revision 1.34
sys/dev/sdmmc/sdhc.c: revision 1.118
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.1
distrib/utils/embedded/conf/evbppc.conf: revision 1.1
sys/dev/wsfb/genfb.c: revision 1.91
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.2
sys/dev/wscons/wsconsio.h: revision 1.127
sys/arch/powerpc/oea/oea_machdep.c: revision 1.85
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.1
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.2
sys/arch/evbppc/conf/std.wii: revision 1.3
sys/arch/powerpc/oea/cpu_subr.c: revision 1.109
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.1
sys/dev/usb/usb.h: revision 1.124
sys/arch/evbppc/wii/machdep.c: revision 1.1
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.1
sys/arch/powerpc/include/oea/hid.h: revision 1.14
sys/arch/evbppc/wii/mainbus.c: revision 1.1
sys/arch/evbppc/wii/machdep.c: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.1
sys/arch/evbppc/wii/mainbus.c: revision 1.2
sys/arch/evbppc/wii/machdep.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.2
sys/arch/evbppc/wii/mainbus.c: revision 1.3
sys/arch/evbppc/wii/machdep.c: revision 1.4
sys/arch/evbppc/wii/dev/hwgpio.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.2
sys/arch/evbppc/wii/wii_locore.S: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.1
sys/arch/evbppc/wii/wii_locore.S: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.2
sys/arch/evbppc/wii/dev/exi.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.2
sys/arch/evbppc/conf/files.wii: revision 1.3
sys/arch/powerpc/powerpc/clock.c: revision 1.18
sys/arch/evbppc/include/wii.h: revision 1.3
sys/arch/evbppc/conf/files.wii: revision 1.4
sys/arch/evbppc/include/wii.h: revision 1.4
sys/arch/evbppc/wii/dev/exi.h: revision 1.1
sys/arch/evbppc/wii/dev/avenc.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.5
sys/arch/evbppc/include/wii.h: revision 1.6
sys/arch/evbppc/include/wii.h: revision 1.7
sys/arch/evbppc/wii/dev/avenc.h: revision 1.1
distrib/utils/embedded/mkimage: revision 1.79
sys/arch/evbppc/conf/WII: revision 1.1
sys/arch/evbppc/conf/INSTALL_WII: revision 1.1
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.1
sys/arch/evbppc/wii/dev/vireg.h: revision 1.1
sys/arch/evbppc/conf/WII: revision 1.2
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.2
sys/arch/evbppc/wii/dev/vireg.h: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.3
sys/arch/evbppc/conf/WII: revision 1.4
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.11
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.1
sys/dev/usb/ehcivar.h: revision 1.52
sys/arch/evbppc/wii/pic_pi.c: revision 1.1
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.2
etc/etc.evbppc/ttys: revision 1.8
sys/arch/evbppc/wii/dev/bwai.c: revision 1.1
sys/arch/evbppc/wii/dev/bwai.c: revision 1.2
sys/arch/evbppc/wii/dev/bwai.c: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.1
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.1
sys/arch/evbppc/wii/dev/bwai.h: revision 1.1
sys/arch/evbppc/wii/autoconf.c: revision 1.2
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.2

powerpc: oea: Fix prefetchable mappings
Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
powerpc: oea: Decode IBM750CL L2 cache information.
sdmmc: add support for optional delay after register write
wscons: Add HOLLYWOOD display and YUY2 pixel format types
wsfb: add support for optional "devcmap" property
A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.
ehci: add EHCIF_32BIT_ACCESS flag to force 32-bit MMIO
fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
powerpc: fix delay for large (> ~5sec) values
When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
usb: increase USB_PORT_RESET_RECOVERY from 10ms to 20ms
I changed this from 250ms to 10ms back in 2021 based on a similar FreeBSD
change, but it seems to be a bit too aggressive for some platforms.
evbppc: Add initial support for the Nintendo Wii
wii: support RB_POWERDOWN
build fix: use dd with count=1 for compat with NetBSD dd(1)
wii: Add NTSC 480p support.
In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.
wii: Add 128x48 icon to SD card image
wii: Fix a comment
wii: Add drivers for Broadway DSP and Audio interface.
0: [*] audio0 @ bwdsp0: Broadway DSP
playback: 16, 2ch, 48000Hz
record: unavailable
(P-) slinear_be 16/16, 2ch, { 48000 }
wii: Add screenblank support.
wii: Use screen dimming register for screen blanking.
wii: Add GPIO, I2C, and basic A/V encoder driver.
wii: Use A/V encoder volume controls instead of using a software filter.
wii: Simply DSP driver - no interrupt handler required.
wii: provide device names to intr_establish
wii$ intrctl list
interrupt id CPU0 device name(s)
pi irq 14 64769* hollywood0
hollywood irq 36 5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0
wii: Add support for passing boot options to the kernel.
wii: Add External interface bus and RTC support
wii: Remove objcopy after kernel build.
HBC will do the right thing.
Add wsvt25 entries (off by default) for ttyE0-ttyE3.
Add support for "PAL" (576i) mode on Wii.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 03-Feb-2003  matt branches: 1.1.104; 1.1.106; 1.1.108;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.1.108.1 16-May-2008  yamt sync with head.
 1.1.106.1 18-May-2008  yamt sync with head.
 1.1.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.39 15-Dec-2023  rin powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621
 1.38 28-Sep-2023  skrll Trailing whitespace.
 1.37 07-May-2022  rin branches: 1.37.4;
Try to fix PV tracking support.

* For oea (with real PV tracking support):

Define __HAVE_PMAP_PV_TRACK. Otherwise, pmap_pv_init() is not called by
uvm_init().

* For booke and ibm4xx (without PV tracking support):

For MODULAR kernel and modules, define __HAVE_PMAP_PV_TRACK together with
PMAP_PV_TRACK_ONLY_STUBS, so that modules can be shared with oea.

Note that PMAP_PV_TRACK_ONLY_STUBS can be used even for oea,
as a compile-time option to strip real PV tracking support.
 1.36 16-Feb-2022  riastradh powerpc: Implement pv-tracking for unmanaged pages.

Needed for drm.
 1.35 12-Mar-2021  thorpej Re-factor the code in pmap_extract() that checks the 601 I/O segment
table and the BAT tables into separate functions that can be called
from outside of the pmap module.
 1.34 02-Mar-2021  thorpej Complete the pmap symbol renaming shenanigans for pmap_bootstrap[12]().
 1.33 01-Mar-2021  thorpej Split pmap_bootstrap() into 2 functions:
- pmap_bootstrap1(), which sets up the low-level pmap data structures.
- pmap_bootstrap2(), which actually programs the MMU hardware based on
pmap_bootstrap1()'s work.

pmap_bootstrap() is still provided as a wrapper around the two, but this
provides flexibility to platforms that might need to do additional work
between these two phases.
 1.32 06-Jul-2020  rin branches: 1.32.2;
Include missing opt_modular.h so that struct vm_page_md is compatible to
that for booke.
 1.31 06-Jul-2020  rin LKM was gone.
 1.30 14-Mar-2020  ad pmap_remove_all(): Return a boolean value to indicate the behaviour. If
true, all mappings have been removed, the pmap is totally cleared out, and
UVM can then avoid doing the work to call pmap_remove() for each map entry.
If false, either nothing has been done, or some helpful arch-specific voodoo
has taken place.
 1.29 19-Apr-2018  christos branches: 1.29.2;
s/static inline/static __inline/g for consistency.
 1.28 28-Feb-2014  matt branches: 1.28.28;
Add pmap_ste_spill
 1.27 28-Jul-2012  matt branches: 1.27.2; 1.27.4;
Fix -fno-common fallout.
 1.26 27-Sep-2011  jym branches: 1.26.2;
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.25 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.24 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.23 20-Jun-2011  matt Add #error for unknown PPC variant
Now that oea calls cpu_fixup_stubs, we don't need pmap_fixup_stubs.
 1.22 15-Feb-2011  macallan branches: 1.22.2;
implement pmap_mmap_flags() and teach PowerPC's bus_space_mmap() to actually
use BUS_SPACE_MAP_PREFETCHABLE which, now that /dev/pci* knows how to use it,
helps improve X performance
 1.21 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.20 18-Jan-2011  matt branches: 1.20.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.19 14-Nov-2010  uebayasi branches: 1.19.2;
Move struct vm_page_md definition from vmparam.h to pmap.h, because
it's used only by pmap. vmparam.h has definitions for wider
audience.

All GENERIC kernels build tested, except ia64.

powerpc/include/booke/vmparam.h has one too, but it has no pmap.h,
so it's left as is.
 1.18 07-Nov-2009  cegger branches: 1.18.4;
Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.17 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.16 21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.15 28-Dec-2008  he branches: 1.15.2;
Wrap #include "opt_ppcarch.h" in #ifdef _KERNEL_OPT, to allow
lib/librump to build for evbppc.
 1.14 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

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

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.13 07-Feb-2008  matt branches: 1.13.6; 1.13.10; 1.13.16; 1.13.18; 1.13.30;
Cleanup/simplify #if/#endif
 1.12 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.11 09-Jan-2008  garbled When compiling in bridge mode, add a prototype for pmap_setup_segment0_map()
 1.10 21-Feb-2007  thorpej branches: 1.10.22; 1.10.28; 1.10.34;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.9 05-Aug-2006  sanjayl branches: 1.9.10;
1st cut of Powermac G5 support (uses bridge mode).
 1.8 24-Dec-2005  perry branches: 1.8.4; 1.8.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 21-Nov-2003  matt branches: 1.6.16;
More PPC64 changes. (latent for now).
 1.5 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.4 09-Apr-2003  matt branches: 1.4.2;
Add POOL_VTOPHYS. Change vtophys to return -1 if pmap_extract fails.
(callers of vtophys should always supply a valid VA so that
pmap_extract should never fail).
 1.3 15-Mar-2003  matt Make lint happy.
 1.2 05-Feb-2003  matt Make things a bit more LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.5 11-Feb-2008  yamt sync with head.
 1.6.16.4 21-Jan-2008  yamt sync with head
 1.6.16.3 26-Feb-2007  yamt sync with head.
 1.6.16.2 30-Dec-2006  yamt sync with head.
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.8.8.1 11-Aug-2006  yamt sync with head
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.10.34.1 10-Jan-2008  bouyer Sync with HEAD
 1.10.28.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.22.1 23-Mar-2008  matt sync with HEAD
 1.13.30.1 07-Jan-2011  matt PMAP_NC -> PMAP_NOCACHE.
 1.13.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.13.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.10.2 11-Mar-2010  yamt sync with head
 1.13.10.1 04-May-2009  yamt sync with head.
 1.13.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.15.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.22.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.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.26.2.1 30-Oct-2012  yamt sync with head
 1.27.4.1 18-May-2014  rmind sync with head
 1.27.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.28.1 22-Apr-2018  pgoyette Sync with HEAD
 1.29.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.37.4.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.10 06-Jul-2020  rin Fix comments. No binary changes.
 1.9 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.8 05-Aug-2006  sanjayl branches: 1.8.34; 1.8.40;
1st cut of Powermac G5 support (uses bridge mode).
 1.7 27-Dec-2005  ross branches: 1.7.4; 1.7.8;
Fix typo inside PPC_OEA64
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 21-Nov-2003  matt branches: 1.5.16;
More PPC64 changes. (latent for now).
 1.4 21-Nov-2003  matt Add PowerPC64 definitions
 1.3 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.2 05-Feb-2003  matt branches: 1.2.2;
Make things a bit more LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.3 11-Feb-2008  yamt sync with head.
 1.5.16.2 30-Dec-2006  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.7.8.1 11-Aug-2006  yamt sync with head
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.40.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.34.1 23-Mar-2008  matt sync with HEAD
 1.7 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.6 01-Jun-2018  macallan add functions to access SCOM registers on 970 CPUs
 1.5 04-May-2018  macallan add Hardware Interrupt Offset Register found on 970
 1.4 16-Feb-2018  macallan branches: 1.4.2;
add a few pp970-specific bits
 1.3 07-Jul-2015  macallan add instruction cache throttling SPR found on 750
 1.2 01-Feb-2012  matt branches: 1.2.6; 1.2.24;
Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.1 25-Feb-2010  matt branches: 1.1.2; 1.1.6; 1.1.8; 1.1.16; 1.1.20;
Split <powerpc/spr.h> into a common <powerpc/spr.h> and <powerpc/XXX/spr.h>
where XXX is ibm4xx or oea.
 1.1.20.1 18-Feb-2012  mrg merge to -current.
 1.1.16.1 17-Apr-2012  yamt sync with head
 1.1.8.3 28-Jan-2011  matt Add SPR_DBAT7L ...
 1.1.8.2 07-Jan-2011  matt Split spr.h into generic PPC <powerpc/spr.h> and chip-specific
<powerpc/XXX/spr.h> (XXX=oea, ibm4xx, booke)
 1.1.8.1 25-Feb-2010  matt file spr.h was added on branch matt-nb5-pq3 on 2011-01-07 01:34:24 +0000
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 25-Feb-2010  uebayasi file spr.h was added on branch uebayasi-xip on 2010-04-30 14:39:43 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 25-Feb-2010  yamt file spr.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:51 +0000
 1.2.24.1 22-Sep-2015  skrll Sync with HEAD
 1.2.6.1 03-Dec-2017  jdolecek update from HEAD
 1.4.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.4.2.1 21-May-2018  pgoyette Sync with HEAD
 1.6 27-Feb-2021  thorpej Rather than putting it on the caller, just let oea_iobat_add() decide
whether to call mpc601_ioseg_add().
 1.5 28-Apr-2008  martin branches: 1.5.100;
Remove clause 3 and 4 from TNF licenses
 1.4 09-Apr-2007  garbled branches: 1.4.34; 1.4.36; 1.4.38;
Make the SR601_VALID_P check less draconic wrt valid io segregs. There
are perfectly valid iosegregs for which the old test would fail.
 1.3 11-Dec-2005  christos branches: 1.3.26; 1.3.30; 1.3.32;
merge ktrace-lwp.
 1.2 06-Jun-2004  kleink branches: 1.2.12;
Add some BAT-style predicate macros.
 1.1 03-Feb-2003  matt branches: 1.1.2; 1.1.6;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.1.6.1 07-Aug-2005  riz Pull up revision 1.2 (requested by briggs in ticket #1238):
Add some BAT-style predicate macros.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2.12.1 03-Sep-2007  yamt sync with head.
 1.3.32.1 11-Jul-2007  mjf Sync with head.
 1.3.30.1 10-Apr-2007  ad Sync with head.
 1.3.26.1 15-Apr-2007  yamt sync with head.
 1.4.38.1 16-May-2008  yamt sync with head.
 1.4.36.1 18-May-2008  yamt sync with head.
 1.4.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.100.1 03-Apr-2021  thorpej Sync with HEAD.
 1.23 03-Feb-2022  macallan bump MAXTSIZ
now clang runs again
 1.22 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.21 17-Apr-2021  rin Adjust TABs. No functional changes.
 1.20 17-Aug-2017  sevan branches: 1.20.18;
Raise the maximum text size value to 128MB, this allows binaries such as clang which
currently has a text area of around 96MB to execute successfully on macppc.

ok macallan
 1.19 13-Feb-2017  skrll branches: 1.19.6;
G/C VM_MAX_KERNEL_BUF
 1.18 28-Feb-2014  matt branches: 1.18.6; 1.18.10; 1.18.14;
Make this 64-bit aware.
 1.17 20-Jun-2011  matt branches: 1.17.2; 1.17.12; 1.17.16;
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.16 14-Nov-2010  uebayasi branches: 1.16.6;
Move struct vm_page_md definition from vmparam.h to pmap.h, because
it's used only by pmap. vmparam.h has definitions for wider
audience.

All GENERIC kernels build tested, except ia64.

powerpc/include/booke/vmparam.h has one too, but it has no pmap.h,
so it's left as is.
 1.15 06-Nov-2010  uebayasi Remove incomplete, never worked dynamic run-time memory registration
(uvm_page_physload(9)). This functionality will be re-added later.
 1.14 06-Mar-2009  joerg branches: 1.14.2; 1.14.4;
Remove SHMMAXPGS from all kernel configs. Dynamically compute the
initial limit as 1/4 of the physical memory. Ensure the limit is at
least 1024 pages, the old default on most platforms.
 1.13 28-Apr-2008  martin branches: 1.13.8; 1.13.14;
Remove clause 3 and 4 from TNF licenses
 1.12 05-Feb-2008  garbled branches: 1.12.6; 1.12.8; 1.12.10;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.11 19-Jan-2008  aymeric bump the default data size to 256MB (i.e. double it) because compiling
gcc during a standard native system build doesn't pass with 128MB.
 1.10 21-Sep-2006  matt branches: 1.10.28; 1.10.34; 1.10.42;
Define a PHYSMAP_VSID for mapping pa==va.
 1.9 05-Aug-2006  sanjayl branches: 1.9.4; 1.9.6;
1st cut of Powermac G5 support (uses bridge mode).
 1.8 10-Jan-2005  matt branches: 1.8.10; 1.8.22; 1.8.26;
Now that countless UVM bugs have been fixed, enable "topdown" memory
allocation by default.
 1.7 21-Nov-2003  matt More PPC64 changes. (latent for now).
 1.6 01-Apr-2003  thorpej branches: 1.6.2;
Make PAGE_SIZE, PAGE_SHIFT, and PAGE_MASK compile-time constants for
PowerPC processors.
 1.5 23-Feb-2003  atatat #include opt_uvm.h in machine/vmparam.h (for those ports offering the
topdown option) so that including it directly before including
uvm/uvm_param.h (or uvm/uvm_extern.h which includes uvm/uvm_param.h)
and attempting to use topdown won't result in a compiler error.

Problem noted in private email.
 1.4 21-Feb-2003  matt Add TOPDOWN VM support.
 1.3 06-Feb-2003  matt Allow KERNEL_SR/KERNEL2_SR to be overriden (I run a kernel with
the mapped space at 0x8000000-0x9fffffff).
 1.2 05-Feb-2003  matt Make LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.6.2.2 17-Jan-2005  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.26.1 11-Aug-2006  yamt sync with head
 1.8.22.1 09-Sep-2006  rpaulo sync with head
 1.8.10.3 11-Feb-2008  yamt sync with head.
 1.8.10.2 21-Jan-2008  yamt sync with head
 1.8.10.1 30-Dec-2006  yamt sync with head.
 1.9.6.1 22-Oct-2006  yamt sync with head
 1.9.4.1 18-Nov-2006  ad Sync with head.
 1.10.42.1 20-Jan-2008  bouyer Sync with HEAD
 1.10.34.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.28.1 23-Mar-2008  matt sync with HEAD
 1.12.10.2 04-May-2009  yamt sync with head.
 1.12.10.1 16-May-2008  yamt sync with head.
 1.12.8.1 18-May-2008  yamt sync with head.
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.14.1 13-May-2009  jym Sync with HEAD.

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

(In the future, we should allocate struct vm_page [] on the added memory
segment for NUMA's sake.)
 1.14.2.1 23-Feb-2010  uebayasi Convert all VM_MDPAGE_INIT()'s to take struct vm_page_md * and paddr_t.
 1.16.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.16.1 18-May-2014  rmind sync with head
 1.17.12.2 03-Dec-2017  jdolecek update from HEAD
 1.17.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.18.6.1 28-Aug-2017  skrll Sync with HEAD
 1.19.6.1 31-Aug-2017  martin Pull up following revision(s) (requested by sevan in ticket #241):
sys/arch/powerpc/include/oea/vmparam.h: revision 1.20
Raise the maximum text size value to 128MB, this allows binaries such as
clang which
currently has a text area of around 96MB to execute successfully on macppc.
ok macallan
 1.20.18.1 17-Apr-2021  thorpej Sync with HEAD.
 1.7 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.6 17-Jun-2011  matt struct device * -> device_t
 1.5 19-Aug-2009  dyoung branches: 1.5.10;
genppc_isa_detach_hook() needs two arguments, the first an
isa_chipset_tag_t.
 1.4 19-Aug-2009  dyoung Define genppc_isa_detach_hook() and isa_dmadestroy().
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 03-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file isa_machdep_common.c was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.2 07-May-2007  garbled Rewrite how shared isa is done slightly. This will allow the individual
ports to override the shared functions if needed. Also, implement
isa_intr_alloc, which needed to be done inside pic/intr.c because it
needs access to structs which are static to the file.
 1.1.2.1 03-May-2007  garbled Add a common isa_machdep.c
 1.2.26.2 19-Aug-2009  yamt sync with head.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file isa_machdep_common.c was added on branch matt-armv6 on 2007-11-06 23:20:40 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file isa_machdep_common.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:49 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file isa_machdep_common.c was added on branch vmlocking on 2007-10-23 20:36:06 +0000
 1.5.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.13 17-Dec-2021  skrll Correct copypaste comment grammar.
 1.12 17-Dec-2021  skrll Trailing whitespace
 1.11 23-Dec-2016  cherry "Make NetBSD great again!"

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

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

KeK (http://www.kek.org.in) for hosting the primary developers.
 1.10 26-Feb-2016  christos branches: 1.10.2;
PR/50858: David Binderman: Remove redundant code.
 1.9 09-Jun-2013  kiyohara branches: 1.9.10;
Call kmem_intr_free() with kmem_intr_alloc-ed memory instead of free().
 1.8 01-Feb-2012  matt branches: 1.8.6;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.7 01-Jul-2011  dyoung branches: 1.7.2; 1.7.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.6 10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.5 28-Apr-2008  martin branches: 1.5.20; 1.5.22;
Remove clause 3 and 4 from TNF licenses
 1.4 07-Mar-2007  he branches: 1.4.40; 1.4.42; 1.4.44;
Use char* and not void* with mtod() before doing pointer arithmetic
on the result.
 1.3 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 11-Dec-2005  christos branches: 1.2.26;
merge ktrace-lwp.
 1.1 19-Oct-2003  matt branches: 1.1.4; 1.1.18;
Add powerpc-specific isa and isadma machdep code. (Merge common code from
prep and sandpoint and ...)
 1.1.18.1 03-Sep-2007  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 19-Oct-2003  skrll file isadma_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:39:37 +0000
 1.2.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.44.1 16-May-2008  yamt sync with head.
 1.4.42.1 18-May-2008  yamt sync with head.
 1.4.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.22.1 05-Mar-2011  rmind sync with head
 1.5.20.1 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.7.6.1 18-Feb-2012  mrg merge to -current.
 1.7.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.7.2.1 17-Apr-2012  yamt sync with head
 1.8.6.2 03-Dec-2017  jdolecek update from HEAD
 1.8.6.1 23-Jun-2013  tls resync from head
 1.9.10.2 05-Feb-2017  skrll Sync with HEAD
 1.9.10.1 19-Mar-2016  skrll Sync with HEAD
 1.10.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.5 01-Jul-2011  dyoung branches: 1.5.2; 1.5.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.4 21-Oct-2009  snj Drop 3rd and 4th clauses. Approved by thomas@ (copyright holder).
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file isapnp_machdep.c was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1 02-May-2007  garbled Move prep's isapnp_machdep.c to powerpc/isa, and make prep use that instead.
 1.2.26.2 11-Mar-2010  yamt sync with head
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file isapnp_machdep.c was added on branch matt-armv6 on 2007-11-06 23:20:41 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file isapnp_machdep.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:49 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file isapnp_machdep.c was added on branch vmlocking on 2007-10-23 20:36:07 +0000
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.21 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.20 18-Mar-2009  cegger branches: 1.20.2; 1.20.4;
bzero -> memset
 1.19 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.18 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.17 04-Jun-2008  ad branches: 1.17.6; 1.17.12;
vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both.
 1.16 28-Apr-2008  martin branches: 1.16.2;
Remove clause 3 and 4 from TNF licenses
 1.15 05-Feb-2008  garbled branches: 1.15.6; 1.15.8; 1.15.10;
Replace as much of the hardcoded CACHELINESIZE with
curcpu()->ci_ci.dcache_line_size as I can. With this change, an ofppc kernel
compiled with both PPC_OEA and PPC_OEA64_BRIDGE defined, boots.
 1.14 04-Mar-2007  christos branches: 1.14.20; 1.14.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 12-Mar-2006  yamt branches: 1.13.16;
fix mistakes in yamt-uio_vmspace changes.
 1.12 01-Mar-2006  yamt branches: 1.12.2; 1.12.4;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.11 24-Dec-2005  perry branches: 1.11.2; 1.11.4; 1.11.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 24-Nov-2005  yamt bus_dmamem_map: honour BUS_DMA_NOWAIT. noted by Manuel Bouyer.
bus_space_map: always do NOWAIT allocation as it used to be before yamt-km.

we have too many copies!
 1.8 01-Apr-2005  yamt branches: 1.8.2; 1.8.8;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.7 09-Mar-2005  matt Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API
to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create). dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
 1.6 28-Nov-2004  thorpej branches: 1.6.4; 1.6.6;
bus_dmamap_load_mbuf(): Skip zero-length mbufs.
kern/24811
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 29-Jun-2003  fvdl branches: 1.4.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.3 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.2 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.4.2.9 11-Dec-2005  christos Sync with head.
 1.4.2.8 01-Apr-2005  skrll Sync with HEAD.
 1.4.2.7 19-Feb-2005  skrll Don't deref a NULL struct lwp *. This shouldn't happen, but...
 1.4.2.6 18-Dec-2004  skrll Sync with HEAD.
 1.4.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.3 06-Aug-2004  skrll Fix merge mistakes.
 1.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.6.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.6.1 28-Jan-2005  yamt convert arch/powerpc to new apis.
 1.6.4.1 29-Apr-2005  kent sync with -current
 1.8.8.1 29-Nov-2005  yamt sync with head.
 1.8.2.3 11-Feb-2008  yamt sync with head.
 1.8.2.2 03-Sep-2007  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.11.6.1 22-Apr-2006  simonb Sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 18-Feb-2006  yamt adapt the rest of MD code.
 1.12.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.12.2.1 13-Mar-2006  yamt sync with head.
 1.13.16.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.20.1 23-Mar-2008  matt sync with HEAD
 1.15.10.3 11-Aug-2010  yamt sync with head.
 1.15.10.2 04-May-2009  yamt sync with head.
 1.15.10.1 16-May-2008  yamt sync with head.
 1.15.8.2 17-Jun-2008  yamt sync with head.
 1.15.8.1 18-May-2008  yamt sync with head.
 1.15.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.15.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.12.2 24-Oct-2010  jym Sync with HEAD
 1.17.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.20.4.1 30-May-2010  rmind sync with head
 1.20.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.20.2.1 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.21 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.20 18-Mar-2009  cegger branches: 1.20.2; 1.20.4;
Ansify function definitions w/o arguments. Generated with sed.
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 03-Dec-2007  ad branches: 1.18.18; 1.18.26; 1.18.32; 1.18.40;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.17 24-Jan-2007  hubertf branches: 1.17.6; 1.17.22; 1.17.24; 1.17.30;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.16 13-Jun-2006  freza branches: 1.16.6;
Merge multiple definitions of cntlzw() ("count leading zeros")
instruction-wrapper to <powerpc/cpu.h>.

OK by briggs@
 1.15 24-Dec-2005  perry branches: 1.15.4; 1.15.8; 1.15.14;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.14 11-Dec-2005  christos merge ktrace-lwp.
 1.13 03-Jun-2005  scw branches: 1.13.2;
Appease -Wshadow.
 1.12 01-Jun-2004  matt Fix softnet intr handling (to be like the generic ppc softintr).
 1.11 15-Jul-2003  lukem branches: 1.11.2;
__KERNEL_RCSID()
 1.10 16-May-2003  scw branches: 1.10.2;
Make this compile with DEBUG defined.
 1.9 29-Apr-2003  scw Fix use of an uninitialised variable. This was harmless, other than
spuriously incrementing an interrupt counter.
 1.8 26-Apr-2003  wiz Management, not managment. Mostly from jmc@openbsd.
 1.7 09-Apr-2003  matt Make the imask_t typedef a struct rather than a naked array. The attribute
on the array typedef was contaminating other u_int32_t naked arrays and
affecting their alignment.
 1.6 17-Mar-2003  matt Add __HAVE_GENERIC_SOFT_INTERRUPT support.
 1.5 16-Mar-2003  matt Make the result an early clobber so gcc won't get clever.
 1.4 15-Mar-2003  matt Reduce visible globals. (gt_handle is now gt_memh and is only known to
machdep.c, gt_mainbus.c, and extintr.c)
 1.3 15-Mar-2003  matt Make lint happy and use __asm && __volatile.
manipulate netisr via lwarx/stwcx. to get atomicity.
 1.2 06-Mar-2003  matt Adapt to powerpc/bus.h changes.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.10.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.2.1 04-Jun-2004  jmc Pullup rev 1.12 (requested by matt in ticket #436)

Fix softnet intr handling (to be like the generic ppc softintr).
 1.13.2.3 07-Dec-2007  yamt sync with head
 1.13.2.2 26-Feb-2007  yamt sync with head.
 1.13.2.1 21-Jun-2006  yamt sync with head.
 1.15.14.1 19-Jun-2006  chap Sync with head.
 1.15.8.1 26-Jun-2006  yamt sync with head.
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.16.6.1 01-Feb-2007  ad Sync with head.
 1.17.30.1 08-Dec-2007  mjf Sync with HEAD.
 1.17.24.1 09-Jan-2008  matt sync with HEAD
 1.17.22.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.17.6.1 03-Dec-2007  ad Sync with HEAD.
 1.18.40.2 27-Jul-2011  matt Fix DEBUG declaration.
 1.18.40.1 28-Mar-2011  matt Don't adjust ci_idepth since trap_subr does it.
 1.18.32.2 24-Oct-2010  jym Sync with HEAD
 1.18.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.18.2 11-Aug-2010  yamt sync with head.
 1.18.18.1 04-May-2009  yamt sync with head.
 1.20.4.1 30-May-2010  rmind sync with head
 1.20.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.18 17-Jun-2011  matt Part of the interrupt rototill. Use <powerpc/intr.h> and just override
a few things (like imask_t).
 1.17 28-Apr-2010  kiyohara branches: 1.17.6;
Clean up gt and peripherals.
This change tested compile only.
 1.16 14-Mar-2009  dsl branches: 1.16.2; 1.16.4;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.15 28-Apr-2008  martin branches: 1.15.8; 1.15.14;
Remove clause 3 and 4 from TNF licenses
 1.14 24-Apr-2008  he branches: 1.14.2;
Need to include <powerpc/psl.h> and <powerpc/frame.h> here to get
PSL_EE and struct intrframe defined. Fixes build problem for evbppc
EV64260 kernel.
 1.13 03-Dec-2007  ad branches: 1.13.14; 1.13.16;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.12 17-Oct-2007  garbled branches: 1.12.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.11 21-Dec-2006  yamt branches: 1.11.6; 1.11.14; 1.11.22; 1.11.24; 1.11.26; 1.11.28;
merge yamt-splraiseipl branch.

- finish implementing splraiseipl (and makeiplcookie).
http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
- complete workqueue(9) and fix its ipl problem, which is reported
to cause audio skipping.
- fix netbt (at least compilation problems) for some ports.
- fix PR/33218.
 1.10 30-Jun-2006  freza branches: 1.10.4; 1.10.6;
Bring ibm4xx interrupt code up to date:

- generic soft interrupts (ie. use powerpc/softintr.c)
- interrupt event counters (using the ones from powerpc/cpu.h:cpu_info
where appropriate)
- cleanup ibm4xx_intr.h, move implementation details to intr.c

Convert all affected evbppc platforms.

OK by simonb@, some points discussed with matt@
 1.9 24-Dec-2005  perry branches: 1.9.4; 1.9.8; 1.9.16;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 27-Nov-2005  yamt implement splraiseipl() for the following ports.
evbppc, evbmips, evbsh3, hp700, mac68k, vax, x68k.
 1.7 01-Jun-2004  matt branches: 1.7.12; 1.7.18;
Fix softnet intr handling (to be like the generic ppc softintr).
 1.6 03-Sep-2003  matt branches: 1.6.2;
Move CLKF_BASEPRI to machine specific <intr.h> file since it depends on
the encoding of the spl for the port.
 1.5 09-Apr-2003  matt branches: 1.5.2;
Make the imask_t typedef a struct rather than a naked array. The attribute
on the array typedef was contaminating other u_int32_t naked arrays and
affecting their alignment.
 1.4 17-Mar-2003  matt Add __HAVE_GENERIC_SOFT_INTERRUPT support.
 1.3 16-Mar-2003  matt Use "b" constraint so r0 won't be used.
 1.2 15-Mar-2003  matt Make lint happy and use __asm && __volatile.
manipulate netisr via lwarx/stwcx. to get atomicity.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.5.2.4 11-Dec-2005  christos Sync with head.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.2.1 04-Jun-2004  jmc Pullup rev 1.7 (requested by matt in ticket #436)

Fix softnet intr handling (to be like the generic ppc softintr).
 1.7.18.1 29-Nov-2005  yamt sync with head.
 1.7.12.4 07-Dec-2007  yamt sync with head
 1.7.12.3 27-Oct-2007  yamt sync with head.
 1.7.12.2 30-Dec-2006  yamt sync with head.
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.9.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.9.8.1 11-Aug-2006  yamt sync with head
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.6.1 20-Sep-2006  yamt implement new api for evbppc.
 1.10.4.1 12-Jan-2007  ad Sync with head.
 1.11.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.26.1 18-Oct-2007  yamt sync with head.
 1.11.24.2 09-Jan-2008  matt sync with HEAD
 1.11.24.1 06-Nov-2007  matt sync with HEAD
 1.11.22.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.11.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.14.1 17-Oct-2007  garbled Back out most of the PIC rennovation on ev64260, it was not completed,
and can be completed post-merge. With these changes, ev64260 compiles
again on the branch. Untested.
 1.11.6.2 03-Dec-2007  ad Sync with HEAD.
 1.11.6.1 23-Oct-2007  ad Sync with head.
 1.12.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.16.1 18-May-2008  yamt sync with head.
 1.13.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.2.3 11-Aug-2010  yamt sync with head.
 1.14.2.2 04-May-2009  yamt sync with head.
 1.14.2.1 16-May-2008  yamt sync with head.
 1.15.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.16.4.1 30-May-2010  rmind sync with head
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.17.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.5 05-Jul-2013  joerg branches: 1.5.8; 1.5.12;
Set pc_intr_map only once.
 1.4 17-Aug-2011  matt branches: 1.4.2; 1.4.12; 1.4.16;
First pass of the new PCI MSI/MSI ABI definitions. (return EOPNOTSUPP for
now).
 1.3 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.2 13-Dec-2010  matt Change definition of pc_bus_maxdevs to get a void * instead a pci_chipset_tag_t
to match its use in pci_bus_maxdevs. This makes it the same as pci_conf_read
and pci_conf_write.
Change all struct device * to device_t.
[Obviously nothing ever used the first argument to pc_bus_maxdevs since it
could have never worked because it wasn't being passed a pci_chipset_tag_t.]
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Clean up gt and peripherals.
This change tested compile only.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file pci_machdep.c was added on branch yamt-nfs-mp on 2010-08-11 22:52:35 +0000
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file pci_machdep.c was added on branch rmind-uvmplock on 2010-05-30 05:17:03 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file pci_machdep.c was added on branch uebayasi-xip on 2010-04-30 14:39:44 +0000
 1.4.16.1 28-Aug-2013  rmind sync with head
 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.4.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.12.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5.8.1 05-Dec-2016  skrll Sync with HEAD
 1.9 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.8 26-Dec-2007  mrg branches: 1.8.10; 1.8.24; 1.8.30; 1.8.32;
move
extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
where everyone can see it. fixes ofppc builds.
 1.7 11-Dec-2005  christos branches: 1.7.50; 1.7.56; 1.7.60; 1.7.64;
merge ktrace-lwp.
 1.6 02-Aug-2004  tacha branches: 1.6.12;
remove obsolete "pci_enumerate_bus" definition.
 1.5 19-May-2003  scw branches: 1.5.2;
Fix an obvious pasto.
 1.4 16-May-2003  scw Add parentheses around macro arguments.
 1.3 15-Mar-2003  matt This contains no marvell specific code now. It now completely hides the
underlying PCI MD implementation. XXX want to move this to
powerpc/include/ someday.
 1.2 06-Mar-2003  matt Remove unneeded conditional code.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.12.1 21-Jan-2008  yamt sync with head
 1.7.64.1 02-Jan-2008  bouyer Sync with HEAD
 1.7.60.1 26-Dec-2007  ad Sync with head.
 1.7.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.50.1 09-Jan-2008  matt sync with HEAD
 1.8.32.1 30-May-2010  rmind sync with head
 1.8.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.24.1 24-Oct-2010  jym Sync with HEAD
 1.8.10.1 11-Aug-2010  yamt sync with head.
 1.8 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.7 01-Feb-2012  matt branches: 1.7.6; 1.7.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.6 30-Jan-2012  matt Use proper ANSI prototypes for foo() -> foo(void)
Caught when compiling with -Wold-style-definition
 1.5 20-Jun-2011  matt branches: 1.5.2; 1.5.6;
Add __CTASSERT(sizeof(imask_t) == sizeof(uint64_t));
 1.4 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.3 28-Apr-2010  kiyohara branches: 1.3.6;
Clean up gt and peripherals.
This change tested compile only.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.26; 1.2.46; 1.2.48;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 11-May-2007  matt branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file pic_discovery.c was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1 11-May-2007  matt Not compile-tested. marvell discovery (64260) pic code.
 1.2.48.1 30-May-2010  rmind sync with head
 1.2.46.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.26.1 11-Aug-2010  yamt sync with head.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pic_discovery.c was added on branch matt-armv6 on 2007-11-06 23:20:42 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pic_discovery.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:50 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pic_discovery.c was added on branch vmlocking on 2007-10-23 20:36:08 +0000
 1.3.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.7.24.1 28-Aug-2017  skrll Sync with HEAD
 1.7.6.1 03-Dec-2017  jdolecek update from HEAD
 1.2 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.1 05-Mar-2003  matt branches: 1.1.108; 1.1.122; 1.1.128; 1.1.130;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.130.1 30-May-2010  rmind sync with head
 1.1.128.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.122.1 24-Oct-2010  jym Sync with HEAD
 1.1.108.1 11-Aug-2010  yamt sync with head.
 1.35 15-Jun-2024  mrg don't do anything in vec_restore_from_mcontext() if no altivec.

fixes a crash seen on netbsd-10 in PR#58283.

XXX: pullup-10.
 1.34 30-Oct-2021  thorpej branches: 1.34.4;
- In vec_restore_from_mcontext() and vec_save_to_mcontext(), allows the
mcontext argument to be NULL.
- In sendsig_sigcontext(), don't set PSL_VEC in the saved MSR; we can't
actually round-trip the AltiVec registers. At least get them saved
into the PCB by calling vec_save_to_mcontext() (with a NULL mcontext
argument).
- In compat_16_sys___sigreturn14(), call vec_restore_from_mcontext()
with a NULL mcontext argument, which will force any subsequent use
of AltiVec to re-load the AltiVec registers from the PCB.

This isn't ideal, but it's the best we can do with the limited capability
of sigcontext.

Fixes PR port-powerpc/56471.
 1.33 06-Jul-2020  rin Drop unused opt_multiprocessor.h includes.
 1.32 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.31 16-Mar-2017  chs allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.30 06-Jul-2015  matt branches: 1.30.2; 1.30.4;
Don't reload if just re-enabling
 1.29 16-May-2014  rmind branches: 1.29.2; 1.29.4;
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.28 23-Aug-2013  matt branches: 1.28.2;
Get rid of MDLWP_USED{FPU,VEC}
 1.27 22-Aug-2013  drochner -extend the pcu(9) API by a function which saves all context on the
current CPU, and use it if a CPU is taken offline
-add a bool argument to pcu_discard which tells whether the internal
"LWP has used the coprocessor" flag should be set or reset. The flag
is reported by pcu_used_p(). If set, future accesses should use the
state stored in the PCB. If reset, it should be reset to default.
The former case is useful for setmcontext().
With that, it should not be necessary anymore to manage the "FPU used"
state by an additional MD variable.

approved by matt
 1.26 26-Dec-2012  matt branches: 1.26.2;
Update to new pcu_state_{load,state,release} definitions
 1.25 07-Jun-2011  matt branches: 1.25.2; 1.25.8; 1.25.12;
zero PCU area when loading used area.
 1.24 25-May-2011  matt branches: 1.24.2;
Set PSL_VEC in the right place.
 1.23 02-May-2011  matt Make sure to enable the vector unit in the PSL when returning to userland.
 1.22 02-May-2011  matt Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.21 08-Feb-2011  matt Powerpc send_ipi use ci_cpuid, not cpu_index
 1.20 23-Jan-2011  matt Clear ownership bit after saving contents to PCB.
 1.19 18-Jan-2011  matt branches: 1.19.2;
Fix some fallout from building the macppc GENERIC.MP.
 1.18 18-Jan-2011  matt 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.17 14-Jan-2011  rmind branches: 1.17.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.16 25-Feb-2010  matt branches: 1.16.2;
Adapt to spr.h breakup.
 1.15 21-Nov-2009  rmind branches: 1.15.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.14 08-Apr-2008  garbled branches: 1.14.4; 1.14.6; 1.14.26;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.13 17-Oct-2007  garbled branches: 1.13.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 09-Feb-2007  ad branches: 1.12.6; 1.12.14; 1.12.22; 1.12.24; 1.12.26; 1.12.28;
Merge newlock2 to head.
 1.11 24-Dec-2005  perry branches: 1.11.20;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 11-Apr-2005  nathanw branches: 1.9.2;
Rewrite the inner loop of vcopypage() and vzeropage() to be entirely
in inline asm and include turning the DMMU off and back on. This
prevents the compiler (especially gcc -O0) from inserting accesses to
locations in virtual address space when such accesses would fail.
 1.8 22-Feb-2005  matt Don't clear PCB_FPU/PCB_ALTIVEC when releasing the FPU/AltiVec unit. Add
new flags to indicate whether the PCB currently owns the FPU/AltiVec unit.
 1.7 16-Apr-2004  matt branches: 1.7.4; 1.7.6;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.6 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 23-Jun-2003  martin branches: 1.4.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.3 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.2 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.4.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.9.2.3 27-Oct-2007  yamt sync with head.
 1.9.2.2 26-Feb-2007  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.11.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.26.1 18-Oct-2007  yamt sync with head.
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.14.1 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.12.6.1 23-Oct-2007  ad Sync with head.
 1.13.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.26.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.14.26.1 07-Jan-2011  matt Deal with new powerpc world.
 1.14.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.14.4.1 11-Mar-2010  yamt sync with head
 1.15.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.3 12-Jun-2011  rmind sync with head
 1.16.2.2 31-May-2011  rmind sync with head
 1.16.2.1 05-Mar-2011  rmind sync with head
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.24.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.25.12.3 03-Dec-2017  jdolecek update from HEAD
 1.25.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.12.1 25-Feb-2013  tls resync with head
 1.25.8.3 19-Nov-2015  bouyer Revert ticket 1310 (second try):
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.25.8.2 16-Nov-2015  bouyer Revert ticket 1310:
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.25.8.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.30
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revision 1.29
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/oea/altivec.c: revision 1.30
Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Don't reload if just re-enabling
Don't reload the FPU register if this is just a re-enable.
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.25.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.25.2.1 23-Jan-2013  yamt sync with head
 1.26.2.2 18-May-2014  rmind sync with head
 1.26.2.1 28-Aug-2013  rmind sync with head
 1.28.2.1 10-Aug-2014  tls Rebase.
 1.29.4.2 28-Aug-2017  skrll Sync with HEAD
 1.29.4.1 22-Sep-2015  skrll Sync with HEAD
 1.29.2.1 17-Jul-2015  snj Pull up following revision(s) (requested by matt in ticket #868):
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revisions 1.29, 1.30
sys/arch/powerpc/oea/altivec.c: revision 1.30
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
Add a check to make sure that if PSL_FP is set, we own the FPU.
--
Don't clear PSL_FP/PSL_VEC
--
Don't reload if just re-enabling
--
Don't reload the FPU register if this is just a re-enable.
--
Remove PSL_SPV from BOOKE PSL_USERMOD
--
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.30.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.30.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.34.4.1 03-Jul-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #732):

sys/arch/powerpc/oea/altivec.c: revision 1.35

don't do anything in vec_restore_from_mcontext() if no altivec.
fixes a crash seen on netbsd-10 in PR#58283.
 1.3 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 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 17-Jan-2011  matt branches: 1.1.2;
file altivec_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.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 18-Jan-2011  jruoho file altivec_subr.S was added on branch jruoho-x86intr on 2011-06-06 09:06:29 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file altivec_subr.S was added on branch rmind-uvmplock on 2011-03-05 20:51:39 +0000
 1.3 06-Jul-2020  rin Drop unused opt_ppcparam.h.
 1.2 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.1 01-Jun-2018  macallan branches: 1.1.2;
add clock speed control for 970MP CPUs
 1.1.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.1.2.1 01-Jun-2018  pgoyette file cpu_speedctl.c was added on branch pgoyette-compat on 2018-06-25 07:25:45 +0000
 1.111 17-Feb-2025  jmcneill powerpc: Identify Broadway CPU.

Use hex to report Broadway revision and ignore TAU as it does not exist
on this processor.
 1.110 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.109 20-Jan-2024  jmcneill branches: 1.109.2;
powerpc: oea: Decode IBM750CL L2 cache information.
 1.108 21-Mar-2021  rin branches: 1.108.16;
Fix copy-paste.
 1.107 26-Feb-2021  thorpej branches: 1.107.2;
Split cpu_model_init() into cpu_features_probe() and cpu_features_enable()
so that early bootstrap can do those two steps independently, if needed.

Continue to provide a cpu_model_init() wrapper for now.
 1.106 26-Feb-2021  thorpej Declare oeacpufeat once, in powerpc/oea/cpu_subr.c, rather than in
N different locore.S files.
 1.105 24-Feb-2021  thorpej Add a provision for a per-cpu battable. Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.
 1.104 06-Jul-2020  rin branches: 1.104.2;
Include missing opt_ppcarch.h.
 1.103 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.102 25-Oct-2019  macallan register the IPI before spinning up CPUs, and make sure to do it exactly once
with this, and previous commits, G5s with four CPUs work
tested by Romain Dolbeau
 1.101 20-Sep-2019  macallan don't enable NAP mode on 7450 CPUs - my Quicksilver has two of those and we
hang hard shortly after boot with NAP enabled, even on UP kernels
 1.100 02-Aug-2019  macallan first step to address PR54331:
poll h->hatch_running for a bit instead of blindly relying on a fixed timeout
for secondary CPUs to wake up and get ready

needs more testing, possibly pullup
 1.99 06-Feb-2019  mrg - add or adjust fallthru comments
 1.98 06-Jan-2019  phx Only execute dssall when the CPU has the Altivec instruction set extension.
 1.97 15-Jun-2018  uwe branches: 1.97.2;
Fix fmttab value for L2CR_L2PE (parity enabled) so that we don't print
self-contradictory "no parity parity enabled".
 1.96 08-Jun-2018  macallan when switching CPU speed using DFS, only use xcalls on MULTIPROCESSOR kernels
 1.95 01-Jun-2018  macallan add clock speed control for 970MP CPUs
 1.94 25-May-2018  macallan copy HID1 from the boot CPU to secondary CPUs as well on 64bit CPUs
now the 2nd CPU on my G5s runs at full speed
 1.93 04-May-2018  macallan save & restore HID4 and HID5, zero SPR_HIOR on 970
 1.92 29-Mar-2018  macallan fix build for 32bit non-bridge SMP kernels
 1.91 22-Mar-2018  macallan first step towards G5 SMP:
- only save/restore BATs on CPUs that have them
- treat HID0 as 64bit on 64bit CPUs
 1.90 04-Mar-2018  mrg branches: 1.90.2;
avoid 32 bit only code in 64 bit mode.
 1.89 16-Feb-2018  macallan use mtspr64() in bridge mode
 1.88 21-Jan-2018  mrg fix ofppc/pegasosII (and maybe others).

don't assume PPC_OEA64_BRIDGE means we have a 64 bit cpu (code
for 64 bit in bridge and normal 32 bit can co-exist due to
fixups the early boot code does has, and ofppc builds GENERIC
this way):
- fix mtmsr()/mfmsr() to use the right method based upon the
actually cpu booted on.
- fix cpu_setup() to have 32 bit and 64 bit hid0 variables
and operate on the right one based upon the current cpu.
restore a minor optimisation of not writing hid0 if it
didn't change.

in set_timebase() check if OF_finddevice("/cpus/@0") failed
and returned -1 before using it for OF_getprop().
 1.87 06-Jan-2018  snj fix a few typos in comments
 1.86 30-Sep-2017  macallan use 7450 HID0 bitmask on 7447A and 7448 as well
 1.85 11-Jul-2017  maya inline HAVE_64BIT_HID0 and remove macro definition.

Fixes llvm INSTALL kernel build, which failed with:
error: macro expansion producing 'defined' has undefined behavior
 1.84 07-Jul-2017  macallan remove accidential debug printf()
 1.83 07-Jul-2017  macallan deal with ppc970's HID0
 1.82 24-Mar-2014  christos branches: 1.82.6;
use cpu_{g,s}etmodel
 1.81 14-Mar-2014  mrg remove various set-but-unused variables.
 1.80 03-Nov-2013  mrg - remove set but unused variables
- move some variables inside their relevant use #ifdef
 1.79 22-Sep-2013  matt Fix c&p bug.
 1.78 22-Sep-2013  matt Disable XBSEN for the 7450.
 1.77 22-Sep-2013  matt Make sure ABE/SYNCBE are enabled in HID1 for the 7450 CPUs
Enable XBSEN for the 7450.
 1.76 20-Oct-2012  kiyohara branches: 1.76.2;
Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.75 20-Oct-2012  kiyohara Fix broken cpu_hatch_stack.
And define macro HATCH_STACK_SIZE.
 1.74 20-Oct-2012  kiyohara Remove white-spaces. And remove unused 'extern void tlbia()'.
 1.73 01-Feb-2012  matt branches: 1.73.6;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.72 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.71 23-Jan-2012  phx Insert some missing aprint_naive().
 1.70 29-Jun-2011  matt branches: 1.70.2; 1.70.6;
Cleanup hatch names.
Add cpuset_info.
 1.69 21-Jun-2011  matt Reap the ci_ev_soft* evcnts since every variant implements __HAVE_FAST_SOFTINTS
 1.68 20-Jun-2011  pgoyette Initialize sensor state before registering.
 1.67 20-Jun-2011  matt <arch/powerpc/... -> <powerpc/...
 1.66 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.65 16-Jun-2011  matt Make sure to set curlwp (aka r13) in cpu_hatch
 1.64 12-Jun-2011  matt Use mtsprg0 instead of mtsprg 0,r
 1.63 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.62 12-Feb-2011  matt branches: 1.62.2;
Add support for the IBM750GX (from Bob Lee).
 1.61 18-Jan-2011  matt branches: 1.61.2;
Fix some fallout from building the macppc GENERIC.MP.
 1.60 18-Jan-2011  matt 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.59 06-Nov-2010  uebayasi branches: 1.59.2;
Machine dependent code is considered as part of UVM. Include
internal API header.
 1.58 05-Nov-2010  phx Only read from HID1 when a G3 CPU was detected in cpu_get_dfs(), otherwise
the access might cause a PGM trap.
 1.57 28-Oct-2010  macallan Use nap mode on 750-ish CPUs
 1.56 20-Oct-2010  phx Support sysctl machdep.cpu_speed for 7447A and 7448 based Macs. On those
machines the CPU's DFS (Dynamic Frequency Switching) feature is used instead
of a GPIO to control the speed.
Two new functions in powerpc/oea/cpu_subr.c were introduced to support
reading and writing of DFS: cpu_get_dfs() and cpu_set_dfs(). Also works
for multiple CPUs, but not before interrupts are enabled.
 1.55 25-Feb-2010  matt branches: 1.55.2;
Adapt to spr.h breakup.
 1.54 21-Nov-2009  rmind branches: 1.54.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.53 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.52 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.51 16-Dec-2008  christos branches: 1.51.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.50 14-Oct-2008  macallan branches: 1.50.2; 1.50.14;
Some fixes to the TAU support code:
- set the ADC time according to clock speed, not some magic number
- move some mtspr()s which we really only need to do once
- make our envsys_data_t static, this should fix PR 39411
 1.49 04-Oct-2008  chs in cpu_hatch(), set PIR when the current value is not what we need
rather than only when it's zero.
 1.48 23-Sep-2008  macallan properly 'probe' the MPC7400's L1 caches - before we'd fall through to
setting both to PAGE_SIZE
 1.47 25-May-2008  chs branches: 1.47.4;
add IBM970MP (used in the last model of powermac G5).
 1.46 08-Apr-2008  garbled branches: 1.46.2; 1.46.4; 1.46.6;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.45 23-Feb-2008  matt Detect HIGHBAT/XBSEN/HIGHSPRG to MPC74[45]x where x > 1
Enable above as appropriate.
 1.44 14-Feb-2008  garbled branches: 1.44.2; 1.44.6;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.43 05-Feb-2008  garbled Replace as much of the hardcoded CACHELINESIZE with
curcpu()->ci_ci.dcache_line_size as I can. With this change, an ofppc kernel
compiled with both PPC_OEA and PPC_OEA64_BRIDGE defined, boots.
 1.42 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.41 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.40 31-Dec-2007  garbled On the 745x cpu, you have to invalidate cache slightly differently than
you do on the other cpus. Add an if statement that takes this into account.
 1.39 31-Dec-2007  macallan 'never try to fix more than one thing at once, especially if one is a crash'
backout bogus G4 CPU revision 'fix'
 1.38 30-Dec-2007  macallan Remove a superfluous /* FALLTHROUGH */
Also switch back to waiting for L2CR_L2IP in cpu_enable_l2cr() - now my 2nd
G4 spins up again.
 1.37 30-Dec-2007  macallan Fix a logic botch when setting up L3 cache - don't attempt to do so on CPUs
that can't have L3 cache. While there also fix revision reporting for MPC7400
so what we report matches MacOS X.
 1.36 27-Dec-2007  garbled Lots and lots of fixes to the cpu identification code, and dealing with
L2 and L3 cache initialization. Mostly to get the L2 enabled on the
pegasos, but since I had the manual, I fixed a few other things I saw
while I was there.
 1.35 17-Nov-2007  kefren branches: 1.35.6;
Initialize sensor's state
on behalf of xtraeme
 1.34 16-Nov-2007  xtraeme Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.33 17-Oct-2007  garbled branches: 1.33.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.32 01-Jul-2007  xtraeme branches: 1.32.8; 1.32.10; 1.32.12; 1.32.14;
Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.31 25-Jun-2007  aymeric Recognize the Freescale G2 cores: initialize cache line size, and doze mode
While there, fix the way the major version of a PowerPC processor is computed
 1.30 02-Jun-2007  nisimura - add MPC8245 to cpuname table.
 1.29 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.28 30-Oct-2006  garbled branches: 1.28.4; 1.28.8; 1.28.10; 1.28.16;
Make these files compile with -Wextra -Wno-unused.
 1.27 05-Aug-2006  sanjayl branches: 1.27.4; 1.27.6;
1st cut of Powermac G5 support (uses bridge mode).
 1.26 24-Dec-2005  perry branches: 1.26.4; 1.26.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.25 11-Dec-2005  christos merge ktrace-lwp.
 1.24 02-Jun-2005  he branches: 1.24.2;
Fix shadowing and cast qualification warnings.
 1.23 03-Feb-2005  briggs Keep track of the CPU's current speed (in kHz) in the cpu info structure,
if we can get it. May want to expand this in the future to include min
and max speeds for systems where we can adjust the speed.
 1.22 21-Jan-2005  matt branches: 1.22.2;
Add more support for MPC7447A/MPC7448.
 1.21 20-Jan-2005  matt Add entry for MPC7447A
 1.20 19-Jan-2005  matt Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.19 11-Jan-2005  chs branches: 1.19.2;
enable powersave mode on 7450 and family.
also, the HID0_DOZE bit in this context doesn't mean "doze",
it's actually "enable extra BATs". add an alias for this bit
and use it as appropriate.
 1.18 07-Jan-2005  briggs Allow MSR[POW] off for power saving on 604-era CPUs. From Tim Kelly.
XXX -- needs benchmarking
 1.17 07-Jan-2005  briggs Don't attempt to probe the cache with l2cr on 604ev. From Tim Kelly.
 1.16 08-Dec-2004  briggs Add MPC7400 to the list of CPUs for which we try to measure the speed.
Noticed missing by Tim Kelly.
 1.15 06-Dec-2004  briggs Minor (old) patch from me to correct CPU ID of 604e vs. 604ev.
Tested by Tim Kelly.
Also patched from Tim to
- Delay longer for second CPU spinup.
- Only attempt to print CPU speed and cache configuration on certain
CPU types.
 1.14 26-Jun-2004  kleink On OEA, turn PSL_USER* into runtime values appropriate for the CPU model
we're executing on; besides dealing with the bits not implemented in the
601's MSR it also removes the silent failure behaviour when passing
PSL_VEC set on a CPU not implementing it.

Also, fix those masks for the 4xx again.
 1.13 11-Mar-2004  christos PR/24741: Aymeric Vincent: Variable sme_flags isn't initialized to zero
 1.12 17-Feb-2004  matt Don't waste space on likely unused sysmon structure.
Instead malloc them as needed.
 1.11 09-Oct-2003  matt Add support for MPC74[45]7
 1.10 04-Aug-2003  matt Make that OEA based kernels can properly deal with kernel ISI faults. Now
that LKMs are supported, it is possible for a LKM page to be "outspilled"
resulting in a possible ISI fault. Try to spill the page back in.
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 10-Apr-2003  scw branches: 1.8.2;
Re-read L2CR after enabling the L2 cache to avoid returning without
printing the cache details.
 1.7 04-Apr-2003  matt Rework l2cr/l3cr enabling/printing code. Make printing table driven.
 1.6 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.5 29-Mar-2003  matt Make sure to turn on the speed knobs in HID0 on the 745x.
 1.4 15-Mar-2003  matt s;backside;; and report L2CR_L2DO & L2CR_L2IO
 1.3 14-Mar-2003  matt Use aprint_normal. Print 2MB L2 sizes with 7410.
 1.2 26-Feb-2003  jklos Added L3CR_CONFIG for support of 745x G4 L3 cache configuration.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.8.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.7 04-Feb-2005  skrll Sync with HEAD.
 1.8.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.8.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.1 29-Apr-2005  kent sync with -current
 1.22.2.1 12-Feb-2005  yamt sync with head.
 1.24.2.8 27-Feb-2008  yamt sync with head.
 1.24.2.7 11-Feb-2008  yamt sync with head.
 1.24.2.6 21-Jan-2008  yamt sync with head
 1.24.2.5 07-Dec-2007  yamt sync with head
 1.24.2.4 27-Oct-2007  yamt sync with head.
 1.24.2.3 03-Sep-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.26.8.1 11-Aug-2006  yamt sync with head
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.6.1 10-Dec-2006  yamt sync with head.
 1.27.4.1 18-Nov-2006  ad Sync with head.
 1.28.16.7 11-Oct-2007  garbled Fix the NOTICE: curlwp should be set before main() on OEA machines.
 1.28.16.6 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.28.16.5 04-Oct-2007  macallan add event counters for IPIs received on each CPU
 1.28.16.4 03-Oct-2007  garbled Sync with HEAD
 1.28.16.3 02-Aug-2007  macallan sync with HEAD
 1.28.16.2 26-Jun-2007  garbled Sync with HEAD.
 1.28.16.1 22-May-2007  matt Update to HEAD.
 1.28.10.1 11-Jul-2007  mjf Sync with head.
 1.28.8.5 03-Dec-2007  ad Sync with HEAD.
 1.28.8.4 23-Oct-2007  ad Sync with head.
 1.28.8.3 15-Jul-2007  ad Sync with head.
 1.28.8.2 09-Jun-2007  ad Sync with head.
 1.28.8.1 27-May-2007  ad Sync with head.
 1.28.4.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.32.14.2 18-Nov-2007  bouyer Sync with HEAD
 1.32.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.32.12.1 18-Oct-2007  yamt sync with head.
 1.32.10.3 23-Mar-2008  matt sync with HEAD
 1.32.10.2 09-Jan-2008  matt sync with HEAD
 1.32.10.1 06-Nov-2007  matt sync with HEAD
 1.32.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.32.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.33.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.33.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.35.6.2 19-Jan-2008  bouyer Sync with HEAD
 1.35.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.44.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.44.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.44.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.44.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.44.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.44.2.1 24-Mar-2008  keiichi sync with head.
 1.46.6.2 10-Oct-2008  skrll Sync with HEAD.
 1.46.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.46.4.2 11-Mar-2010  yamt sync with head
 1.46.4.1 04-May-2009  yamt sync with head.
 1.46.2.1 04-Jun-2008  yamt sync with head
 1.47.4.1 19-Oct-2008  haad Sync with HEAD.
 1.50.14.4 12-Feb-2011  matt Add IBM750GX support (from Bob Lee).
 1.50.14.3 28-Jan-2011  matt IBM750FX has HIGHBAT (BATs >= 4)
 1.50.14.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.50.14.1 07-Jan-2011  matt Deal with new powerpc world.
 1.50.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.50.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.51.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.54.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.54.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.54.2.2 27-May-2010  uebayasi Fix build.
 1.54.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.55.2.2 12-Jun-2011  rmind sync with head
 1.55.2.1 05-Mar-2011  rmind sync with head
 1.59.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.61.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.62.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.70.6.1 18-Feb-2012  mrg merge to -current.
 1.70.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.70.2.2 30-Oct-2012  yamt sync with head
 1.70.2.1 17-Apr-2012  yamt sync with head
 1.73.6.3 03-Dec-2017  jdolecek update from HEAD
 1.73.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.73.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.76.2.1 18-May-2014  rmind sync with head
 1.82.6.1 28-Aug-2017  skrll Sync with HEAD
 1.90.2.4 18-Jan-2019  pgoyette Synch with HEAD
 1.90.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.90.2.2 21-May-2018  pgoyette Sync with HEAD
 1.90.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.97.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.97.2.1 10-Jun-2019  christos Sync with HEAD
 1.104.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.107.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.108.16.2 22-Feb-2025  martin Pull up following revision(s) (requested by jmcneill in ticket #1057):

distrib/utils/embedded/conf/evbppc.conf: revision 1.4
sys/arch/powerpc/oea/cpu_subr.c: revision 1.111
sys/arch/evbppc/wii/pic_pi.c: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.9
sys/arch/evbppc/wii/dev/bwai.c: revision 1.4

wii: Simplify Processor Interface pic code.

wii: Audio playback improvements.
Instead of resetting the byte counter for every block (which is racy),
increment the interrupt timing register by the exact byte count for
each block. Should do better at keeping things in sync.

powerpc: Identify Broadway CPU.
Use hex to report Broadway revision and ignore TAU as it does not exist
on this processor.

wii: Remove some options to save memory.

wii: Disable ntpd by default.
It takes up a lot of memory.
 1.108.16.1 03-Feb-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #561):

etc/etc.evbppc/Makefile.inc: revision 1.15
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.2
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.3
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.2
distrib/utils/embedded/files/evbppc_wii_icon.png: revision 1.1
usr.sbin/sysinst/arch/evbppc/md.h: revision 1.4
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.4
sys/arch/evbppc/wii/dev/viio.h: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.5
sys/arch/evbppc/wii/dev/mainbus.h: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.2
distrib/utils/embedded/conf/wii.conf: revision 1.3
sys/dev/sdmmc/sdhcvar.h: revision 1.34
sys/dev/sdmmc/sdhc.c: revision 1.118
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.1
distrib/utils/embedded/conf/evbppc.conf: revision 1.1
sys/dev/wsfb/genfb.c: revision 1.91
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.2
sys/dev/wscons/wsconsio.h: revision 1.127
sys/arch/powerpc/oea/oea_machdep.c: revision 1.85
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.1
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.2
sys/arch/evbppc/conf/std.wii: revision 1.3
sys/arch/powerpc/oea/cpu_subr.c: revision 1.109
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.1
sys/dev/usb/usb.h: revision 1.124
sys/arch/evbppc/wii/machdep.c: revision 1.1
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.1
sys/arch/powerpc/include/oea/hid.h: revision 1.14
sys/arch/evbppc/wii/mainbus.c: revision 1.1
sys/arch/evbppc/wii/machdep.c: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.1
sys/arch/evbppc/wii/mainbus.c: revision 1.2
sys/arch/evbppc/wii/machdep.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.2
sys/arch/evbppc/wii/mainbus.c: revision 1.3
sys/arch/evbppc/wii/machdep.c: revision 1.4
sys/arch/evbppc/wii/dev/hwgpio.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.2
sys/arch/evbppc/wii/wii_locore.S: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.1
sys/arch/evbppc/wii/wii_locore.S: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.2
sys/arch/evbppc/wii/dev/exi.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.2
sys/arch/evbppc/conf/files.wii: revision 1.3
sys/arch/powerpc/powerpc/clock.c: revision 1.18
sys/arch/evbppc/include/wii.h: revision 1.3
sys/arch/evbppc/conf/files.wii: revision 1.4
sys/arch/evbppc/include/wii.h: revision 1.4
sys/arch/evbppc/wii/dev/exi.h: revision 1.1
sys/arch/evbppc/wii/dev/avenc.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.5
sys/arch/evbppc/include/wii.h: revision 1.6
sys/arch/evbppc/include/wii.h: revision 1.7
sys/arch/evbppc/wii/dev/avenc.h: revision 1.1
distrib/utils/embedded/mkimage: revision 1.79
sys/arch/evbppc/conf/WII: revision 1.1
sys/arch/evbppc/conf/INSTALL_WII: revision 1.1
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.1
sys/arch/evbppc/wii/dev/vireg.h: revision 1.1
sys/arch/evbppc/conf/WII: revision 1.2
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.2
sys/arch/evbppc/wii/dev/vireg.h: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.3
sys/arch/evbppc/conf/WII: revision 1.4
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.11
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.1
sys/dev/usb/ehcivar.h: revision 1.52
sys/arch/evbppc/wii/pic_pi.c: revision 1.1
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.2
etc/etc.evbppc/ttys: revision 1.8
sys/arch/evbppc/wii/dev/bwai.c: revision 1.1
sys/arch/evbppc/wii/dev/bwai.c: revision 1.2
sys/arch/evbppc/wii/dev/bwai.c: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.1
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.1
sys/arch/evbppc/wii/dev/bwai.h: revision 1.1
sys/arch/evbppc/wii/autoconf.c: revision 1.2
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.2

powerpc: oea: Fix prefetchable mappings
Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
powerpc: oea: Decode IBM750CL L2 cache information.
sdmmc: add support for optional delay after register write
wscons: Add HOLLYWOOD display and YUY2 pixel format types
wsfb: add support for optional "devcmap" property
A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.
ehci: add EHCIF_32BIT_ACCESS flag to force 32-bit MMIO
fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
powerpc: fix delay for large (> ~5sec) values
When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
usb: increase USB_PORT_RESET_RECOVERY from 10ms to 20ms
I changed this from 250ms to 10ms back in 2021 based on a similar FreeBSD
change, but it seems to be a bit too aggressive for some platforms.
evbppc: Add initial support for the Nintendo Wii
wii: support RB_POWERDOWN
build fix: use dd with count=1 for compat with NetBSD dd(1)
wii: Add NTSC 480p support.
In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.
wii: Add 128x48 icon to SD card image
wii: Fix a comment
wii: Add drivers for Broadway DSP and Audio interface.
0: [*] audio0 @ bwdsp0: Broadway DSP
playback: 16, 2ch, 48000Hz
record: unavailable
(P-) slinear_be 16/16, 2ch, { 48000 }
wii: Add screenblank support.
wii: Use screen dimming register for screen blanking.
wii: Add GPIO, I2C, and basic A/V encoder driver.
wii: Use A/V encoder volume controls instead of using a software filter.
wii: Simply DSP driver - no interrupt handler required.
wii: provide device names to intr_establish
wii$ intrctl list
interrupt id CPU0 device name(s)
pi irq 14 64769* hollywood0
hollywood irq 36 5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0
wii: Add support for passing boot options to the kernel.
wii: Add External interface bus and RTC support
wii: Remove objcopy after kernel build.
HBC will do the right thing.
Add wsvt25 entries (off by default) for ttyE0-ttyE3.
Add support for "PAL" (576i) mode on Wii.
 1.109.2.1 02-Aug-2025  perseant Sync with HEAD
 1.29 24-Feb-2021  thorpej Add a provision for a per-cpu battable. Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.
 1.28 06-Jul-2020  rin branches: 1.28.2;
Style and cosmetic changes. No binary changes intended.
 1.27 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.26 01-Feb-2012  matt branches: 1.26.46; 1.26.48;
Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.25 20-Jun-2011  matt branches: 1.25.2; 1.25.6;
Don't include *pmap.h in assembly files. Get the needed definitions
from "assym.h".
 1.24 20-Jun-2011  matt Make struct cpu_info the same size if building MODULAR
kernels or compiling a module.
 1.23 18-Jun-2011  matt Make a common genassym.cf (powerpc/genassym.cf) and then
only put specific stuff in foo/genassym.cf
 1.22 17-Jun-2011  matt Add IPL_HIGH and IPL_SCHED so locore.S can use them.
 1.21 16-Jun-2011  matt ifdef / define / endif can't be the first thing. So move that block down.
 1.20 16-Jun-2011  matt Make __HAVE_FAST_SOFTINTS appear in assym.h so all oeas don't need to include
<powerpc/intr.h>
XXX <powerpc/intr.h> should be <powerpc/oea/intr.h>
 1.19 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 1.18 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.17 18-Jan-2011  matt branches: 1.17.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.16 20-Mar-2010  chs branches: 1.16.2;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.15 10-Dec-2009  rmind branches: 1.15.2; 1.15.4;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.14 23-Feb-2008  matt branches: 1.14.4; 1.14.26;
Add MTX_* and RW_* definitions
 1.13 05-Feb-2008  garbled branches: 1.13.2; 1.13.6;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.12 17-Oct-2007  garbled branches: 1.12.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.11 18-May-2007  rjs branches: 1.11.10;
Fix for yamt-idlelwp merge.
 1.10 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.9 11-Dec-2005  christos branches: 1.9.26; 1.9.30; 1.9.32; 1.9.38;
merge ktrace-lwp.
 1.8 19-Jan-2005  matt branches: 1.8.8;
Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.7 21-Nov-2003  matt branches: 1.7.8;
Restore ci_curpm since it re-enables 603 to working state.
 1.6 27-Aug-2003  matt Move SFRAMELEN to frame.h and use it in vm_machdep.c. In setfunc, setup
callframe linkages correctly. Restore use of ldptr to locore_subr.S
[pthreads and gdb no longer crash/hang the system]
 1.5 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.4 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.3 08-Aug-2003  matt Nuke ci_spillstk/CI_SPILLSTK. No longer needed.
 1.2 03-Aug-2003  matt Add CPUSAVE_* and each register in the saveframe and faultbuf.
 1.1 03-Feb-2003  matt branches: 1.1.2;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.1.2.4 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.8.8.3 27-Feb-2008  yamt sync with head.
 1.8.8.2 11-Feb-2008  yamt sync with head.
 1.8.8.1 03-Sep-2007  yamt sync with head.
 1.9.38.2 02-Aug-2007  macallan sync with HEAD
 1.9.38.1 22-May-2007  matt Update to HEAD.
 1.9.32.1 11-Jul-2007  mjf Sync with head.
 1.9.30.1 27-May-2007  ad Sync with head.
 1.9.26.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.11.10.2 23-Mar-2008  matt sync with HEAD
 1.11.10.1 06-Nov-2007  matt sync with HEAD
 1.12.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.13.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.2.1 24-Mar-2008  keiichi sync with head.
 1.14.26.3 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.14.26.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.14.26.1 07-Jan-2011  matt Deal with new powerpc world.
 1.14.4.2 11-Aug-2010  yamt sync with head.
 1.14.4.1 11-Mar-2010  yamt sync with head
 1.15.4.3 12-Jun-2011  rmind sync with head
 1.15.4.2 05-Mar-2011  rmind sync with head
 1.15.4.1 30-May-2010  rmind sync with head
 1.15.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.25.6.1 18-Feb-2012  mrg merge to -current.
 1.25.2.1 17-Apr-2012  yamt sync with head
 1.26.48.1 10-Jun-2019  christos Sync with HEAD
 1.26.46.1 28-Jul-2018  pgoyette Sync with HEAD
 1.28.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.26; 1.2.34; 1.2.40;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 09-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file kgdb_glue.c was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1 09-May-2007  garbled Bebox, mvmeppc, pmppc and sandpoint all have this file, and they are all
identical. Put it in one place for all to find.
 1.2.40.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.34.1 28-Apr-2009  skrll Sync with HEAD.
 1.2.26.1 04-May-2009  yamt sync with head.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file kgdb_glue.c was added on branch matt-armv6 on 2007-11-06 23:20:44 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file kgdb_glue.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:53 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file kgdb_glue.c was added on branch vmlocking on 2007-10-23 20:36:08 +0000
 1.85 20-Jan-2024  jmcneill powerpc: oea: Fix prefetchable mappings

Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
 1.84 07-Aug-2022  andvar branches: 1.84.4;
fix typos in comments.
 1.83 05-Dec-2021  msaitoh s/specificed/specified/ in comment.
 1.82 27-Feb-2021  thorpej Rather than putting it on the caller, just let oea_iobat_add() decide
whether to call mpc601_ioseg_add().
 1.81 06-Jul-2020  rin branches: 1.81.2;
Drop unused opt_compat_netbsd.h include.
 1.80 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.79 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.78 31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.77 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.76 06-Feb-2019  mrg - add or adjust fallthru comments
 1.75 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.74 11-Feb-2018  mrg branches: 1.74.2; 1.74.4;
introduce a inline function to set a value to zero while
hiding this fact from GCC. this allows the PPC code that
writes to address zero to actually work rather than cause
GCC to emit an explicit "trap" instruction, which in early
boot means hang on my pegasosII. use this in oae_init()
for both rfid->rfi and also setting the jump-to-zero trap.

found with a lot of debugging, but GCC 6's new warning
-Wnull-dereference found it when i was informed of its
existence. unfortunately, there are dozens of other
violations in our kernel today so simply enabling that
option for everything is not a good idea, but is a goal.
 1.73 30-May-2016  chs allocate cpuset structures needed by MP DDB.
 1.72 06-Jul-2015  matt Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.71 24-Mar-2014  christos branches: 1.71.4; 1.71.6;
use cpu_{g,s}etmodel
 1.70 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.69 28-Feb-2014  matt Use more appropriate type.
 1.68 03-Nov-2013  mrg - remove set but unused variables
- move some variables inside their relevant use #ifdef
 1.67 31-Aug-2013  matt convert rfid to rfi in exception handlers.
 1.66 31-Aug-2013  matt Move the pmap_setup to the start oea_init (no non-OFW ports can use it).
If PPC_OEA64_BRIDGE is defined, add code so that when OEACPU_64_BRIDGE is not
present, it replaces the rfid with rfi and mfmsr/rldicl/mtmsrd sequence
with NOPs. This allows plain OEA kernels to work. (tested on PMPPC with
PPC_OEA64_BRIDGE option added).
 1.65 04-Jul-2013  joerg When trying to write into page 0, use volatile to force the compiler to
actually create this access.
 1.64 16-Feb-2012  matt branches: 1.64.2; 1.64.4;
Allow use of large (>256MB) bats for iobats. If XBSEN isn't present, they
will be "downsized" into multiple 256MB bats. Tested by riz.
 1.63 15-Feb-2012  macallan branches: 1.63.2;
fix crash during early startup - we can't call OpenFirmware between zapping
the BATs and complete setting them up again
ok releng
 1.62 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.61 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.60 17-Jul-2011  joerg branches: 1.60.2; 1.60.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.59 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.58 20-Jun-2011  matt Cleanup includes. (<net/netisr.h> is handled by softints, not MD anymore,
so this can be nuked).
 1.57 18-Jun-2011  matt Call cpu_fixup_stubs at the end of oea_machdep
 1.56 18-Jan-2011  matt branches: 1.56.4;
Fix some fallout from building the macppc GENERIC.MP.
 1.55 18-Jan-2011  matt 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.54 14-Jan-2011  rmind branches: 1.54.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.53 25-Feb-2010  matt branches: 1.53.2;
Adapt to spr.h breakup.
 1.52 08-Feb-2010  joerg Remove separate mb_map. The nmbclusters is computed at boot time based
on the amount of physical memory and limited by NMBCLUSTERS if present.
Architectures without direct mapping also limit it based on the kmem_map
size, which is used as backing store. On i386 and ARM, the maximum KVA
used for mbuf clusters is limited to 64MB by default.

The old default limits and limits based on GATEWAY have been removed.
key_registered_sb_max is hard-wired to a value derived from 2048
clusters.
 1.51 27-Nov-2009  rmind branches: 1.51.2;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.50 26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.49 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.48 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.47 07-Jun-2009  phx MSGBUFADDR creates a msgbuf at a fixed address, usually defined by the port's
config file.
The use of MSGBUGADDR was already prepared in powerpc/oea/pmap.c years ago,
but was never used and missing powerpc/oea/oea_machdep.c. The option will
be used by port amigappc.
 1.46 02-Jul-2008  ad branches: 1.46.18;
Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@.
 1.45 24-May-2008  phx branches: 1.45.2;
Make oea_init() support systems with high-vector configurations (i.e exception
vectors at 0xfff00000), and trap_subr.S allows the kernel to be in a memory
region which is not reachable by absolute branch instructions (ba and bla).

High-vector support can be enabled by option PPC_HIGH_VEC, and long-branches
to the kernel are enabled by the option DISTANT_KERNEL.
 1.44 14-Feb-2008  garbled branches: 1.44.6; 1.44.8; 1.44.10; 1.44.12;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.43 07-Feb-2008  garbled Code to disable BAT use on cpu's that either don't have BAT's, or don't
gain any benefit from them. This nets a small speedup on the POWER3, and
is probably needed for POWER5, which might not emulate BATs like the 3 does.
Also, thanks to Matt Thomas, who suggested re-using alitrap rather than
writing a new dsinobattrap that would have looked remarkably identical
when finished.
 1.42 07-Feb-2008  matt Cleanup a few 601 ifdefs.
 1.41 06-Feb-2008  garbled Some minor cleanup in the PPC_OEA601 code, and a fix for bridge-mode
cpus, which apparently still need the non-601 code to zap various
instructions into nops.
 1.40 05-Feb-2008  garbled Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.39 28-Jan-2008  garbled Apparently BRIDGE mode allows BAT registers, so re-enable that code.
Change the pegasos PCI_NETBSD_CONFIGURE arguments around to wire up mem
space into the correct area, and move the io regs a little to make it
work properly. Just avoid the secondary PCI entirely.
Change the list of things that we fiddle with in pci_conf_hook. Map mem
on the fwohci, avoid display cards, avoid IO on the auvia.
Change some printf's to aprint_*
Yank a call to genppc_pci_indirect_make_tag and change it to the
bus-independant pci call instead. (in pci_conf_hook)
 1.38 09-Jan-2008  garbled Make this compile when compiling in bridge mode w/o ALTIVEC
 1.37 03-Dec-2007  ad branches: 1.37.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.36 17-Oct-2007  garbled branches: 1.36.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.35 14-Jul-2007  ad branches: 1.35.8; 1.35.10; 1.35.12; 1.35.14;
Generic soft interrupts are mandatory.
 1.34 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.33 04-Mar-2007  macallan branches: 1.33.2; 1.33.4; 1.33.10;
make this compile again
 1.32 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.31 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.30 09-Feb-2007  ad branches: 1.30.2;
Merge newlock2 to head.
 1.29 18-Sep-2006  sanjayl Remove debug printf
 1.28 31-Aug-2006  freza branches: 1.28.2; 1.28.4;
* move the "cheating" conditional into unmapiodev() implementation
itself (instead of memio_unmap()), as it differs between OEA and
ibm4xx.

OK by matt@
 1.27 31-Aug-2006  matt Add unmapiodev(vaddr_t, vsize_t) (to be used by bus_space_unmap)
 1.26 05-Aug-2006  sanjayl 1st cut of Powermac G5 support (uses bridge mode).
 1.25 04-Jun-2006  mrg undef memset before calling it with a destination address of 0.
GCC4.1 complains about this when using the builtin, so force
this to call the real function normally.
 1.24 24-Dec-2005  perry branches: 1.24.4; 1.24.6; 1.24.8; 1.24.14;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 02-Jun-2005  he branches: 1.22.2;
Fix variable shadowing warnings by renaming the innermost variables.
 1.21 25-Apr-2005  lukem Move the MI printing of `copyright' to the MD cpu_startup() code
where the printing of `version' is already performed.
This has the benefit of allowing the copyright to be available
via dmesg(8) on platforms which need the `msgbuf' to be setup
in cpu_startup() before printed output is remembered.
 1.20 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.19 26-Jun-2004  kleink branches: 1.19.4; 1.19.6;
On OEA, turn PSL_USER* into runtime values appropriate for the CPU model
we're executing on; besides dealing with the bits not implemented in the
601's MSR it also removes the silent failure behaviour when passing
PSL_VEC set on a CPU not implementing it.

Also, fix those masks for the 4xx again.
 1.18 23-Jun-2004  kleink On MPC601s, rewrite any (unimplemented) tlbsync instruction as a sync.
 1.17 09-Jun-2004  kleink Get rid of the silly CPU601 hooks and move BAT register restoration and
obliteration to RESTORE_{KERN,USER}_SRS, respectively; have oea_init()
patch these sequences to be skipped on non-MPC601s. The code sequence
matching heuristic isn't as pretty as the one for VRSAVE and MQ but works
well enough with the current structure of the trap code, and can be easily
updated when necessary.
 1.16 01-Apr-2004  matt Remove softintr__init call.
 1.15 24-Mar-2004  matt branches: 1.15.2;
Add latent generic soft interrupt initialization.
 1.14 31-Jan-2004  uebayasi Typo typo.
 1.13 30-Dec-2003  pk Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

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

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
 1.12 21-Nov-2003  matt Restore ci_curpm since it re-enables 603 to working state.
 1.11 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.10 08-Aug-2003  matt Nuke ci_spillstk/CI_SPILLSTK. No longer needed.
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 02-Apr-2003  thorpej branches: 1.8.2;
Use PAGE_SIZE rather than NBPG.
 1.7 29-Mar-2003  matt Allow oea_batinit to be called with either the MMU on or off.
(don't reset the BATs if the MMU is off).
 1.6 15-Mar-2003  matt Add LINTSTUBs and make oea_init() agree with them.
 1.5 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.4 08-Feb-2003  matt Don't try to reserve DEAD zone unless the kernel address space encompasses it.
 1.3 06-Feb-2003  matt Add oea_iobat_remove(paddr_t).
 1.2 05-Feb-2003  matt Make things a bit more LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.8.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.4 01-Apr-2005  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 01-Apr-2004  jmc Pullup rev 1.16 (requested by matt in ticket #44)

Move to softintr__init to cpu_startup and remove softintr__init call for oea.
 1.19.6.1 28-Jan-2005  yamt convert arch/powerpc to new apis.
 1.19.4.1 29-Apr-2005  kent sync with -current
 1.22.2.10 27-Feb-2008  yamt sync with head.
 1.22.2.9 11-Feb-2008  yamt sync with head.
 1.22.2.8 04-Feb-2008  yamt sync with head.
 1.22.2.7 21-Jan-2008  yamt sync with head
 1.22.2.6 07-Dec-2007  yamt sync with head
 1.22.2.5 27-Oct-2007  yamt sync with head.
 1.22.2.4 03-Sep-2007  yamt sync with head.
 1.22.2.3 26-Feb-2007  yamt sync with head.
 1.22.2.2 30-Dec-2006  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.24.14.1 19-Jun-2006  chap Sync with head.
 1.24.8.3 03-Sep-2006  yamt sync with head.
 1.24.8.2 11-Aug-2006  yamt sync with head
 1.24.8.1 26-Jun-2006  yamt sync with head.
 1.24.6.1 07-Jun-2006  kardel Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.28.4.1 22-Oct-2006  yamt sync with head
 1.28.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.28.2.1 18-Nov-2006  ad Sync with head.
 1.30.2.3 03-Apr-2007  matt Install a "call to 0" panic routine rather than falling through to trap.
 1.30.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.30.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.33.10.5 17-Oct-2007  garbled Back out most of the PIC rennovation on ev64260, it was not completed,
and can be completed post-merge. With these changes, ev64260 compiles
again on the branch. Untested.
 1.33.10.4 03-Oct-2007  garbled Sync with HEAD
 1.33.10.3 02-Aug-2007  macallan sync with HEAD
 1.33.10.2 22-May-2007  matt Update to HEAD.
 1.33.10.1 10-May-2007  garbled HAVE_GENERIC_SOFTINTRS is no longer optional. Delete ifndef'd code from
oea_machdep.c, and move softintr__init() to oea_startup(). Remove
softintr__init from every port's cpu_startup().
 1.33.4.1 11-Jul-2007  mjf Sync with head.
 1.33.2.4 03-Dec-2007  ad Sync with HEAD.
 1.33.2.3 23-Oct-2007  ad Sync with head.
 1.33.2.2 15-Jul-2007  ad Sync with head.
 1.33.2.1 27-May-2007  ad Sync with head.
 1.35.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.35.12.1 18-Oct-2007  yamt sync with head.
 1.35.10.3 23-Mar-2008  matt sync with HEAD
 1.35.10.2 09-Jan-2008  matt sync with HEAD
 1.35.10.1 06-Nov-2007  matt sync with HEAD
 1.35.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.35.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.36.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.37.6.1 10-Jan-2008  bouyer Sync with HEAD
 1.44.12.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.44.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.44.12.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.44.10.3 11-Mar-2010  yamt sync with head
 1.44.10.2 20-Jun-2009  yamt sync with head
 1.44.10.1 04-May-2009  yamt sync with head.
 1.44.8.1 04-Jun-2008  yamt sync with head
 1.44.6.2 02-Jul-2008  mjf Sync with HEAD.
 1.44.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.45.2.1 03-Jul-2008  simonb Sync with head.
 1.46.18.4 28-Jan-2011  matt If a CPU has HIGHBAT, then use them. We dynamically change dsitrap to
select between bats 4-7 when HIGHBAT is detected.
 1.46.18.3 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.46.18.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.46.18.1 07-Jan-2011  matt Deal with new powerpc world.
 1.51.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.53.2.1 05-Mar-2011  rmind sync with head
 1.54.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.56.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.60.6.1 18-Feb-2012  mrg merge to -current.
 1.60.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.60.2.1 17-Apr-2012  yamt sync with head
 1.63.2.4 18-May-2016  martin Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.29-1.30
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
(via patch)

Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.63.2.3 19-Nov-2015  bouyer Revert ticket 1310 (second try):
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.63.2.2 16-Nov-2015  bouyer Revert ticket 1310:
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.63.2.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.30
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revision 1.29
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/oea/altivec.c: revision 1.30
Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Don't reload if just re-enabling
Don't reload the FPU register if this is just a re-enable.
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.64.4.2 18-May-2014  rmind sync with head
 1.64.4.1 28-Aug-2013  rmind sync with head
 1.64.2.2 03-Dec-2017  jdolecek update from HEAD
 1.64.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.6.2 09-Jul-2016  skrll Sync with HEAD
 1.71.6.1 22-Sep-2015  skrll Sync with HEAD
 1.71.4.1 17-Jul-2015  snj Pull up following revision(s) (requested by matt in ticket #868):
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revisions 1.29, 1.30
sys/arch/powerpc/oea/altivec.c: revision 1.30
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
Add a check to make sure that if PSL_FP is set, we own the FPU.
--
Don't clear PSL_FP/PSL_VEC
--
Don't reload if just re-enabling
--
Don't reload the FPU register if this is just a re-enable.
--
Remove PSL_SPV from BOOKE PSL_USERMOD
--
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.74.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.74.4.1 10-Jun-2019  christos Sync with HEAD
 1.74.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.81.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.84.4.1 03-Feb-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #561):

etc/etc.evbppc/Makefile.inc: revision 1.15
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.2
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.3
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.2
distrib/utils/embedded/files/evbppc_wii_icon.png: revision 1.1
usr.sbin/sysinst/arch/evbppc/md.h: revision 1.4
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.4
sys/arch/evbppc/wii/dev/viio.h: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.5
sys/arch/evbppc/wii/dev/mainbus.h: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.2
distrib/utils/embedded/conf/wii.conf: revision 1.3
sys/dev/sdmmc/sdhcvar.h: revision 1.34
sys/dev/sdmmc/sdhc.c: revision 1.118
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.1
distrib/utils/embedded/conf/evbppc.conf: revision 1.1
sys/dev/wsfb/genfb.c: revision 1.91
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.2
sys/dev/wscons/wsconsio.h: revision 1.127
sys/arch/powerpc/oea/oea_machdep.c: revision 1.85
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.1
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.2
sys/arch/evbppc/conf/std.wii: revision 1.3
sys/arch/powerpc/oea/cpu_subr.c: revision 1.109
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.1
sys/dev/usb/usb.h: revision 1.124
sys/arch/evbppc/wii/machdep.c: revision 1.1
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.1
sys/arch/powerpc/include/oea/hid.h: revision 1.14
sys/arch/evbppc/wii/mainbus.c: revision 1.1
sys/arch/evbppc/wii/machdep.c: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.1
sys/arch/evbppc/wii/mainbus.c: revision 1.2
sys/arch/evbppc/wii/machdep.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.2
sys/arch/evbppc/wii/mainbus.c: revision 1.3
sys/arch/evbppc/wii/machdep.c: revision 1.4
sys/arch/evbppc/wii/dev/hwgpio.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.2
sys/arch/evbppc/wii/wii_locore.S: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.1
sys/arch/evbppc/wii/wii_locore.S: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.2
sys/arch/evbppc/wii/dev/exi.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.2
sys/arch/evbppc/conf/files.wii: revision 1.3
sys/arch/powerpc/powerpc/clock.c: revision 1.18
sys/arch/evbppc/include/wii.h: revision 1.3
sys/arch/evbppc/conf/files.wii: revision 1.4
sys/arch/evbppc/include/wii.h: revision 1.4
sys/arch/evbppc/wii/dev/exi.h: revision 1.1
sys/arch/evbppc/wii/dev/avenc.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.5
sys/arch/evbppc/include/wii.h: revision 1.6
sys/arch/evbppc/include/wii.h: revision 1.7
sys/arch/evbppc/wii/dev/avenc.h: revision 1.1
distrib/utils/embedded/mkimage: revision 1.79
sys/arch/evbppc/conf/WII: revision 1.1
sys/arch/evbppc/conf/INSTALL_WII: revision 1.1
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.1
sys/arch/evbppc/wii/dev/vireg.h: revision 1.1
sys/arch/evbppc/conf/WII: revision 1.2
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.2
sys/arch/evbppc/wii/dev/vireg.h: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.3
sys/arch/evbppc/conf/WII: revision 1.4
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.11
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.1
sys/dev/usb/ehcivar.h: revision 1.52
sys/arch/evbppc/wii/pic_pi.c: revision 1.1
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.2
etc/etc.evbppc/ttys: revision 1.8
sys/arch/evbppc/wii/dev/bwai.c: revision 1.1
sys/arch/evbppc/wii/dev/bwai.c: revision 1.2
sys/arch/evbppc/wii/dev/bwai.c: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.1
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.1
sys/arch/evbppc/wii/dev/bwai.h: revision 1.1
sys/arch/evbppc/wii/autoconf.c: revision 1.2
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.2

powerpc: oea: Fix prefetchable mappings
Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
powerpc: oea: Decode IBM750CL L2 cache information.
sdmmc: add support for optional delay after register write
wscons: Add HOLLYWOOD display and YUY2 pixel format types
wsfb: add support for optional "devcmap" property
A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.
ehci: add EHCIF_32BIT_ACCESS flag to force 32-bit MMIO
fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
powerpc: fix delay for large (> ~5sec) values
When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
usb: increase USB_PORT_RESET_RECOVERY from 10ms to 20ms
I changed this from 250ms to 10ms back in 2021 based on a similar FreeBSD
change, but it seems to be a bit too aggressive for some platforms.
evbppc: Add initial support for the Nintendo Wii
wii: support RB_POWERDOWN
build fix: use dd with count=1 for compat with NetBSD dd(1)
wii: Add NTSC 480p support.
In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.
wii: Add 128x48 icon to SD card image
wii: Fix a comment
wii: Add drivers for Broadway DSP and Audio interface.
0: [*] audio0 @ bwdsp0: Broadway DSP
playback: 16, 2ch, 48000Hz
record: unavailable
(P-) slinear_be 16/16, 2ch, { 48000 }
wii: Add screenblank support.
wii: Use screen dimming register for screen blanking.
wii: Add GPIO, I2C, and basic A/V encoder driver.
wii: Use A/V encoder volume controls instead of using a software filter.
wii: Simply DSP driver - no interrupt handler required.
wii: provide device names to intr_establish
wii$ intrctl list
interrupt id CPU0 device name(s)
pi irq 14 64769* hollywood0
hollywood irq 36 5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0
wii: Add support for passing boot options to the kernel.
wii: Add External interface bus and RTC support
wii: Remove objcopy after kernel build.
HBC will do the right thing.
Add wsvt25 entries (off by default) for ttyE0-ttyE3.
Add support for "PAL" (576i) mode on Wii.
 1.28 04-Oct-2025  thorpej No longer need to copy "local-mac-address" and "shared-pins" into
the properties dictionary; they can be queried from the device tree
directly now.
 1.27 21-Sep-2025  thorpej Give each PowerPC OFW platform its own device_register(), which calls
into the common ofw_device_register(). ofppc's is a simple wrapper.

macppc's, on the other hand, takes care of looking up environmental
sensor descriptive information in the OFW device tree and adds those
properties directly to the sensor device property dictionaries. This
single implementation will replace the duplicated code that's scattered
across multiple macppc i2c controller drivers.
 1.26 23-Sep-2023  andvar add ifdef NWSDISPLAY > 0 around rascons_* functions usage,
otherwise implementation is not available, which breaks macppc MAMBO config.

potentially better solution to provide empty implementation, comments welcome.
 1.25 14-Dec-2022  macallan if we have the ROM font, make it available to wsdisplay
needs testing on non-macppc
 1.24 27-Nov-2019  joerg Add a hack for qemu/macppc. OF_finddevice calls will crash depending on
the boot loader and kernel being used. This patch allows using
-prom-env qemu_boot_hack=y to disable the lookup.
 1.23 21-Nov-2018  scole branches: 1.23.4;
don't bother reading ofw properties for platinumfb
 1.22 17-Aug-2018  macallan parse G5 device paths
 1.21 04-Mar-2018  macallan branches: 1.21.2; 1.21.4;
detect if we netboot and set booted_device accordingly
 1.20 18-Feb-2014  macallan branches: 1.20.22;
when looking for SCSI disks in canonicalize_bootpath() also match 'disk@'
since that's what at least some Adaptec firmware uses
 1.19 12-May-2013  macallan branches: 1.19.2;
move console_node and console_instance to ofw_consinit.c where they're
actually used
 1.18 28-Apr-2013  macallan some macppc boxes have onboard devices where parts or the whole PCI interrupt
register is hardwired to zero - fix this up here
 1.17 29-Jul-2012  mlelstv branches: 1.17.2;
Do not call setroot() from MD code and from MI code, which has
unwanted sideeffects in the RB_ASKNAME case. This fixes PR/46732.

No longer wrap MD cpu_rootconf(), as hp300 port stores reboot information
as a side effect. Instead call MI rootconf() from MD code which makes
rootconf() now a wrapper to setroot().

Adjust several MD routines to set the global booted_device,booted_partition
variables instead of passing partial information to setroot().

Make cpu_rootconf(9) describe the calling order.
 1.16 24-May-2012  macallan copy properties for valkyriefb as well
 1.15 17-Jul-2011  joerg branches: 1.15.2; 1.15.6; 1.15.8;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.14 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.13 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.12 09-Jun-2010  kiyohara branches: 1.12.6;
Support MV64361 on PegasosII by gt(4).
+ Support gtpci@gt instead of pegasospci more smartly.
+ Support Gigabit Ethernet by mvgbe@gt.
 1.11 20-Jan-2010  macallan branches: 1.11.2; 1.11.4;
pass some OF properties as device properties for network devices
namely local-mac-address and shared-pins needed by gem
 1.10 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.9 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 25-Sep-2008  macallan branches: 1.8.2; 1.8.8;
recognize ATY,DDparent as display device so the rest of the code can find
the nodes for each individual display
 1.7 11-Jan-2008  mrg branches: 1.7.6; 1.7.10; 1.7.12; 1.7.16;
several changes to make boot device work for disks, at least
on my pegasos:

- don't chop off the 2nd part of the OFW address, it makes it
match pcib (ISA bridge - dev 12 fn 0) instead of viaide (dev 12
fn 1).
- now that it's available, provide an "addr2" that has the
second address present.
- for pci devices match against device and function, not just
function.
- remove the special case and actually broken check in the
"pciide" section, and use the now generic "addr2" and check
against the drive and channel number if provided.
- support "viaide" and "slide" in here, as well as "pciide".
(is there a good way to say "any ide adapter"?)
 1.6 09-Jan-2008  aymeric probe as console devices which have a "class-code" property corresponding to
PCI_CLASS_DISPLAY, and not just those which have a "display" device_type.
In the case where each head is a subnode of the graphics card, it's the heads
which have a "display" device_type.

Maybe only testing "class-code" would make sense if this property is defined
on any openfirmware based PowerPC platform.
 1.5 16-Dec-2007  phx branches: 1.5.2;
At least under certain (mis)configurations (e.g. on the "Pegasos" board)
the VT8231-IDE's native mode only works with irq 14/15, and cannot be
programmed to use a single native PCI irq alone. So we install an interrupt
handler for each channel, as in compatibility mode.
This behaviour has to be activated by the "use-compat-native-irq" property,
otherwise the driver works as before.
 1.4 26-Nov-2007  macallan branches: 1.4.2; 1.4.4; 1.4.8;
repeat after me: I will not test OF nodes for validity by checking for >0
since node numbers may well have 0x80000000 set
 1.3 26-Nov-2007  garbled Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.2 07-Nov-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.1 07-Nov-2007  garbled Create a new ofw_autoconf.c based almost entirely on the one from macppc.
 1.2.8.5 18-Feb-2008  mjf Sync with HEAD.
 1.2.8.4 27-Dec-2007  mjf Sync with HEAD.
 1.2.8.3 08-Dec-2007  mjf Sync with HEAD.
 1.2.8.2 19-Nov-2007  mjf Sync with HEAD.
 1.2.8.1 07-Nov-2007  mjf file ofw_autoconf.c was added on branch mjf-devfs on 2007-11-19 00:46:45 +0000
 1.2.6.4 21-Jan-2008  yamt sync with head
 1.2.6.3 07-Dec-2007  yamt sync with head
 1.2.6.2 15-Nov-2007  yamt sync with head.
 1.2.6.1 07-Nov-2007  yamt file ofw_autoconf.c was added on branch yamt-lazymbuf on 2007-11-15 11:43:17 +0000
 1.2.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.2.4.1 07-Nov-2007  bouyer file ofw_autoconf.c was added on branch bouyer-xenamd64 on 2007-11-13 15:59:07 +0000
 1.2.2.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2.2.2 11-Nov-2007  joerg Sync with HEAD.
 1.2.2.1 07-Nov-2007  joerg file ofw_autoconf.c was added on branch jmcneill-pm on 2007-11-11 16:46:50 +0000
 1.4.8.3 11-Jan-2008  bouyer Sync with HEAD
 1.4.8.2 10-Jan-2008  bouyer Sync with HEAD
 1.4.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.4.1 26-Dec-2007  ad Sync with head.
 1.4.2.2 03-Dec-2007  ad Sync with HEAD.
 1.4.2.1 26-Nov-2007  ad file ofw_autoconf.c was added on branch vmlocking on 2007-12-03 19:03:59 +0000
 1.5.2.3 23-Mar-2008  matt sync with HEAD
 1.5.2.2 09-Jan-2008  matt sync with HEAD
 1.5.2.1 16-Dec-2007  matt file ofw_autoconf.c was added on branch matt-armv6 on 2008-01-09 01:47:51 +0000
 1.7.16.1 19-Oct-2008  haad Sync with HEAD.
 1.7.12.1 10-Oct-2008  skrll Sync with HEAD.
 1.7.10.3 11-Aug-2010  yamt sync with head.
 1.7.10.2 11-Mar-2010  yamt sync with head
 1.7.10.1 04-May-2009  yamt sync with head.
 1.7.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.8.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.4.1 03-Jul-2010  rmind sync with head
 1.11.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.12.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15.8.1 08-Aug-2012  martin Pull up following revision(s) (requested by mlelstv in ticket #466):
sys/arch/amiga/amiga/autoconf.c: revision 1.113
sys/arch/rs6000/rs6000/autoconf.c: revision 1.4
sys/arch/emips/emips/autoconf.c: revision 1.6
sys/arch/sandpoint/sandpoint/autoconf.c: revision 1.27
sys/arch/evbmips/alchemy/autoconf.c: revision 1.18
sys/arch/sgimips/sgimips/autoconf.c: revision 1.43
sys/arch/atari/atari/autoconf.c: revision 1.63
sys/arch/powerpc/oea/ofw_autoconf.c: revision 1.17
sys/arch/mmeye/mmeye/autoconf.c: revision 1.9
distrib/sets/lists/comp/mi: revision 1.1771
sys/arch/mipsco/mipsco/autoconf.c: revision 1.25
sys/arch/iyonix/iyonix/autoconf.c: revision 1.14
sys/arch/hp300/hp300/autoconf.c: revision 1.100
sys/kern/init_main.c: revision 1.445
sys/arch/pmax/pmax/autoconf.c: revision 1.79
sys/arch/netwinder/netwinder/autoconf.c: revision 1.11
sys/arch/dreamcast/dreamcast/autoconf.c: revision 1.10
sys/arch/ibmnws/ibmnws/autoconf.c: revision 1.12
sys/arch/evbppc/ev64260/autoconf.c: revision 1.17
sys/arch/evbmips/gdium/autoconf.c: revision 1.5
sys/arch/algor/algor/autoconf.c: revision 1.21
share/man/man9/Makefile: revision 1.367
sys/arch/ews4800mips/ews4800mips/autoconf.c: revision 1.9
sys/arch/amigappc/amigappc/autoconf.c: revision 1.5
sys/arch/x86/x86/x86_autoconf.c: revision 1.65
sys/arch/acorn26/acorn26/autoconf.c: revision 1.9
sys/arch/mvmeppc/mvmeppc/autoconf.c: revision 1.13
sys/arch/vax/vax/autoconf.c: revision 1.94
sys/arch/usermode/dev/cpu.c: revision 1.72
sys/arch/evbppc/virtex/autoconf.c: revision 1.5
sys/arch/next68k/next68k/autoconf.c: revision 1.26
sys/arch/mac68k/mac68k/autoconf.c: revision 1.73
sys/arch/ia64/ia64/autoconf.c: revision 1.6
sys/arch/evbppc/obs405/obs405_autoconf.c: revision 1.6
share/man/man9/cpu_rootconf.9: revision 1.7
sys/arch/landisk/landisk/autoconf.c: revision 1.6
sys/arch/evbmips/malta/autoconf.c: revision 1.16
sys/arch/sun3/sun3/autoconf.c: revision 1.76
sys/arch/evbppc/explora/autoconf.c: revision 1.13
sys/arch/sun3/sun3/autoconf.c: revision 1.77
sys/arch/evbmips/loongson/autoconf.c: revision 1.3
sys/arch/evbmips/atheros/autoconf.c: revision 1.11
sys/arch/sparc64/sparc64/autoconf.c: revision 1.188
sys/arch/acorn32/acorn32/autoconf.c: revision 1.18
sys/arch/evbarm/evbarm/autoconf.c: revision 1.13
sys/arch/cobalt/cobalt/autoconf.c: revision 1.30
sys/arch/mvme68k/mvme68k/autoconf.c: revision 1.46
sys/arch/hp700/hp700/autoconf.c: revision 1.48
sys/arch/evbmips/adm5120/autoconf.c: revision 1.5
sys/arch/hpcmips/hpcmips/autoconf.c: revision 1.25
sys/arch/alpha/alpha/autoconf.c: revision 1.52
sys/arch/sparc/sparc/autoconf.c: revision 1.244
sys/arch/evbppc/pmppc/autoconf.c: revision 1.7
sys/arch/bebox/bebox/autoconf.c: revision 1.25
sys/arch/luna68k/luna68k/autoconf.c: revision 1.13
sys/arch/hpcarm/hpcarm/autoconf.c: revision 1.20
sys/arch/evbppc/walnut/autoconf.c: revision 1.21
sys/arch/cesfic/cesfic/autoconf.c: revision 1.26
sys/arch/cats/cats/autoconf.c: revision 1.17
sys/arch/x68k/x68k/autoconf.c: revision 1.67
sys/arch/news68k/news68k/autoconf.c: revision 1.21
sys/arch/arc/arc/autoconf.c: revision 1.34
sys/arch/evbsh3/evbsh3/autoconf.c: revision 1.11
sys/sys/conf.h: revision 1.143
sys/arch/evbmips/rasoc/autoconf.c: revision 1.3
sys/arch/hpcsh/hpcsh/autoconf.c: revision 1.26
sys/arch/sun68k/sun68k/autoconf.c: revision 1.29
sys/arch/evbmips/rmixl/autoconf.c: revision 1.6
sys/arch/zaurus/zaurus/autoconf.c: revision 1.12
sys/arch/xen/x86/autoconf.c: revision 1.15
sys/arch/evbppc/mpc85xx/autoconf.c: revision 1.6
sys/arch/shark/shark/autoconf.c: revision 1.18
sys/arch/prep/prep/autoconf.c: revision 1.25
sys/arch/newsmips/newsmips/autoconf.c: revision 1.36
sys/arch/sbmips/sbmips/autoconf.c: revision 1.8
Do not call setroot() from MD code and from MI code, which has
unwanted sideeffects in the RB_ASKNAME case. This fixes PR/46732.
No longer wrap MD cpu_rootconf(), as hp300 port stores reboot information
as a side effect. Instead call MI rootconf() from MD code which makes
rootconf() now a wrapper to setroot().
Adjust several MD routines to set the global booted_device,booted_partition
variables instead of passing partial information to setroot().
Make cpu_rootconf(9) describe the calling order.
add rootconf(9) as a link to cpu_rootconf(9)
make this compile again
 1.15.6.1 02-Jun-2012  mrg sync to latest -current.
 1.15.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.15.2.1 30-Oct-2012  yamt sync with head
 1.17.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.2.1 23-Jun-2013  tls resync from head
 1.19.2.1 18-May-2014  rmind sync with head
 1.20.22.2 07-Dec-2019  martin Build fix for ticket #1465
 1.20.22.1 05-Dec-2019  bouyer Pull up following revision(s) (requested by joerg in ticket #1465):
sys/arch/powerpc/oea/ofw_autoconf.c: revision 1.24
Add a hack for qemu/macppc. OF_finddevice calls will crash depending on
the boot loader and kernel being used. This patch allows using
-prom-env qemu_boot_hack=y to disable the lookup.
 1.21.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.4.1 10-Jun-2019  christos Sync with HEAD
 1.21.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.21.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.23.4.1 08-Dec-2019  martin Pull up following revision(s) (requested by joerg in ticket #494):

sys/arch/powerpc/oea/ofw_autoconf.c: revision 1.24

Add a hack for qemu/macppc. OF_finddevice calls will crash depending on
the boot loader and kernel being used. This patch allows using
-prom-env qemu_boot_hack=y to disable the lookup.
 1.27 06-Dec-2022  macallan convert more seriously early output to ofprint
regular console output needs more of the kernel in working order now, and this
stuff happ0ens long before the banner
 1.26 24-Nov-2022  macallan move ofprint() to powerpc/ofw_machdep.c and make it official
now that console output uses locks it needs more of the kernel to function, so
for now use direct OF calls for earliest debug output
 1.25 13-Feb-2022  martin PR port-macppc/56091: on G5 macs we currently can not easily make
early serial console work, so keep the OF based "failsafe" console
but note that we would like to switch over.
Once zs attaches, use the new device mapping and do a belated init
of the zs console globals, and then switch over to real zs based
serial console.
 1.24 05-Mar-2021  thorpej Separate probing for the console device and initializing it, so that
ofwoea_initppc() can have more control over which of those steps are
performed during initialization. Probing happens before setting up
the exception vectors, initializing happens after.
 1.23 19-Feb-2021  thorpej Fix the previously differently.
 1.22 19-Feb-2021  thorpej Avoid an unused variable warning for the not-building-macppc case.
 1.21 19-Feb-2021  thorpej Revert unintended change.
 1.20 19-Feb-2021  thorpej Shuffle around a couple of things that aren't particularly OEA-specific:

- Early bootstrap console initialization moves to ofw_machdep.c, and
is called a bit earlier, from ofw_bootstrap().

- Decoding the "translations" property from /chosen/mmu is specified
in the general OpenFirmware PowerPC bindings, and is not specific to
any particular PowerPC flavor. It's now decoded a bit earlier in
ofw_bootstrap().

The *interpretation* of the mode field of a translation is, however,
implementation-specific, so that remains in ofwoea_machdep.c.
 1.19 06-Jul-2020  rin branches: 1.19.2;
Style and cosmetic changes. No binary changes intended.
 1.18 15-Apr-2020  rin When boot up with auto-boot? == true, some systems do not provide stdout
if the normal output is screen.

Open screen explicitly as stdout in this case, both for ofwboot and kernel,
which fixes problems with auto-boot? == true for Mac mini G4:

- messages from ofwboot do not appear
- kernel freeze during early boot stage

Taken from OpenBSD:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/macppc/ofw_machdep.c#rev1.3
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/stand/Locore.c#rev1.3

XXX
pullup to netbsd-9 and -8
 1.17 14-Feb-2016  dholland branches: 1.17.10; 1.17.18; 1.17.22; 1.17.28;
Add missing va_end, from David Binderman in PR 50798.
 1.16 12-May-2013  macallan branches: 1.16.10;
move console_node and console_instance to ofw_consinit.c where they're
actually used
 1.15 29-Oct-2012  chs fix compile problems (for POWERMAC_G5).
 1.14 13-Oct-2012  jdc Adapt to the changed signature of pckbc_cnattach().
 1.13 17-Jul-2011  joerg branches: 1.13.2; 1.13.12;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.12 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.11 14-Nov-2010  uebayasi prop/proplib.h is indirectly used here, include it.

XXX What is the conclusion about direct vs. indirect #include from headers?
 1.10 14-Mar-2010  kiyohara branches: 1.10.2;
Fix isa(4) support for ofw.
ofw not initialized bus_space for isa(4).
It tested on ofppc(PegasosII).
 1.9 10-Mar-2010  kiyohara Remove white-spaces.
 1.8 25-Sep-2008  macallan branches: 1.8.14;
If we have to guess wether the console keyboard is USB or ADB check if the
PMU actually has ADB support.
 1.7 28-Apr-2008  martin branches: 1.7.2; 1.7.6;
Remove clause 3 and 4 from TNF licenses
 1.6 26-Nov-2007  garbled branches: 1.6.14; 1.6.16; 1.6.18;
Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.5 10-Nov-2007  macallan unbork the initial console for macppc
ofb_cnattach() has nothing to do with ofb (anymore) - it's simply a dumb
rasops console we use until a real wsdisplay driver attaches, therefore
it needs to be #if NWSDISPLAY > 0, not NOFB > 0
Should probably be renamed to avoid future confusion.
 1.4 05-Nov-2007  garbled branches: 1.4.2; 1.4.4;
Lots of small changes for ofppc:

Remove the ofb driver. I'm not interested in trying to make this work.
It should be replaced with the genfb driver, which I have added,
commented out because that driver needs work before it will function on
ofppc. (it's too panic-happy, and ofppc needs a working autoconf.c)

Change the way we do isa_inb/outb. The new way is a slightly nastier
hack, but won't run afoul of the other isa drivers as much.

Fix ofw_consinit.c to remove the dependency on ofb.
 1.3 04-Nov-2007  garbled Get rid of the ofppc use of the ofbus completely, for the last time.

Write a complete OF boot console into ofw_consinit.c and rewire a bunch
of the ifdef logic in that file to use it when appropriate on both macppc
and ofppc. Get rid of the attempt to wire up the serial console early,
as that is extremely difficult on ofppc. Yank all the console code out
of ofppc/machdep.c. (This is a boot console only, not a full blown
console like ofcons.c)

Delete all the ofbus references out of the config files, and pull in
dev/ofw/openfirmio.c and dev/ofw/ofw_subr.c directly rather than pulling
in files.ofw. It might be worth going back and adding a files.ofw-nobus
to that directory to allow pulling in the openfirmware driver without
pulling in the whole ofbus mess.

Change rtas driver to connect directly to mainbus, like the PCI bus nodes do.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 06-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file ofw_consinit.c was initially added on branch ppcoea-renovation.
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.5 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.1.6.3 06-Nov-2007  joerg Sync with HEAD.
 1.1.6.2 04-Nov-2007  jmcneill Sync with HEAD.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.3 21-Jun-2007  garbled Protect the 16550 serial console code with a NISA > 0.
 1.1.2.2 14-Jun-2007  macallan add a missing return in ofwoea_bootstrap_console() - now we get past ofb
initialization and hang a little later
 1.1.2.1 06-Jun-2007  garbled Add new routines which should be common between macppc and ofppc. Not
used by either port yet.
 1.2.4.4 07-Dec-2007  yamt sync with head
 1.2.4.3 15-Nov-2007  yamt sync with head.
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file ofw_consinit.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:54 +0000
 1.2.2.4 03-Dec-2007  ad Sync with HEAD.
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file ofw_consinit.c was added on branch vmlocking on 2007-10-23 20:36:09 +0000
 1.4.4.3 09-Jan-2008  matt sync with HEAD
 1.4.4.2 06-Nov-2007  matt sync with HEAD
 1.4.4.1 05-Nov-2007  matt file ofw_consinit.c was added on branch matt-armv6 on 2007-11-06 23:20:45 +0000
 1.4.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.4.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.6.18.3 11-Aug-2010  yamt sync with head.
 1.6.18.2 04-May-2009  yamt sync with head.
 1.6.18.1 16-May-2008  yamt sync with head.
 1.6.16.1 18-May-2008  yamt sync with head.
 1.6.14.2 28-Sep-2008  mjf Sync with HEAD.
 1.6.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.6.1 19-Oct-2008  haad Sync with HEAD.
 1.7.2.1 10-Oct-2008  skrll Sync with HEAD.
 1.8.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.2.1 05-Mar-2011  rmind sync with head
 1.13.12.3 03-Dec-2017  jdolecek update from HEAD
 1.13.12.2 23-Jun-2013  tls resync from head
 1.13.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.13.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.13.2.1 30-Oct-2012  yamt sync with head
 1.16.10.1 19-Mar-2016  skrll Sync with HEAD
 1.17.28.1 20-Apr-2020  bouyer Sync with HEAD
 1.17.22.1 21-Apr-2020  martin Pull up following revision(s) (requested by rin in ticket #837):

sys/arch/macppc/stand/ofwboot/Locore.c: revision 1.34
sys/arch/powerpc/oea/ofw_consinit.c: revision 1.18

When boot up with auto-boot? == true, some systems do not provide stdout
if the normal output is screen.

Open screen explicitly as stdout in this case, both for ofwboot and kernel,
which fixes problems with auto-boot? == true for Mac mini G4:
- messages from ofwboot do not appear
- kernel freeze during early boot stage

Taken from OpenBSD:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/macppc/ofw_machdep.c#rev1.3
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/stand/Locore.c#rev1.3

XXX
pullup to netbsd-9 and -8
 1.17.18.1 21-Apr-2020  martin Sync with HEAD
 1.17.10.1 21-Apr-2020  martin Pull up following revision(s) (requested by rin in ticket #1533):

sys/arch/macppc/stand/ofwboot/Locore.c: revision 1.34 (via patch)
sys/arch/powerpc/oea/ofw_consinit.c: revision 1.18

When boot up with auto-boot? == true, some systems do not provide stdout
if the normal output is screen.

Open screen explicitly as stdout in this case, both for ofwboot and kernel,
which fixes problems with auto-boot? == true for Mac mini G4:
- messages from ofwboot do not appear
- kernel freeze during early boot stage

Taken from OpenBSD:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/macppc/ofw_machdep.c#rev1.3
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/stand/Locore.c#rev1.3

XXX
pullup to netbsd-9 and -8
 1.19.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.18 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.17 07-Jul-2020  rin rascons_init_rasops(): Initialize color palette only for macppc.
Fix build failure for ofppc.
 1.16 07-Jul-2020  rin It turned out that using some Open Firmware routines causes the system
freeze after calling OF_quiesce().

This is why setting color palette crash the system for some Power Mac G5
models, like PowerMac11,2.

Therefore, stop using color-palette and backlight callbacks for genfb(4)
in this case.

Also, postpone OF_quiesce() after rascons_init_rasops(), and initialize
color palette there if OF is going to be quiesced and color depth is 8.

Now, color palette for wscons is initialized correctly for PowerMac11,2.
 1.15 07-Jul-2020  rin Fix boot failure for PowerMac11,2 when ``auto-boot?'' is true.

For some machines like PowerMac11,2, Open Firmware does not correctly
initialize console-related variables, like font-adr and line#, when
``auto-boot?'' is true; -1 is returned instead of correct values.

Fall back to wsfont embedded in kernel in this case. Also, do not use
line# if it is negative.
 1.14 16-Mar-2020  macallan make the ROM font usable on G5s:
- copy the font data into a buffer instead of just pointing at the ROM
- don't blindly assume the font's width
- don't try to center output ourselves - rasops_init() will do it for us
- provide a hook to add the ROM font to wsfont when we're ready
 1.13 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.12 02-Mar-2018  macallan branches: 1.12.2; 1.12.4;
add a comment to explain why we defer wsdisplay_preattach() in bridge mode
 1.11 02-Mar-2018  macallan defer scribbling into video memory until after re-enabling the MMU if
we're in bridge mode.
With this NetBSD boots on PCI-X G5s
 1.10 23-Feb-2018  sevan Remove OFB_ENABLE_CACHE
from <macallan>
"it is outdated, genfb and friends don't need or use it, and it makes no sense
on accelerated drivers either. It tries to BAT-map the framebuffer cacheable,
which works on most macs but makes a few models lock up. Genfb doesn't have that
problem and is faster too."
 1.9 11-Apr-2013  macallan branches: 1.9.28;
for some reason we can't use the ROM font on G5, so disable it with
options OFWOEA_WSCONS_NO_ROM_FONT
from Phileas Fogg
 1.8 01-Feb-2012  matt branches: 1.8.6;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.7 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.6 01-Jul-2011  dyoung branches: 1.6.2; 1.6.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.5 06-May-2010  macallan set RI_NO_AUTO when initializing the early console - we're so early that
kmem_alloc() can't be used and we don't really need box drawing characters
for the OF font anyway
 1.4 10-Mar-2010  kiyohara branches: 1.4.2;
Remove white-spaces.
 1.3 18-Mar-2009  cegger branches: 1.3.2;
Ansify function definitions w/o arguments. Generated with sed.
 1.2 03-Mar-2008  phx branches: 1.2.4; 1.2.12; 1.2.18; 1.2.26;
Removed the check for device_type==display in rascons_cnattach(). It is not
required, because this function will be called for display-consoles only,
and it allows SmartFirmware to attach a rascons console.
Approved by garbled.
 1.1 26-Nov-2007  garbled branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.18; 1.1.20; 1.1.24;
Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.1.24.1 03-Apr-2008  mjf Sync with HEAD.
 1.1.20.1 24-Mar-2008  keiichi sync with head.
 1.1.18.3 23-Mar-2008  matt sync with HEAD
 1.1.18.2 09-Jan-2008  matt sync with HEAD
 1.1.18.1 26-Nov-2007  matt file ofw_rascons.c was added on branch matt-armv6 on 2008-01-09 01:47:52 +0000
 1.1.10.2 08-Dec-2007  mjf Sync with HEAD.
 1.1.10.1 26-Nov-2007  mjf file ofw_rascons.c was added on branch mjf-devfs on 2007-12-08 18:17:40 +0000
 1.1.8.3 17-Mar-2008  yamt sync with head.
 1.1.8.2 07-Dec-2007  yamt sync with head
 1.1.8.1 26-Nov-2007  yamt file ofw_rascons.c was added on branch yamt-lazymbuf on 2007-12-07 17:25:56 +0000
 1.1.4.2 03-Dec-2007  ad Sync with HEAD.
 1.1.4.1 26-Nov-2007  ad file ofw_rascons.c was added on branch vmlocking on 2007-12-03 19:04:01 +0000
 1.1.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.2.1 26-Nov-2007  joerg file ofw_rascons.c was added on branch jmcneill-pm on 2007-11-27 19:35:51 +0000
 1.2.26.1 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.2.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.2.4.2 11-Aug-2010  yamt sync with head.
 1.2.4.1 04-May-2009  yamt sync with head.
 1.3.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.2.1 30-May-2010  rmind sync with head
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.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.6.2.1 17-Apr-2012  yamt sync with head
 1.8.6.1 23-Jun-2013  tls resync from head
 1.9.28.1 26-Feb-2018  snj Pull up following revision(s) (requested by sevan in ticket #578):
sys/arch/macppc/conf/GENERIC: 1.341
sys/arch/macppc/conf/MAMBO: 1.28
sys/arch/macppc/conf/POWERMAC: 1.69
sys/arch/macppc/conf/POWERMAC_G5: 1.30
sys/arch/powerpc/oea/ofw_rascons.c: 1.10
Remove OFB_ENABLE_CACHE
from <macallan>
"it is outdated, genfb and friends don't need or use it, and it makes no
sense on accelerated drivers either. It tries to BAT-map the framebuffer
cacheable, which works on most macs but makes a few models lock up.
Genfb doesn't have that problem and is faster too."
 1.12.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12.4.1 10-Jun-2019  christos Sync with HEAD
 1.12.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.3 16-Mar-2020  macallan make the ROM font usable on G5s:
- copy the font data into a buffer instead of just pointing at the ROM
- don't blindly assume the font's width
- don't try to center output ourselves - rasops_init() will do it for us
- provide a hook to add the ROM font to wsfont when we're ready
 1.2 02-Mar-2018  macallan branches: 1.2.4;
defer scribbling into video memory until after re-enabling the MMU if
we're in bridge mode.
With this NetBSD boots on PCI-X G5s
 1.1 26-Nov-2007  garbled branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.18;
Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.1.18.2 09-Jan-2008  matt sync with HEAD
 1.1.18.1 26-Nov-2007  matt file ofw_rasconsvar.h was added on branch matt-armv6 on 2008-01-09 01:47:52 +0000
 1.1.10.2 08-Dec-2007  mjf Sync with HEAD.
 1.1.10.1 26-Nov-2007  mjf file ofw_rasconsvar.h was added on branch mjf-devfs on 2007-12-08 18:17:40 +0000
 1.1.8.2 07-Dec-2007  yamt sync with head
 1.1.8.1 26-Nov-2007  yamt file ofw_rasconsvar.h was added on branch yamt-lazymbuf on 2007-12-07 17:25:57 +0000
 1.1.4.2 03-Dec-2007  ad Sync with HEAD.
 1.1.4.1 26-Nov-2007  ad file ofw_rasconsvar.h was added on branch vmlocking on 2007-12-03 19:04:03 +0000
 1.1.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.2.1 26-Nov-2007  joerg file ofw_rasconsvar.h was added on branch jmcneill-pm on 2007-11-27 19:35:51 +0000
 1.2.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.20 28-Feb-2021  thorpej Minor re-ordering of a few things, and issue an isync barrier at all
critical MMU on/off transitions.
 1.19 24-Feb-2021  thorpej - Fix a comment.
- rename ofwsrsave to clsrsave; we're saving / restoring the client's
(i.e. kernel's) SRs there, not the firmware's.
 1.18 24-Feb-2021  thorpej Don't save the firmware's copy of SPRG[0-3], and don't fiddle with
SPRG[0-3] in the firmware trampoline. Section 7.1 of the OpenFirmware
PowerPC CPU bindings says that firmware "client interface shall not modify"
when in virtual-mode, and "client interface shall preserve" in real-mode.

This is important because in vritual-mode, DSI exceptions will land in
the kernel's DSI exception handler, and that handler depends on the
kernel's SPRG0 value (it contains the pointer to the cpu_info for that
CPU).

Additionally, in the firmware trampoline, point curcpu at an empty
ofw_battable. This ensures that the DSI exception handler won't
load a BAT register with a kernel block translation that clobbers
a segment translation owned by the firmware. Eventually, this ofw_battable
might contain some of the larger translations owned by the firmware.
 1.17 19-Feb-2021  thorpej ofwreal_incharge does not need to be global.
 1.16 19-Feb-2021  thorpej Put back accidental removal of "ofwreal_incharge".
 1.15 18-Feb-2021  thorpej Add an ofw_bootstrap() function, called during early bootstrap from
ofwinit() to perform additional early initialization in C code. Use
this to get the memory config while we're still running in the OpenFirmware
client environment, rather than waiting until we've started fiddling with
the system state.
 1.14 18-Feb-2021  thorpej - Tidy up some comments.
- Use correct stack frame linkage everywhere so that if something goes
wrong, we can get a meaningful back trace.
- Use an additional layer of indirection so that, when we're very
early in bootstrap, we can just call OpenFirmware directly, rather
than using our trampoline that saves/restores kernel state.
- Carve out a space for ofwinit() to call into C code to do additional
initialization. (This is not done yet.)
 1.13 13-Feb-2021  thorpej - Don't change to the OFW stack in C code; instead, switch to the OFW
stack in the openfirmware() wrapper itself. Inspired by a similar
change in OpenBSD designed to appease clang.
- The OF_*() entry firmware interfaces use several global resources;
protect those global resources with a __cpu_simple_lock_t.
- Make ofbcopy() static -- it's no longer referenced outside openfirm.c
 1.12 06-Jul-2020  rin branches: 1.12.2;
Include missing opt_ppcarch.h.
 1.11 15-Nov-2019  macallan bump OF_buf(fer) since we may put extra parameters in there
 1.10 27-Jul-2011  macallan branches: 1.10.54;
move clearing PSL_IP in ofwmsr back where it was - if we do it too early my
PowerBook 3400c hangs on startup.
 1.9 12-Jun-2011  matt Save/restore all sprgs when calling OFW.
Move all-zero variables from .data to .bss
Use .lcomm for local variables.
Cleanup a bit of assembly.
Clear PSL_IP in the saved ofmsr (was previously done in ofwoea_machdep.c)
 1.8 08-Apr-2008  garbled branches: 1.8.36;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.7 14-Feb-2008  garbled branches: 1.7.6;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.6 28-Jan-2008  garbled Pull another instance of bridge mode avoiding the BATs.
Fix FIRMWORKSBUGS. The #else on one of the ifdefs for it made it so that
it would never work on a machine that didn't need it. This caused IBM
machines to be unable to talk to OFW if the option was enabled. Replace
the #else with a branch and call it good.
 1.5 17-Oct-2007  garbled branches: 1.5.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.4 25-Jun-2007  aymeric branches: 1.4.10;
in the FIRMWORKSBUGS case, and if PSL_DR/PSL_IR are set, don't do the
job of saving and restoring registers twice: let ofwreal cope with everything.

This was the last bit needed to get a stock NetBSD/ofppc kernel booting
on the Efika. This will have to be adapted to the ppcoea-renovation branch.
 1.3 05-Aug-2006  sanjayl branches: 1.3.14; 1.3.16; 1.3.22;
1st cut of Powermac G5 support (uses bridge mode).
 1.2 13-Feb-2003  matt branches: 1.2.18; 1.2.32; 1.2.36;
Use register 8, not 0, when construct OF_buffer address.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.2.36.1 11-Aug-2006  yamt sync with head
 1.2.32.1 09-Sep-2006  rpaulo sync with head
 1.2.18.4 27-Feb-2008  yamt sync with head.
 1.2.18.3 04-Feb-2008  yamt sync with head.
 1.2.18.2 03-Sep-2007  yamt sync with head.
 1.2.18.1 30-Dec-2006  yamt sync with head.
 1.3.22.2 02-Aug-2007  macallan sync with HEAD
 1.3.22.1 26-Jun-2007  garbled Sync with HEAD.
 1.3.16.1 11-Jul-2007  mjf Sync with head.
 1.3.14.1 15-Jul-2007  ad Sync with head.
 1.4.10.2 23-Mar-2008  matt sync with HEAD
 1.4.10.1 06-Nov-2007  matt sync with HEAD
 1.5.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.36.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.64 28-May-2024  macallan - initialize bootpath
- if we don't get anything useful from args, check /chosen
now my G5 finds its boot device even when netbooting a kernel directly
 1.63 23-Sep-2023  andvar add ifdef NWSDISPLAY > 0 around rascons_* functions usage,
otherwise implementation is not available, which breaks macppc MAMBO config.

potentially better solution to provide empty implementation, comments welcome.
 1.62 05-Dec-2021  msaitoh s/preceed/preced/ in comment.
 1.61 02-Apr-2021  macallan clarify comment in previous
( this is a hack, should go away when the root cause is fixed etc. )
no functional change
 1.60 01-Apr-2021  macallan avoid mapping 0xfffff000 - my beige G3 DSIs on it
with this my the machine boots again
tested on a variety of G4 and G5 models with no problems
 1.59 05-Mar-2021  thorpej branches: 1.59.2;
Separate probing for the console device and initializing it, so that
ofwoea_initppc() can have more control over which of those steps are
performed during initialization. Probing happens before setting up
the exception vectors, initializing happens after.
 1.58 05-Mar-2021  thorpej Split set_timebase() into get_timebase_frequency() and init_decrementer().
Call get_timebase_frequency() much earlier.
 1.57 05-Mar-2021  thorpej Move ofppc-specific CPU spinup code to ofppc/machdep.c
 1.56 27-Feb-2021  thorpej Un-do a bunch of misguided code sharing. It's not really shared if it's
full of platform-specific #ifdefs:
- ofwoea_batinit() is gone; just do what's needed early in macppc / ofppc
initppc() functions.
- Get a bunch of Mac-specific stuff out of ofwoea_initppc().
 1.55 27-Feb-2021  thorpej In ofwoea_initppc(), call oea_init() after getting the bootpath, etc.
Also, add a comment explaining why it's actually necessary to clear
PSL_IP after installing the kernel's exception vectors.
 1.54 24-Feb-2021  thorpej Don't save the firmware's copy of SPRG[0-3], and don't fiddle with
SPRG[0-3] in the firmware trampoline. Section 7.1 of the OpenFirmware
PowerPC CPU bindings says that firmware "client interface shall not modify"
when in virtual-mode, and "client interface shall preserve" in real-mode.

This is important because in vritual-mode, DSI exceptions will land in
the kernel's DSI exception handler, and that handler depends on the
kernel's SPRG0 value (it contains the pointer to the cpu_info for that
CPU).

Additionally, in the firmware trampoline, point curcpu at an empty
ofw_battable. This ensures that the DSI exception handler won't
load a BAT register with a kernel block translation that clobbers
a segment translation owned by the firmware. Eventually, this ofw_battable
might contain some of the larger translations owned by the firmware.
 1.53 19-Feb-2021  thorpej Update some #ifdef PMAC_G5 for previous change that I missed before.
 1.52 19-Feb-2021  thorpej Shuffle around a couple of things that aren't particularly OEA-specific:

- Early bootstrap console initialization moves to ofw_machdep.c, and
is called a bit earlier, from ofw_bootstrap().

- Decoding the "translations" property from /chosen/mmu is specified
in the general OpenFirmware PowerPC bindings, and is not specific to
any particular PowerPC flavor. It's now decoded a bit earlier in
ofw_bootstrap().

The *interpretation* of the mode field of a translation is, however,
implementation-specific, so that remains in ofwoea_machdep.c.
 1.51 12-Feb-2021  thorpej Add some comments to help visually track the nested #ifdef blocks in
ofwoea_batinit().
 1.50 07-Jul-2020  rin branches: 1.50.2;
It turned out that using some Open Firmware routines causes the system
freeze after calling OF_quiesce().

This is why setting color palette crash the system for some Power Mac G5
models, like PowerMac11,2.

Therefore, stop using color-palette and backlight callbacks for genfb(4)
in this case.

Also, postpone OF_quiesce() after rascons_init_rasops(), and initialize
color palette there if OF is going to be quiesced and color depth is 8.

Now, color palette for wscons is initialized correctly for PowerMac11,2.
 1.49 06-Jul-2020  rin - Drop unused opt_compat_netbsd.h.
- Include missing opt_multiprocessor.h.
 1.48 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.47 28-Feb-2020  macallan do what FreeBSD does and OF_quiesce() only on PowerMac11,2 and 12,1
 1.46 28-Feb-2020  macallan switch PowerMac7,* CPUs to full speed via OF
if we do this later we hang
 1.45 15-Jul-2018  maxv branches: 1.45.6;
Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.44 03-Mar-2018  macallan branches: 1.44.2; 1.44.4;
get bootpath from OF if we don't get it as an argument
 1.43 02-Mar-2018  macallan defer scribbling into video memory until after re-enabling the MMU if
we're in bridge mode.
With this NetBSD boots on PCI-X G5s
 1.42 21-Jan-2018  mrg fix ofppc/pegasosII (and maybe others).

don't assume PPC_OEA64_BRIDGE means we have a 64 bit cpu (code
for 64 bit in bridge and normal 32 bit can co-exist due to
fixups the early boot code does has, and ofppc builds GENERIC
this way):
- fix mtmsr()/mfmsr() to use the right method based upon the
actually cpu booted on.
- fix cpu_setup() to have 32 bit and 64 bit hid0 variables
and operate on the right one based upon the current cpu.
restore a minor optimisation of not writing hid0 if it
didn't change.

in set_timebase() check if OF_finddevice("/cpus/@0") failed
and returned -1 before using it for OF_getprop().
 1.41 22-Sep-2017  macallan add quick path for timebase-frequency detection
deal with differences in /u4 reg property encoding vs. /uni-n, so this works
on my G5 now
 1.40 15-Sep-2017  macallan flesh out RANGE_TYPE_MACIO
 1.39 22-Dec-2016  cherry switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.38 25-Mar-2014  matt branches: 1.38.6; 1.38.10;
sprintf -> snprintf
 1.37 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.36 28-Feb-2014  matt Use uintptr_t instead of int.
 1.35 03-Nov-2013  mrg - remove set but unused variables
- move some variables inside their relevant use #ifdef
 1.34 31-Aug-2013  matt Move the pmap_setup to the start oea_init (no non-OFW ports can use it).
If PPC_OEA64_BRIDGE is defined, add code so that when OEACPU_64_BRIDGE is not
present, it replaces the rfid with rfi and mfmsr/rldicl/mtmsrd sequence
with NOPs. This allows plain OEA kernels to work. (tested on PMPPC with
PPC_OEA64_BRIDGE option added).
 1.33 13-May-2013  macallan branches: 1.33.2;
more G5 stuff:
- call OF_quiesce()
- properly map the message buffer
 1.32 11-Apr-2013  macallan make PPC_OEA64_BRIDGE mode work
from Phileas Fogg
 1.31 20-Oct-2012  kiyohara Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.30 17-Jul-2012  jmmv branches: 1.30.2;
OF_finddevice returns -1 on error, not an arbitrary negative number. Make
conditional explicit so that model_name gets a chance to be initialized when
the handle for the device is actually negative (which appears to be the case
in my Mac Mini G4).
 1.29 08-May-2012  macallan provide a BAT mapping for the PCI IO range on Grackle/Heathrow based macs
now drivers that need PCI IO access work again
 1.28 16-Feb-2012  matt Allow use of large (>256MB) bats for iobats. If XBSEN isn't present, they
will be "downsized" into multiple 256MB bats. Tested by riz.
 1.27 15-Feb-2012  macallan branches: 1.27.2;
fix crash during early startup - we can't call OpenFirmware between zapping
the BATs and complete setting them up again
ok releng
 1.26 04-Aug-2011  phx branches: 1.26.2; 1.26.6;
Drop into ddb, when requested by ofwboot (-d option).
 1.25 27-Jul-2011  macallan move clearing PSL_IP in ofwmsr back where it was - if we do it too early my
PowerBook 3400c hangs on startup.
 1.24 17-Jul-2011  dyoung Enable new-style <sys/bus.h> on several PowerPC ports supporting PCI
buses. Make non-inline implementations of bus_space(9) and bus_dma(9)
routines and move them to appropriate .c files.

This may leave amigappc in a bad state, sorry. Fortunately, it will be
easy to repair by imitating the bus.h -> bus_{defs,funcs}.h split in
some other PowerPC port.
 1.23 02-Jul-2011  matt Select pmap style before calling oea_init.
 1.22 20-Jun-2011  matt <arch/powerpc/... -> <powerpc/...
 1.21 12-Jun-2011  matt Save/restore all sprgs when calling OFW.
Move all-zero variables from .data to .bss
Use .lcomm for local variables.
Cleanup a bit of assembly.
Clear PSL_IP in the saved ofmsr (was previously done in ofwoea_machdep.c)
 1.20 14-Mar-2010  kiyohara branches: 1.20.8;
Fix isa(4) support for ofw.
ofw not initialized bus_space for isa(4).
It tested on ofppc(PegasosII).
 1.19 10-Mar-2010  kiyohara Remove white-spaces.
 1.18 17-Jan-2010  phx branches: 1.18.2;
Heed modeldata.ranges_offset while constructing the ranges bitmap.
 1.17 13-Feb-2009  apb Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.16 30-Nov-2008  martin branches: 1.16.4;
As discussed on tech-kern: mutex_init is too heavyweight for early bootstrap
phases, so move the initialization of the ksyms mutex back into main via
a function called ksyms_init. Rename the existing (but quite different)
ksyms_init* variations into ksyms_addsyms_elf() and ksyms_addsyms_explicit()
and adapt machdep code accordingly.
 1.15 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.14 28-Apr-2008  martin branches: 1.14.6; 1.14.8;
Remove clause 3 and 4 from TNF licenses
 1.13 08-Apr-2008  garbled branches: 1.13.2; 1.13.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.12 14-Feb-2008  garbled branches: 1.12.6;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.11 11-Feb-2008  garbled Use model_init to clean up how we decide the ranges for
PCI_NETBSD_CONFIGURE. Add some code to hopefully better handle the
firepower and powerstackII, based on the OFW dumps from those machines.
Untested on those machines, but doesn't break anything on pegasos/7044.
 1.10 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.9 28-Jan-2008  garbled Apparently BRIDGE mode allows BAT registers, so re-enable that code.
Change the pegasos PCI_NETBSD_CONFIGURE arguments around to wire up mem
space into the correct area, and move the io regs a little to make it
work properly. Just avoid the secondary PCI entirely.
Change the list of things that we fiddle with in pci_conf_hook. Map mem
on the fwohci, avoid display cards, avoid IO on the auvia.
Change some printf's to aprint_*
Yank a call to genppc_pci_indirect_make_tag and change it to the
bus-independant pci call instead. (in pci_conf_hook)
 1.8 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.7 09-Jan-2008  garbled ofwoea_batinit should be a nop when PPC_OEA is not defined
 1.6 26-Nov-2007  garbled branches: 1.6.6;
Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.5 14-Nov-2007  garbled Commit a fix for the _SR regions that are needed by ofppc. Because this
platform tends to just declare anything from 0x8 to 0xf as mem or io
regions willy-nilly, we need to avoid batmapping a few of those in order
to save space for USER_SR, KERNEL_SR and KERNEL2_SR. I picked values for
these three that are least-commonly used or used for non-vital things.
 1.4 26-Oct-2007  garbled branches: 1.4.2; 1.4.4; 1.4.6;
Fix the ranges_bitmap function so it correctly finds the various ranges
on OFW, and passes them on to ofwoea_batmap correctly. With this fix,
ofppc now properly initializes all of it's batmappings.

Kept the macppc specific override of the bitmap, but surrounded it with
an #ifdef macppc. It would probably be worth testing macppc without this
ifdef to see if it works there as well.
 1.3 25-Oct-2007  garbled Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.2 17-Oct-2007  garbled branches: 1.2.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 06-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file ofwoea_machdep.c was initially added on branch ppcoea-renovation.
 1.1.10.3 18-Nov-2007  bouyer Sync with HEAD
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.6.3 21-Nov-2007  joerg Sync with HEAD.
 1.1.6.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.7 24-Sep-2007  macallan shutup debug output if options OFWOEA_DEBUG isn't given
 1.1.2.6 15-Aug-2007  macallan add a config option to control the number of ranges we can bus_space_map()
per bus, also bump it from 8 to 20 so all PCI devices in my iBook work
again.
 1.1.2.5 18-Jun-2007  macallan call ksyms_init()
 1.1.2.4 18-Jun-2007  macallan forgot to XXX an evil hack
 1.1.2.3 18-Jun-2007  macallan make this work on macppc
caveats:
- ISA is likely borked
- the way we set PCI memory and IO ranges might be macppc-specific and
should probably go into the host bridge drivers
 1.1.2.2 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.1.2.1 06-Jun-2007  garbled Add new routines which should be common between macppc and ofppc. Not
used by either port yet.
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file ofwoea_machdep.c was added on branch vmlocking on 2007-10-23 20:36:10 +0000
 1.4.6.4 23-Mar-2008  matt sync with HEAD
 1.4.6.3 09-Jan-2008  matt sync with HEAD
 1.4.6.2 06-Nov-2007  matt sync with HEAD
 1.4.6.1 26-Oct-2007  matt file ofwoea_machdep.c was added on branch matt-armv6 on 2007-11-06 23:20:46 +0000
 1.4.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.4.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.4.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.4.2.8 27-Feb-2008  yamt sync with head.
 1.4.2.7 11-Feb-2008  yamt sync with head.
 1.4.2.6 04-Feb-2008  yamt sync with head.
 1.4.2.5 21-Jan-2008  yamt sync with head
 1.4.2.4 07-Dec-2007  yamt sync with head
 1.4.2.3 15-Nov-2007  yamt sync with head.
 1.4.2.2 27-Oct-2007  yamt sync with head.
 1.4.2.1 26-Oct-2007  yamt file ofwoea_machdep.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:54 +0000
 1.6.6.2 19-Jan-2008  bouyer Sync with HEAD
 1.6.6.1 10-Jan-2008  bouyer Sync with HEAD
 1.12.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.4 11-Aug-2010  yamt sync with head.
 1.13.4.3 11-Mar-2010  yamt sync with head
 1.13.4.2 04-May-2009  yamt sync with head.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.14.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.20.8.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.6.2 02-Jun-2012  mrg sync to latest -current.
 1.26.6.1 18-Feb-2012  mrg merge to -current.
 1.26.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.26.2.3 30-Oct-2012  yamt sync with head
 1.26.2.2 23-May-2012  yamt sync with head.
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.27.2.1 12-Jun-2012  riz Pull up following revision(s) (requested by macallan in ticket #321):
sys/arch/powerpc/oea/ofwoea_machdep.c: revision 1.29
provide a BAT mapping for the PCI IO range on Grackle/Heathrow based macs
now drivers that need PCI IO access work again
 1.30.2.4 03-Dec-2017  jdolecek update from HEAD
 1.30.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.2.2 23-Jun-2013  tls resync from head
 1.30.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.33.2.1 18-May-2014  rmind sync with head
 1.38.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.38.6.1 05-Feb-2017  skrll Sync with HEAD
 1.44.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.44.4.1 10-Jun-2019  christos Sync with HEAD
 1.44.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.45.6.1 29-Feb-2020  ad Sync with head.
 1.50.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.59.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.122 28-Feb-2025  andvar Fix various typos in comments.
 1.121 15-Dec-2023  rin branches: 1.121.2;
powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621
 1.120 15-Dec-2023  rin powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC

Part of PR kern/57621
 1.119 15-Dec-2023  rin powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool

(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.

(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.

(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.

Part of PR kern/57621
 1.118 15-Dec-2023  rin powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.

Part of PR kern/57621
 1.117 15-Dec-2023  rin powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC

Part of PR kern/57621
 1.116 08-Dec-2023  andvar fix triple s typos in comments.
 1.115 09-Oct-2023  rin powerpc/oea: pmap: Use pool_allocator_nointr() for pmap_pool

As done for (majority of) other pmap implementations.

pmap_pool_allocator() allocates memory below 256MB, but it is not
necessary for struct pmap.

Fix part of PR kern/57621, i.e., stall in pmap_create(9).

There should be another bugs that cause (MP?) kernel hangs
reported in the PR, in pmap or other MD components for powerpc
(PR port-powerpc/56922 should be one of the candidates).

XXX
pmap for powerpc/oea apparently needs some clean ups. But leave it
as is, and pull up this minimum fix to netbsd-10 at the moment.
 1.114 09-May-2022  rin branches: 1.114.4;
PR port-powerpc/56818

Fix inverted logic introduced in rev. 1.108, by which modified/referenced
bits of pages were never cleared appropriately.

Now, full ATF runs on macppc and sandpoint, with no regression observed.
 1.113 09-Apr-2022  riastradh sys: Use membar_release/acquire around reference drop.

This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.
 1.112 12-Mar-2022  riastradh sys: Membar audit around reference count releases.

If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

Thread A Thread B
obj->foo = 42; obj->baz = 73;
mumble(&obj->bar); grumble(&obj->quux);
/* membar_exit(); */ /* membar_exit(); */
atomic_dec -- not last atomic_dec -- last
/* membar_enter(); */
KASSERT(invariant(obj->foo,
obj->bar));
free_stuff(obj);

The memory barriers ensure that

obj->foo = 42;
mumble(&obj->bar);

in thread A happens before

KASSERT(invariant(obj->foo, obj->bar));
free_stuff(obj);

in thread B. Without them, this ordering is not guaranteed.

So in general it is necessary to do

membar_exit();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting. (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these. Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that. It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.
 1.111 18-Feb-2022  martin Backout previous and fix the correct macro magic
 1.110 18-Feb-2022  martin pmap_pv_protect is not STATIC
 1.109 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.108 16-Feb-2022  riastradh powerpc: Implement pv-tracking for unmanaged pages.

Needed for drm.
 1.107 19-Jul-2021  chs there is no need to keep pvos for unmanaged mappings on a hidden p/v list,
since "unmanaged" means that we don't want to find such pvos on any p/v list.
instead, just don't put such pvos on any p/v list at all and remove
the two hidden p/v lists for unmanaged mappings. code mostly from martin,
to implement rin's suggestion of unifying the two hidden lists.
 1.106 27-Jun-2021  martin PR 55325: unify both pvo pools (for managed and unmanaged pages).
Analyzis by rin, fix suggested by chs.
 1.105 12-Mar-2021  thorpej branches: 1.105.4;
Fix paste-o in last.
 1.104 12-Mar-2021  thorpej Re-factor the code in pmap_extract() that checks the 601 I/O segment
table and the BAT tables into separate functions that can be called
from outside of the pmap module.
 1.103 11-Mar-2021  thorpej Tidy up initialization of the kernel SRs just a bit.
 1.102 10-Mar-2021  thorpej - In pmap_bootstrap1(), make sure to initialize pmap_kernel()->pm_vsid
with the kernel's base VSID.
- In va_to_vsid(), always compute the VSID from the base VSID in the
pmap and the effective segment ID (ESID), rather than extracting it
from the pmap's segment register value for that ESID. Not only does
this make the code the same between OEA and OEA64, but is also lets
us compute the correct VSID for that pmap/ESID even if the cached SR
for that ESID currently contains something else, such as an I/O segment
mapping (as might be the case on a 601).

With this change, we can temporarily toggle between an I/O segment and
and HTAB-mapped segment if needed (e.g. when calling OpenFirmware on
a 601-based system).
 1.101 02-Mar-2021  thorpej Complete the pmap symbol renaming shenanigans for pmap_bootstrap[12]().
 1.100 02-Mar-2021  rin Apply PMAPNAME() to pmap_bootstrap[12](); fix build for ofppc, which has
both pmap32 and pmap64bridge in a single kernel.
 1.99 01-Mar-2021  thorpej Split pmap_bootstrap() into 2 functions:
- pmap_bootstrap1(), which sets up the low-level pmap data structures.
- pmap_bootstrap2(), which actually programs the MMU hardware based on
pmap_bootstrap1()'s work.

pmap_bootstrap() is still provided as a wrapper around the two, but this
provides flexibility to platforms that might need to do additional work
between these two phases.
 1.98 06-Jul-2020  rin branches: 1.98.2;
Style and cosmetic changes. No binary changes intended.
 1.97 02-Jul-2020  rin Fix typo; PMAP_OEA64_BRIDGE not PMAP_OEA_BRIDGE.
Tested on Power Mac G5.
 1.96 31-May-2020  rin Stop returning while PMAP_LOCK() (= KERNEL_LOCK(1, NULL)) is held.

Kernel freeze with heavy load is significantly mitigated (fixed?),
in which I could not even enter DDB from console.

XXX
There is still inconsistency in usage of two PVO pools.
I will send-pr later.

XXX
pullup to netbsd-[987]
 1.95 27-Jan-2018  chs branches: 1.95.8;
apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA:

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

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

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

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

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

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

KeK (http://www.kek.org.in) for hosting the primary developers.
 1.93 14-Feb-2016  dholland branches: 1.93.2;
Add missing va_end; PR 50795 from David Binderman.
 1.92 10-Aug-2014  joerg branches: 1.92.2; 1.92.4;
Update conditions on mfsrin definition to match use.
 1.91 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.90 03-Nov-2013  mrg gcc 4.8.1 wants:
- remove some set but unused variables
- move some variables inside their usage #ifdef's
- cast to (void) instead of using a dummy return variable

(there are more to come, but this one is now tested with gcc 4.5)
 1.89 11-Apr-2013  macallan branches: 1.89.4;
make PPC_OEA64_BRIDGE mode work
from Phileas Fogg
 1.88 28-Mar-2013  christos Fix loop bug (Phileas Fogg)
 1.87 20-Oct-2012  kiyohara Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.86 28-Jul-2012  matt branches: 1.86.2;
Fix -fno-common fallout.
 1.85 03-Feb-2012  matt Use CPP __VA_ARGS__ for DPRINTF*
 1.84 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.83 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.82 17-Jul-2011  joerg branches: 1.82.2; 1.82.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.81 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.80 19-Jun-2011  matt Use __builtin_clz instead of cntlzw
 1.79 02-May-2011  matt branches: 1.79.2;
A little PMAP_OEA64 pmap support.
 1.78 18-Feb-2011  matt Move powerpc_mmap_flags since pmap.c can get compiled multiple time resulting
in multiple defintions of powerpc_mmap_flags.
 1.77 15-Feb-2011  macallan implement pmap_mmap_flags() and teach PowerPC's bus_space_mmap() to actually
use BUS_SPACE_MAP_PREFETCHABLE which, now that /dev/pci* knows how to use it,
helps improve X performance
 1.76 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.75 18-Jan-2011  matt branches: 1.75.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.74 12-Nov-2010  uebayasi branches: 1.74.2;
Put VM_PAGE_TO_MD() definition in one place. No functional changes.
 1.73 10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.72 30-Oct-2010  uebayasi Use VM_PAGE_TO_MD() to locate struct vm_page_md. No functional
changes.
 1.71 25-Feb-2010  matt branches: 1.71.2;
Adapt to spr.h breakup.
 1.70 25-Feb-2010  skrll s/cpu_fork/cpu_lwp_fork/ in comment
 1.69 21-Nov-2009  rmind branches: 1.69.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.68 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.67 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.66 11-Aug-2009  matt Remove all declarations of physmem from sys/arch. Add an include of
<sys/systm.h> to the one file that did not already contain it.
This now means that physmem can be changed by updating systm.h and uvm_page.c
(excluding fixing printfs)
 1.65 21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.64 11-Dec-2008  pooka branches: 1.64.2;
Since oea pmap.c is #included many times, put kernel_pmap_ptr into
its own source module to avoid multiple initialized data definitions.
 1.63 10-Dec-2008  pooka Make kernel_pmap_ptr a const. Requested by steve_martin.
 1.62 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

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

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.61 29-Oct-2008  skrll branches: 1.61.12;
Typo in comment.
 1.60 05-May-2008  chs branches: 1.60.6; 1.60.8;
pmap_upvo_pool needs to use IPL_VM since it is used from
pmap_kenter_pa(), which can be called from interrupt context.
 1.59 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.58 08-Apr-2008  garbled branches: 1.58.2; 1.58.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.57 11-Mar-2008  matt on MP systems, whenever we change a PTE, make to sync the data cache so that
other processors can see the change.
 1.56 17-Feb-2008  phx branches: 1.56.2; 1.56.6;
Fixed compilation with DEBUG option for PMAP_OEA64_BRIDGE.
Approved by garbled.
 1.55 05-Feb-2008  garbled Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.54 05-Feb-2008  mlelstv fix and cleanup debug printf formats
 1.53 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.52 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.51 09-Jan-2008  garbled fix a bad cast when compiling in bridge mode
 1.50 02-Jan-2008  ad Merge vmlocking2 to head.
 1.49 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.48 12-Mar-2007  ad branches: 1.48.18; 1.48.24; 1.48.26; 1.48.30;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.47 04-Mar-2007  macallan branches: 1.47.2;
make this compile again
 1.46 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.45 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.44 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.43 30-Oct-2006  garbled branches: 1.43.4;
Make these files compile with -Wextra -Wno-unused.
 1.42 19-Sep-2006  matt When mapping the kernel, make to update its segment register to be valid.
 1.41 19-Sep-2006  matt At the end of pmap_bootstrap, if PMAP_NEED_MAPKERNEL, map the kernel into
the kernel's pmap (text will be rx, data will be rw).
 1.40 07-Sep-2006  sanjayl branches: 1.40.2; 1.40.4;
Remove debug printf that got left in accidentally
 1.39 02-Sep-2006  matt Add/rename macros (PVO_xxx_P) for testing WIRED, MANAGED, EXECUTABLE ness
of a PVO entry. (Fixes where PVO_WIRED was tested against pvo_pt.pte_lo
instead of pvo_vaddr)
 1.38 05-Aug-2006  sanjayl branches: 1.38.2;
1st cut of Powermac G5 support (uses bridge mode).
 1.37 13-May-2006  matt Fix a problem when an exec page is mapped, modified, and then unmapped.
Make sure to either clear the execness or sync the page to the icache.

This fixes gdb testsuite failures. Thanks for nathanw for testing.
 1.36 12-May-2006  nathanw Fix a typo in a comment.
 1.35 24-Dec-2005  perry branches: 1.35.4; 1.35.6; 1.35.8; 1.35.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.34 08-Dec-2005  yamt use VM_PAGE_TO_PHYS macro.
 1.33 27-Sep-2005  chs avoid calling into the pool code while PSL_EE is off.
the pool code can do spl*()/splx(), and splx() requires PSL_EE to be on.
 1.32 02-Jun-2005  he branches: 1.32.2;
Remove the hack to compile oea/pmap.c with -Wno-cast-qual, and instead
make use of the new __UNVOLATILE() macro in memset() usage.
 1.31 02-Jun-2005  he Fix variable shadowing warning.
 1.30 29-May-2005  chs in pmap_enter(), preset the ref bit for execute-only mappings too.
 1.29 22-Feb-2005  briggs branches: 1.29.2;
pmap_extract(): Only attempt to set '*pap' if pap is non-NULL.
PR port-powerpc/29507 from Neil Ludban.
 1.28 13-Feb-2005  chs move recursion-detection code inside interrupt-protected region. PR 24254.
 1.27 16-Jan-2005  chs branches: 1.27.2;
add some whitespace.
 1.26 24-Aug-2004  matt branches: 1.26.4;
Add pmap counters for reclaimed pvos and for the times a pvo could not be
obtained.
Switch to EVCNT_ATTACH_STATIC*
In DEBUG/DIAGNOSTIC, decrement/increment pmap_pvo_enter_depth around pool
calls since they could possibly cause a recursion back into pmap_pvo_enter.
 1.25 19-Aug-2004  chs implement pmap_pvo_reclaim(), which steals an existing non-wired pvo entry
for reuse, and use this in pmap_pvo_enter() when we can't allocate a new one.
 1.24 09-Jun-2004  kleink pmap_extract(): consider the MPC601's different battable layout, and its
use of I/O segments.
 1.23 21-Mar-2004  aymeric branches: 1.23.2;
pmap_pinit(): improve the hash function in the case of collisions, the
previous version would easily make the low order bits oscillate between 0
and some other value.

Together with the previous change, this should make those
pmap_pinit: out of segments
panics even less likely.

We should really attempt a systematic search before panic()ing at the end.
 1.22 21-Mar-2004  aymeric . don't call VSID_TO_HASH() on a pmap.pm_vsid. It already holds the hash value.
This should fix PR #24754, as well as many of the hangs and process
aborts reported on port-macppc@ in the last weeks.
This error would cause the pmap's vsid never to be freed, and would
occasionnally free a valid vsid used by another pmap, sometimes the kernel's.
. add a related KASSERT() to avoid regression
 1.21 17-Mar-2004  aymeric defparam PMAP_MEMLIMIT
 1.20 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.19 27-Dec-2003  mjl Add some casts to printf() args to make it compile w/ DEBUG set.
 1.18 21-Nov-2003  matt More PPC64 changes. (latent for now).
 1.17 21-Nov-2003  matt Restore ci_curpm since it re-enables 603 to working state.
 1.16 27-Oct-2003  kleink pmap_print_mmuregs(): move initialization of addr before its first use;
reported by David Young.
 1.15 27-Oct-2003  dyoung Stop false uninitialized variable warning.
 1.14 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.13 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.12 08-Aug-2003  matt Allow only user-mappings to be evicted (spillage). This prevents the
dreaded eviction of a kernel stack page.
 1.11 15-Jul-2003  lukem __KERNEL_RCSID()
 1.10 10-May-2003  thorpej branches: 1.10.2;
Back out the following chagne:
http://mail-index.netbsd.org/source-changes/2003/05/08/0068.html

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

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

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

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

This also eliminates use of VM_{MIN,MAX}_KERNEL_ADDRESS from MI code,
this giving MD code greater flexibility over the bounds of the managed
kernel virtual address space if a given port's specific platforms can
vary in this regard (this is especially true of the evb* ports).
 1.8 07-Apr-2003  matt Add a KASSERT to pmap_extract so that vtophys is never attempted on a
mapped user address.
 1.7 04-Apr-2003  matt If extracting an address from the kernel pmap, see if the address is outside
the mapped address range. If so, try to look it up via the BAT table. If
successful, translate and return the BAT'ed pa.
 1.6 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.5 17-Mar-2003  matt fix typo in comment.
 1.4 16-Mar-2003  matt Honor PMAP_NC for pmap_kenter_pa. Fix goof in pmap_pte_to_va.
 1.3 14-Mar-2003  matt Remove Debugger call.
 1.2 05-Feb-2003  matt Make things a bit more LP64 friendly.
 1.1 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.10.2.10 11-Dec-2005  christos Sync with head.
 1.10.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.7 15-Feb-2005  skrll Sync with HEAD.
 1.10.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.10.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.3 03-Sep-2004  skrll Sync with HEAD
 1.10.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.2.1 22-Aug-2004  tron branches: 1.23.2.1.2;
Pull up revision 1.25 (requested by chs in ticket #780):
implement pmap_pvo_reclaim(), which steals an existing non-wired pvo entry
for reuse, and use this in pmap_pvo_enter() when we can't allocate a new one.
 1.23.2.1.2.1 07-Aug-2005  riz Pull up revisions 1.23 and 1.29 (requested by briggs in ticket #1238):
Consider the MPC601's different battable layout and its use of
I/O segments.
Ensure that pap is non-NULL before use in pmap_extract(). Fixes PR#29507.
 1.26.4.1 29-Apr-2005  kent sync with -current
 1.27.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.2.1 21-Oct-2005  tron Pull up following revision(s) (requested by chs in ticket #897):
sys/arch/powerpc/oea/pmap.c: revision 1.33 via patch
avoid calling into the pool code while PSL_EE is off.
the pool code can do spl*()/splx(), and splx() requires PSL_EE to be on.
 1.32.2.8 17-Mar-2008  yamt sync with head.
 1.32.2.7 27-Feb-2008  yamt sync with head.
 1.32.2.6 11-Feb-2008  yamt sync with head.
 1.32.2.5 21-Jan-2008  yamt sync with head
 1.32.2.4 03-Sep-2007  yamt sync with head.
 1.32.2.3 26-Feb-2007  yamt sync with head.
 1.32.2.2 30-Dec-2006  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.35.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.35.8.4 14-Sep-2006  yamt sync with head.
 1.35.8.3 03-Sep-2006  yamt sync with head.
 1.35.8.2 11-Aug-2006  yamt sync with head
 1.35.8.1 24-May-2006  yamt sync with head.
 1.35.6.1 01-Jun-2006  kardel Sync with head.
 1.35.4.1 09-Sep-2006  rpaulo sync with head
 1.38.2.1 08-Sep-2006  rpaulo Pull up following revision(s) (requested by garbled in ticket #134):
sys/arch/powerpc/oea/pmap.c: revision 1.40
Remove debug printf that got left in accidentally
 1.40.4.2 10-Dec-2006  yamt sync with head.
 1.40.4.1 22-Oct-2006  yamt sync with head
 1.40.2.1 18-Nov-2006  ad Sync with head.
 1.43.4.3 24-Mar-2007  yamt sync with head.
 1.43.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.43.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.47.2.1 13-Mar-2007  ad Sync with head.
 1.48.30.3 19-Jan-2008  bouyer Sync with HEAD
 1.48.30.2 10-Jan-2008  bouyer Sync with HEAD
 1.48.30.1 02-Jan-2008  bouyer Sync with HEAD
 1.48.26.2 27-Dec-2007  ad locking changes for macppc. Please test.
 1.48.26.1 26-Dec-2007  ad Sync with head.
 1.48.24.1 18-Feb-2008  mjf Sync with HEAD.
 1.48.18.2 23-Mar-2008  matt sync with HEAD
 1.48.18.1 09-Jan-2008  matt sync with HEAD
 1.56.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.56.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.56.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.56.2.1 24-Mar-2008  keiichi sync with head.
 1.58.4.4 11-Mar-2010  yamt sync with head
 1.58.4.3 19-Aug-2009  yamt sync with head.
 1.58.4.2 04-May-2009  yamt sync with head.
 1.58.4.1 16-May-2008  yamt sync with head.
 1.58.2.1 18-May-2008  yamt sync with head.
 1.60.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.60.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.60.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.61.12.3 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.61.12.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.61.12.1 07-Jan-2011  matt Deal with new powerpc world.
 1.64.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.69.2.5 06-Nov-2010  uebayasi Sync with HEAD.
 1.69.2.4 30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.69.2.3 30-Apr-2010  uebayasi Sync with HEAD.
 1.69.2.2 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.69.2.1 26-Feb-2010  uebayasi Use VM_PAGE_TO_MD(). Only compile tested.
 1.71.2.2 31-May-2011  rmind sync with head
 1.71.2.1 05-Mar-2011  rmind sync with head
 1.74.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.75.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.75.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.79.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.82.6.1 18-Feb-2012  mrg merge to -current.
 1.82.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.82.2.2 30-Oct-2012  yamt sync with head
 1.82.2.1 17-Apr-2012  yamt sync with head
 1.86.2.4 03-Dec-2017  jdolecek update from HEAD
 1.86.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.86.2.2 23-Jun-2013  tls resync from head
 1.86.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.89.4.1 18-May-2014  rmind sync with head
 1.92.4.2 05-Feb-2017  skrll Sync with HEAD
 1.92.4.1 19-Mar-2016  skrll Sync with HEAD
 1.92.2.1 07-Jun-2020  martin Pull up following revision(s) (requested by rin in ticket #1732):

sys/arch/powerpc/oea/pmap.c: revision 1.96

Stop returning while PMAP_LOCK() (= KERNEL_LOCK(1, NULL)) is held.
Kernel freeze with heavy load is significantly mitigated (fixed?),
in which I could not even enter DDB from console.

XXX
There is still inconsistency in usage of two PVO pools.
I will send-pr later.

XXX
pullup to netbsd-[987]
 1.93.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.94.8.2 07-Jun-2020  martin Pull up following revision(s) (requested by rin in ticket #1554):

sys/arch/powerpc/oea/pmap.c: revision 1.96

Stop returning while PMAP_LOCK() (= KERNEL_LOCK(1, NULL)) is held.
Kernel freeze with heavy load is significantly mitigated (fixed?),
in which I could not even enter DDB from console.

XXX
There is still inconsistency in usage of two PVO pools.
I will send-pr later.

XXX
pullup to netbsd-[987]
 1.94.8.1 27-Feb-2018  martin Pull up following revision(s) (requested by mrg in ticket #593):
sys/dev/marvell/mvxpsec.c: revision 1.2
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.70
sys/opencrypto/crypto.c: revision 1.102
sys/arch/sparc64/sparc64/pmap.c: revision 1.308
sys/ufs/chfs/chfs_malloc.c: revision 1.5
sys/arch/powerpc/oea/pmap.c: revision 1.95
sys/sys/pool.h: revision 1.80,1.82
sys/kern/subr_pool.c: revision 1.209-1.216,1.219-1.220
sys/arch/alpha/alpha/pmap.c: revision 1.262
sys/kern/uipc_mbuf.c: revision 1.173
sys/uvm/uvm_fault.c: revision 1.202
sys/sys/mbuf.h: revision 1.172
sys/kern/subr_extent.c: revision 1.86
sys/arch/x86/x86/pmap.c: revision 1.266 (via patch)
sys/dev/dtv/dtv_scatter.c: revision 1.4

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

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

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

Define the new flag too for previous commit.

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

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

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

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

use PR_WAITOK everywhere.
use PR_NOWAIT.

Don't use 0 for PR_NOWAIT

use PR_NOWAIT instead of 0

panic ex nihilo -- PR_NOWAITing for zerot

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

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

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

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

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

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

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

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

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

This somewhat indirectly fixes PR 52706 on the remaining platforms where
this problem existed.
 1.95.8.1 07-Jun-2020  martin Pull up following revision(s) (requested by rin in ticket #938):

sys/arch/powerpc/oea/pmap.c: revision 1.96

Stop returning while PMAP_LOCK() (= KERNEL_LOCK(1, NULL)) is held.
Kernel freeze with heavy load is significantly mitigated (fixed?),
in which I could not even enter DDB from console.

XXX
There is still inconsistency in usage of two PVO pools.
I will send-pr later.

XXX
pullup to netbsd-[987]
 1.98.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.105.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.114.4.2 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.114.4.1 09-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/oea/pmap.c: revision 1.115

powerpc/oea: pmap: Use pool_allocator_nointr() for pmap_pool

As done for (majority of) other pmap implementations.
pmap_pool_allocator() allocates memory below 256MB, but it is not
necessary for struct pmap.

Fix part of PR kern/57621, i.e., stall in pmap_create(9).

There should be another bugs that cause (MP?) kernel hangs
reported in the PR, in pmap or other MD components for powerpc
(PR port-powerpc/56922 should be one of the candidates).
XXX

pmap for powerpc/oea apparently needs some clean ups. But leave it
as is, and pull up this minimum fix to netbsd-10 at the moment.
 1.121.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 05-Feb-2008  garbled branches: 1.1.2; 1.1.4; 1.1.12;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 05-Feb-2008  matt file pmap64.c was added on branch matt-armv6 on 2008-03-23 02:04:18 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 05-Feb-2008  mjf file pmap64.c was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.1.2.2 11-Feb-2008  yamt sync with head.
 1.1.2.1 05-Feb-2008  yamt file pmap64.c was added on branch yamt-lazymbuf on 2008-02-11 14:59:29 +0000
 1.1 05-Feb-2008  garbled branches: 1.1.2; 1.1.4; 1.1.12;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 05-Feb-2008  matt file pmap64_bridge.c was added on branch matt-armv6 on 2008-03-23 02:04:18 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 05-Feb-2008  mjf file pmap64_bridge.c was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.1.2.2 11-Feb-2008  yamt sync with head.
 1.1.2.1 05-Feb-2008  yamt file pmap64_bridge.c was added on branch yamt-lazymbuf on 2008-02-11 14:59:29 +0000
 1.14 15-Dec-2023  rin powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621
 1.13 16-Feb-2022  riastradh branches: 1.13.4;
powerpc: Implement pv-tracking for unmanaged pages.

Needed for drm.
 1.12 02-Mar-2021  thorpej Complete the pmap symbol renaming shenanigans for pmap_bootstrap[12]().
 1.11 06-Jul-2020  rin branches: 1.11.2;
Style and cosmetic changes. No binary changes intended.
 1.10 28-Jul-2012  matt Fix -fno-common fallout.
 1.9 30-Jun-2011  matt branches: 1.9.2;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.8 20-Jun-2011  matt Add #error for unknown PPC variant
Now that oea calls cpu_fixup_stubs, we don't need pmap_fixup_stubs.
 1.7 27-Feb-2011  rjs branches: 1.7.2;
Missing semicolon.
 1.6 26-Feb-2011  matt Can't pass a void.
 1.5 18-Feb-2011  matt Make sure stub routines are not profiled.
 1.4 18-Feb-2011  matt Move powerpc_mmap_flags since pmap.c can get compiled multiple time resulting
in multiple defintions of powerpc_mmap_flags.
 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 11-Dec-2008  pooka branches: 1.2.2; 1.2.4; 1.2.6; 1.2.10; 1.2.14; 1.2.16; 1.2.18;
rcs id police
 1.1 11-Dec-2008  pooka Since oea pmap.c is #included many times, put kernel_pmap_ptr into
its own source module to avoid multiple initialized data definitions.
 1.2.18.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.18.1 17-Feb-2011  bouyer Sync with HEAD
 1.2.16.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.14.1 05-Mar-2011  rmind sync with head
 1.2.10.2 04-May-2009  yamt sync with head.
 1.2.10.1 11-Dec-2008  yamt file pmap_kernel.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:44 +0000
 1.2.6.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.6.1 11-Dec-2008  skrll file pmap_kernel.c was added on branch nick-hppapmap on 2009-01-19 13:16:37 +0000
 1.2.4.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.4.1 11-Dec-2008  mjf file pmap_kernel.c was added on branch mjf-devfs2 on 2009-01-17 13:28:26 +0000
 1.2.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.2.1 11-Dec-2008  haad file pmap_kernel.c was added on branch haad-dm on 2008-12-13 01:13:24 +0000
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.2.1 30-Oct-2012  yamt sync with head
 1.11.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.13.4.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.13 27-Feb-2021  thorpej Don't put #ifdefs in prep_initppc(). Instead, let callers specify the
additional BAT-mapped regions they care about.
 1.12 06-Jul-2020  rin branches: 1.12.2;
Style and cosmetic changes. No binary changes intended.
 1.11 22-Dec-2016  cherry switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.10 11-Feb-2012  kiyohara branches: 1.10.6; 1.10.24; 1.10.28;
Fix panic() on KASSERT(len >= BAT_BL_8M) in oea_iobat_add(). Thanks phx@.
 1.9 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.8 07-Aug-2011  kiyohara branches: 1.8.2; 1.8.6;
Set BeBox Mainboard Registers space to BAT register.
 1.7 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.6 13-Feb-2009  apb Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.5 30-Nov-2008  martin branches: 1.5.4;
As discussed on tech-kern: mutex_init is too heavyweight for early bootstrap
phases, so move the initialization of the ksyms mutex back into main via
a function called ksyms_init. Rename the existing (but quite different)
ksyms_init* variations into ksyms_addsyms_elf() and ksyms_addsyms_explicit()
and adapt machdep code accordingly.
 1.4 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.3 28-Apr-2008  martin branches: 1.3.6; 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 09-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file prep_machdep.c was initially added on branch ppcoea-renovation.
 1.1.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.2 10-May-2007  garbled More cleanup. mvmeppc and ibmnws are machines that have a PReP memory
map. Rather than have each port roll it's own code, use
oea/prep_machdep.c instead.
 1.1.2.1 09-May-2007  garbled Add a prep_bus.h and prep_machdep.c. These files contain a number of
common routines that all machines with a PReP memory map should have in
common. Note that the machine does not need to be a fully PReP compliant
machine to use these functions, just use the memory map.
 1.2.26.2 04-May-2009  yamt sync with head.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file prep_machdep.c was added on branch matt-armv6 on 2007-11-06 23:20:47 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file prep_machdep.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:55 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file prep_machdep.c was added on branch vmlocking on 2007-10-23 20:36:11 +0000
 1.3.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.3.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.5.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.10.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.24.1 05-Feb-2017  skrll Sync with HEAD
 1.10.6.1 03-Dec-2017  jdolecek update from HEAD
 1.12.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 01-May-2007  garbled branches: 1.1.2;
file gen_pci_machdep.c was initially added on branch ppcoea-renovation.
 1.1.2.2 01-May-2007  garbled Per suggestion from Matt, rename these two files.
 1.1.2.1 01-May-2007  garbled Create a few generic functions and drivers for powerpc.
First, we have a generic pci_machdep.c, which is incomplete, but contains
a number of functions that are generally present in all powerpc
pci_machdep.c implementations.
Second, we have a generic implementation of indirect configuration space
read/write.
Lastly, a generic pchb driver for most of the ppc ports.
 1.1 01-May-2007  garbled branches: 1.1.2;
file gen_pciconf_indirect.c was initially added on branch ppcoea-renovation.
 1.1.2.2 01-May-2007  garbled Per suggestion from Matt, rename these two files.
 1.1.2.1 01-May-2007  garbled Create a few generic functions and drivers for powerpc.
First, we have a generic pci_machdep.c, which is incomplete, but contains
a number of functions that are generally present in all powerpc
pci_machdep.c implementations.
Second, we have a generic implementation of indirect configuration space
read/write.
Lastly, a generic pchb driver for most of the ppc ports.
 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 23-Jan-2012  phx Insert some missing aprint_naive().
 1.8 01-Jul-2011  dyoung branches: 1.8.2; 1.8.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.7 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.6 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.5 06-Jun-2011  matt More device_t, cfdata, CFATTACH_DECL_NEW cleanup.
 1.4 28-Apr-2008  martin branches: 1.4.22; 1.4.32;
Remove clause 3 and 4 from TNF licenses
 1.3 28-Jan-2008  garbled branches: 1.3.6; 1.3.8; 1.3.10;
Apparently BRIDGE mode allows BAT registers, so re-enable that code.
Change the pegasos PCI_NETBSD_CONFIGURE arguments around to wire up mem
space into the correct area, and move the io regs a little to make it
work properly. Just avoid the secondary PCI entirely.
Change the list of things that we fiddle with in pci_conf_hook. Map mem
on the fwohci, avoid display cards, avoid IO on the auvia.
Change some printf's to aprint_*
Yank a call to genppc_pci_indirect_make_tag and change it to the
bus-independant pci call instead. (in pci_conf_hook)
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 01-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pchb.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.3 21-May-2007  nisimura Fix a mis-placed closing brace to match PCI_PRODUCT().
 1.1.2.2 02-May-2007  macallan make this compile without PREP_BUS_SPACE_IO
 1.1.2.1 01-May-2007  garbled Create a few generic functions and drivers for powerpc.
First, we have a generic pci_machdep.c, which is incomplete, but contains
a number of functions that are generally present in all powerpc
pci_machdep.c implementations.
Second, we have a generic implementation of indirect configuration space
read/write.
Lastly, a generic pchb driver for most of the ppc ports.
 1.2.8.3 23-Mar-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pchb.c was added on branch matt-armv6 on 2007-11-06 23:20:47 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 04-Feb-2008  yamt sync with head.
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pchb.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:55 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pchb.c was added on branch vmlocking on 2007-10-23 20:36:12 +0000
 1.3.10.1 16-May-2008  yamt sync with head.
 1.3.8.1 18-May-2008  yamt sync with head.
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.22.1 12-Jun-2011  rmind sync with head
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.10.4.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.11.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.25 08-Dec-2021  andvar fix various typos in comments and log messages.
 1.24 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.23 02-Mar-2018  macallan IRQ0 is perfectly legal to use on at least some macppc, so don't treat it
as an error or something special
with this svwsata works on my PCI-X G5
 1.22 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.21 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.20 29-Mar-2014  christos branches: 1.20.6; 1.20.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.19 25-Mar-2014  matt sprintf -> snprintf
 1.18 28-Apr-2013  macallan branches: 1.18.4;
remove PMAC_G5 kludge - fixed this elsewhere
 1.17 11-Apr-2013  macallan temporary kludge for G5 - on mine some devices are configured with interrupt
pin 0 but a valid IRQ line, so don't treat that as an error if PMAC_G5 is set
 1.16 18-Jan-2013  matt Use structure initializers.
 1.15 01-Feb-2012  matt branches: 1.15.6;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.14 17-Aug-2011  matt branches: 1.14.2; 1.14.6;
First pass of the new PCI MSI/MSI ABI definitions. (return EOPNOTSUPP for
now).
 1.13 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.12 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.11 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.10 04-Apr-2011  dyoung branches: 1.10.2;
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.9 13-Dec-2010  matt branches: 1.9.2;
Change definition of pc_bus_maxdevs to get a void * instead a pci_chipset_tag_t
to match its use in pci_bus_maxdevs. This makes it the same as pci_conf_read
and pci_conf_write.
Change all struct device * to device_t.
[Obviously nothing ever used the first argument to pc_bus_maxdevs since it
could have never worked because it wasn't being passed a pci_chipset_tag_t.]
 1.8 28-Apr-2008  martin branches: 1.8.22; 1.8.26;
Remove clause 3 and 4 from TNF licenses
 1.7 17-Jan-2008  garbled branches: 1.7.6; 1.7.8; 1.7.10;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.6 25-Dec-2007  macallan get rid of macppc's private pci_bus_dma_tag
 1.5 24-Dec-2007  macallan check for __HAVE_PRIVATE_PCI_BUS_DMA_TAG instead of macppc when (not)
declaring pci_bus_dma_tag
while there move #include <machine/isa_machdep.h> to the ISA block so archs
without ISA won't see it. Now macppc builds again.
 1.4 20-Dec-2007  phx VT8231 IDE workaround for native mode with "compatibility" interrupts 14/15.
This time done right by calling pciide_machdep_compat_intr_establish() to
get a MD interrupt handler.
Verified that it compiles for XEN again.
 1.3 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 01-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pci_machdep_common.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.4 09-May-2007  garbled Convert pmppc to generic pci. Also fix the prototype for
pci_conf_interrupt while I'm here.
 1.1.2.3 06-May-2007  macallan switch macppc over to generic PCI code from arch/powerpc/pci
 1.1.2.2 01-May-2007  garbled Add a generic pci_intr_map() function (looks like macppc and ibmnws use this)
 1.1.2.1 01-May-2007  garbled Per suggestion from Matt, rename these two files.
 1.2.14.2 19-Jan-2008  bouyer Sync with HEAD
 1.2.14.1 02-Jan-2008  bouyer Sync with HEAD
 1.2.10.1 26-Dec-2007  ad Sync with head.
 1.2.8.4 23-Mar-2008  matt sync with HEAD
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pci_machdep_common.c was added on branch matt-armv6 on 2007-11-06 23:20:48 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pci_machdep_common.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:56 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pci_machdep_common.c was added on branch vmlocking on 2007-10-23 20:36:12 +0000
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.26.1 07-Jan-2011  matt Change bus_maxdevs to be passed pc->pc_conf_v instead pc (e.g. like the
rest of the conf calls).
 1.8.22.2 21-Apr-2011  rmind sync with head
 1.8.22.1 05-Mar-2011  rmind sync with head
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.6.1 18-Feb-2012  mrg merge to -current.
 1.14.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.14.2.2 23-Jan-2013  yamt sync with head
 1.14.2.1 17-Apr-2012  yamt sync with head
 1.15.6.3 03-Dec-2017  jdolecek update from HEAD
 1.15.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.6.1 25-Feb-2013  tls resync with head
 1.18.4.1 18-May-2014  rmind sync with head
 1.20.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.20.6.2 28-Aug-2017  skrll Sync with HEAD
 1.20.6.1 05-Dec-2016  skrll Sync with HEAD
 1.22 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.21 18-Oct-2014  snj branches: 1.21.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.20 25-Mar-2014  matt sprintf -> snprintf
 1.19 03-Nov-2013  mrg - remove set but unused variables
 1.18 01-Feb-2012  matt branches: 1.18.6; 1.18.10;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.17 22-Jun-2011  matt branches: 1.17.2; 1.17.6;
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.16 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.15 04-Apr-2011  dyoung branches: 1.15.2;
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.14 08-May-2010  kiyohara branches: 1.14.2;
Rename PCI_PRODUCT_MARVELL_MV64360 from PCI_PRODUCT_MARVELL_GT64360.
 1.13 19-Apr-2010  kiyohara Remove white-spaces.
 1.12 28-Apr-2008  martin branches: 1.12.20; 1.12.22;
Remove clause 3 and 4 from TNF licenses
 1.11 23-Feb-2008  phx branches: 1.11.2; 1.11.4;
On the Pegasos2, we must never run PCI-configure for the MV64361 host bridge,
otherwise the devices on that bus might no longer work correctly (e.g.
interrupt flood).
Approved by garbled.
 1.10 11-Feb-2008  garbled branches: 1.10.2; 1.10.6;
Use model_init to clean up how we decide the ranges for
PCI_NETBSD_CONFIGURE. Add some code to hopefully better handle the
firepower and powerstackII, based on the OFW dumps from those machines.
Untested on those machines, but doesn't break anything on pegasos/7044.
 1.9 28-Jan-2008  garbled Apparently BRIDGE mode allows BAT registers, so re-enable that code.
Change the pegasos PCI_NETBSD_CONFIGURE arguments around to wire up mem
space into the correct area, and move the io regs a little to make it
work properly. Just avoid the secondary PCI entirely.
Change the list of things that we fiddle with in pci_conf_hook. Map mem
on the fwohci, avoid display cards, avoid IO on the auvia.
Change some printf's to aprint_*
Yank a call to genppc_pci_indirect_make_tag and change it to the
bus-independant pci call instead. (in pci_conf_hook)
 1.8 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.7 11-Jan-2008  mrg enable PCI_NETBSD_CONFIGURE for ofppc.

the call to pci_configure_bus(9) and it's supporting code is
copied verbatim from the prep port.

this allows us to completely remove the really gross pegasos
specific pegasospci_indirect_attach_hook() that set various
pci command regs, since all those devices (mostly work now,
see below) and additionally PCI plugin cards work now too.

it also makes the pegasos onboard vr(4) ethernet work with
disk boot (it previously only worked with netboot.)

in the generic macppc ofw pci conf hook and for pegasos,
don't configure the viaide(4) device, and don't configure
memory space on the fwohci(4) device.


with this, and my other recent ofppc/ppc changes the pegasos
port is mostly functional. the marvell gige is not working,
and my 512mb appears as only about 256mb, but otherwise
this port is almost done!
 1.6 05-Nov-2007  garbled branches: 1.6.2; 1.6.4; 1.6.10;
Lots of small changes for ofppc:

Remove the ofb driver. I'm not interested in trying to make this work.
It should be replaced with the genfb driver, which I have added,
commented out because that driver needs work before it will function on
ofppc. (it's too panic-happy, and ofppc needs a working autoconf.c)

Change the way we do isa_inb/outb. The new way is a slightly nastier
hack, but won't run afoul of the other isa drivers as much.

Fix ofw_consinit.c to remove the dependency on ofb.
 1.5 04-Nov-2007  garbled Apply a patch from Frank Wille that fixes a stupid in the ofw interrupt map
discovery where the pin value was off by one.
 1.4 26-Oct-2007  garbled branches: 1.4.2;
Add code to properly detect the interrupt mapping on the PegasosII, and any
other OFW machine that fails our first two methods.
 1.3 25-Oct-2007  garbled Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.2 17-Oct-2007  garbled branches: 1.2.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 21-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pci_machdep_ofw.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.3 06-Nov-2007  joerg Sync with HEAD.
 1.1.6.2 04-Nov-2007  jmcneill Sync with HEAD.
 1.1.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.1.2.1 21-Jun-2007  garbled Add a bunch of common pci_machdep routines for OFW machines. Used only
by ofppc for now, eventually, macppc should make use of these.
 1.2.2.4 03-Dec-2007  ad Sync with HEAD.
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pci_machdep_ofw.c was added on branch vmlocking on 2007-10-23 20:36:13 +0000
 1.4.2.6 27-Feb-2008  yamt sync with head.
 1.4.2.5 04-Feb-2008  yamt sync with head.
 1.4.2.4 21-Jan-2008  yamt sync with head
 1.4.2.3 15-Nov-2007  yamt sync with head.
 1.4.2.2 27-Oct-2007  yamt sync with head.
 1.4.2.1 26-Oct-2007  yamt file pci_machdep_ofw.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:56 +0000
 1.6.10.2 19-Jan-2008  bouyer Sync with HEAD
 1.6.10.1 11-Jan-2008  bouyer Sync with HEAD
 1.6.4.3 23-Mar-2008  matt sync with HEAD
 1.6.4.2 06-Nov-2007  matt sync with HEAD
 1.6.4.1 05-Nov-2007  matt file pci_machdep_ofw.c was added on branch matt-armv6 on 2007-11-06 23:20:48 +0000
 1.6.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.10.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.2.1 24-Mar-2008  keiichi sync with head.
 1.11.4.2 11-Aug-2010  yamt sync with head.
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.22.2 21-Apr-2011  rmind sync with head
 1.12.22.1 30-May-2010  rmind sync with head
 1.12.20.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.12.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.14.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.6.1 18-Feb-2012  mrg merge to -current.
 1.17.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.17.2.1 17-Apr-2012  yamt sync with head
 1.18.10.1 18-May-2014  rmind sync with head
 1.18.6.2 03-Dec-2017  jdolecek update from HEAD
 1.18.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 28-Aug-2017  skrll Sync with HEAD
 1.2 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.1 22-Jun-2011  matt Provide the pci_* routines for modules to use.
 1.12 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "prep-raven-pchb".
 1.11 17-May-2022  andvar fix few typos in comments.
 1.10 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.9 24-Apr-2021  thorpej branches: 1.9.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.8 06-Jul-2020  rin branches: 1.8.4;
Style and cosmetic changes. No binary changes intended.
 1.7 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.6 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.5 04-May-2008  martin branches: 1.5.32;
Move to 2 clause TNF license
 1.4 04-Apr-2008  matt branches: 1.4.2; 1.4.4;
split device_t/softc. Use device_xname and device_private.
 1.3 17-Jan-2008  garbled branches: 1.3.6;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pcib.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.3 29-May-2007  nisimura - add missing 0x for a hexdigit constant.
 1.1.2.2 03-May-2007  garbled Forgot to commit this. Eliminate init_icu().
 1.1.2.1 02-May-2007  garbled Copy prep's pcib.c over to here as a shared version.
 1.2.14.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.8.3 23-Mar-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pcib.c was added on branch matt-armv6 on 2007-11-06 23:20:49 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pcib.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:57 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pcib.c was added on branch vmlocking on 2007-10-23 20:36:14 +0000
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.4.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.9.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 06-Jan-2021  rin Drop unused headers. No functional changes intended.
 1.6 02-Oct-2015  msaitoh branches: 1.6.30;
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.5 18-Jun-2011  matt branches: 1.5.12; 1.5.30;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 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.3 28-Apr-2008  martin branches: 1.3.32;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 01-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pciconf_indirect.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.3 08-May-2007  rjs Move declarations to header.
 1.1.2.2 06-May-2007  macallan switch macppc over to generic PCI code from arch/powerpc/pci
 1.1.2.1 01-May-2007  garbled Per suggestion from Matt, rename these two files.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pciconf_indirect.c was added on branch matt-armv6 on 2007-11-06 23:20:50 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pciconf_indirect.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:57 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pciconf_indirect.c was added on branch vmlocking on 2007-10-23 20:36:14 +0000
 1.3.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.30.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.12.1 03-Dec-2017  jdolecek update from HEAD
 1.6.30.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7 06-Jan-2021  rin Drop unused headers. No functional changes intended.
 1.6 06-Jul-2020  rin branches: 1.6.2;
Style and cosmetic changes. No binary changes intended.
 1.5 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.4 18-Jun-2011  matt branches: 1.4.12; 1.4.30;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 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 28-Apr-2008  martin branches: 1.2.32;
Remove clause 3 and 4 from TNF licenses
 1.1 25-Oct-2007  garbled branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.24; 1.1.26; 1.1.28;
Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.1.28.1 16-May-2008  yamt sync with head.
 1.1.26.1 18-May-2008  yamt sync with head.
 1.1.24.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.10.2 03-Dec-2007  ad Sync with HEAD.
 1.1.10.1 25-Oct-2007  ad file pciconf_ofmethod.c was added on branch vmlocking on 2007-12-03 19:04:04 +0000
 1.1.8.2 06-Nov-2007  matt sync with HEAD
 1.1.8.1 25-Oct-2007  matt file pciconf_ofmethod.c was added on branch matt-armv6 on 2007-11-06 23:20:51 +0000
 1.1.4.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.4.1 25-Oct-2007  joerg file pciconf_ofmethod.c was added on branch jmcneill-pm on 2007-10-28 20:10:47 +0000
 1.1.2.2 27-Oct-2007  yamt sync with head.
 1.1.2.1 25-Oct-2007  yamt file pciconf_ofmethod.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:57 +0000
 1.2.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.30.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.4.12.1 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.12;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 10-Oct-2007  garbled branches: 1.1.2;
file files.ipi was initially added on branch ppcoea-renovation.
 1.1.2.1 10-Oct-2007  garbled New ppcoea-MI IPI infrastructure. This is similar to the PIC
infrastructure, but simplified greatly.

Also, convert macppc (the only port currently using IPI's) over to this new
infrastructure. Still some minor work left to do here.
 1.2.12.2 06-Nov-2007  matt sync with HEAD
 1.2.12.1 17-Oct-2007  matt file files.ipi was added on branch matt-armv6 on 2007-11-06 23:20:51 +0000
 1.2.8.2 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.2.8.1 17-Oct-2007  joerg file files.ipi was added on branch jmcneill-pm on 2007-11-02 13:34:44 +0000
 1.2.6.2 27-Oct-2007  yamt sync with head.
 1.2.6.1 17-Oct-2007  yamt file files.ipi was added on branch yamt-lazymbuf on 2007-10-27 11:27:58 +0000
 1.2.4.2 23-Oct-2007  ad Sync with head.
 1.2.4.1 17-Oct-2007  ad file files.ipi was added on branch vmlocking on 2007-10-23 20:36:15 +0000
 1.2.2.2 18-Oct-2007  yamt sync with head.
 1.2.2.1 17-Oct-2007  yamt file files.ipi was added on branch yamt-x86pmap on 2007-10-18 08:32:44 +0000
 1.7 17-Jun-2011  matt intr.h must not include cpu due to deadly embrace with SOFTINT_COUNT.
Cleanup intr.h so MD definitions can overload common definitions.
Rototill pic/intr.c. Virtual IRQs can now be reclaimed. separate virq
from hwirq from picirq. Redo intr mask calculations.
tested on pmppc and macppc (MP).
 1.6 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 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 19-Aug-2009  nisimura branches: 1.4.4; 1.4.6; 1.4.10;
- Have pic_mpcsoc.c to adapt variations of Moto/Freescale OpenPIC
compliant interrupt controllers. Mostly the refrain of pic_openpic.c
and shall be useful for 85xx/86xx/QorIQ and Tundra product lines.
 1.3 17-Jan-2008  garbled branches: 1.3.10;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8;
file files.pic was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.10 16-Oct-2007  macallan make interrupt distribution via OpenPIC optional
with options OPENPIC_DISTRIBUTE all CPUs will receive hardware interrupts,
otherwise only cpu0
 1.1.2.9 09-May-2007  garbled The i8259 and prepivr code had a bunch of functions that were duplicates
of one another. Break those out into i8259_common.c and share that file
between the two of them.
 1.1.2.8 04-May-2007  macallan sprinkle needs-flag
 1.1.2.7 04-May-2007  macallan add config voodoo to select support for various PICs using options PIC_*
 1.1.2.6 04-May-2007  garbled Add an i8259 pic. Compile tested only.
Add 8259 initialization code to prepivr. (Forgot to add this when I nuked
init_icu(), oddly enough, my machine didn't care, but I'm sure thats pure
luck.)
There is probably alot more sharing that can take place between these two
files, but I'm not sure how to accomplish it yet because of the PIC_XXX
options. That will be a TODO item.
 1.1.2.5 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.1.2.4 03-May-2007  nisimura - files.pic
allow to choose files as designated for Makefile.
- pic_openpic.c, pic_prepivr.c
remove #ifdef PIC_xxx constructs.
- pic_openpic.c
honour OPENPIC feature register NIRQ field for max. number of
available irqs. Valid for MPC107/MPC824x EPIC.
 1.1.2.3 03-May-2007  garbled Add pic_prepivr.c to this
 1.1.2.2 02-May-2007  macallan OpenPIC support
 1.1.2.1 02-May-2007  macallan first try on a generic interrupt handler.
Features:
- PIC details are hidden by struct pic_ops
- PICs can easily be cascaded
- support for soft interrupts
tested so far only on macppc with a PowerBook 3400c
 1.2.14.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.8.3 23-Mar-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file files.pic was added on branch matt-armv6 on 2007-11-06 23:20:52 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file files.pic was added on branch yamt-lazymbuf on 2007-10-27 11:27:58 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file files.pic was added on branch vmlocking on 2007-10-23 20:36:16 +0000
 1.3.10.1 19-Aug-2009  yamt sync with head.
 1.4.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.1 12-Jun-2011  rmind sync with head
 1.7 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.6 20-Jun-2011  matt branches: 1.6.2; 1.6.6;
<arch/powerpc/... -> <powerpc/...
 1.5 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 28-Apr-2008  martin branches: 1.4.32;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2007  garbled branches: 1.3.8; 1.3.10; 1.3.12;
Fix the endless stream of 7's problem on i8259-like interrupt controllers
once and for all. The i8259 does not like to be read in a loop, when an
interrupt comes in, it will return a valid value, however, if you keep
reading it until there are no outstanding interrupts, it will return 7
(which is the lpt interrupt). Change the pic handler to give an argument
to the get_irq functions of mode, which indicates if this is the first
time we are asking, or if we are just rechecking in a loop. Non-i8259
handlers can safely ignore this argument.

Tested to fix the stream of 7's problem on prep and ofppc. Got rid of
the nasty hack in ofppc with this too, and the prep machine seems to take
less interrupts now, which is a good thing.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.10; 1.2.12; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 09-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file i8259_common.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.2 10-Oct-2007  garbled Change pic_prepivr around a bit. Handle the default IRQ 7 from the 8259
better, and add a new motivr_get_irq(). The motorola machines require an
actual read from the 8259 for PCI irqs, so in that case, we read the
8259, and then read the IVR to ack the irq.

Move i8259_get_irq() to i8259_common.c for above.

Fix some minor typos in the chip id's for prep residual.

Fix ibmnws and prep to properly initialize the prep ivr depending on if
the machine is motorola, or IBM based.

Tested on a 7043 and an MTX604
 1.1.2.1 09-May-2007  garbled The i8259 and prepivr code had a bunch of functions that were duplicates
of one another. Break those out into i8259_common.c and share that file
between the two of them.
 1.2.14.1 13-Dec-2007  bouyer Sync with HEAD
 1.2.12.1 13-Dec-2007  yamt sync with head.
 1.2.10.1 26-Dec-2007  ad Sync with head.
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file i8259_common.c was added on branch matt-armv6 on 2007-11-06 23:20:52 +0000
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file i8259_common.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:58 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file i8259_common.c was added on branch vmlocking on 2007-10-23 20:36:17 +0000
 1.3.12.1 16-May-2008  yamt sync with head.
 1.3.10.1 18-May-2008  yamt sync with head.
 1.3.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.38 05-Jul-2025  macallan add a function to find a PIC by its base address
 1.37 17-Feb-2025  jmcneill powerpc: Don't enable interrupts before calling cascaded intr handler.

Before calling a normal interrupt handler, the pic code adjusts cpl and
enables interrupts. Don't do this with interrupt sources that feed
cascaded pics as the resulting handler will do it anyway, and it can
result in multiple interrupts firing on the parent pic just to service
a single interrupt on the child.
 1.36 16-Feb-2025  jmcneill powerpc: Mask interrupts after returning from handler.

Now that we are explicitly masking interrupts on entry of pic_handle_intr,
we need to disable (instead of store) interrupts after calling
intr_deliver.
 1.35 15-Feb-2025  jmcneill powerpc: Fix ci_ipending corruption with cascaded pics

A cascaded pic will register pic_handle_intr as its interrupt handler,
but interrupt handlers are called with MSR[EE] = 1. This breaks
assumptions in pic callbacks and can result in eg. corrupt ci_ipending
due to a read/modify/write of the field with nested interrupts.

Fix this by always clearing MSR[EE] at the top of pic_handle_intr.
 1.34 16-Feb-2022  riastradh branches: 1.34.4; 1.34.10;
powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.33 23-Mar-2021  skrll KNF
 1.32 22-Mar-2021  rin Brush up previous, or make things more similar to x86:

- Prevent pic_name from appearing vmstat(1) twice.
- Restore "irq" in interrupt id fields of intrctl(8).

For these purposes,

- Add is_evname member to struct intr_source.
- Bump size of is_source to INTRIDBUF, and rename it to is_intrid for clarity.

Now, outputs from vmstat(1) and intrctl(8) are like:

----
$ vmstat -ev
...
openpic irq 39 3967 26 intr
...
$ intrctl list
interrupt id CPU0 device name(s)
...
openpic irq 39 3967* wdc1
...
----
 1.31 06-Mar-2021  rin branches: 1.31.2;
Include PIC name to interrupt source, instead of just "irq", so that
it appears in "interrupt id" field of intrctl(8).

Should be useful when multiple PICs are simultaneously available as in
405EX (where uic[12] are cascaded to uic0).
 1.30 02-Mar-2021  rin Turn imask into static.

XXX
Other macro etc. in powerpc/intr.h should also be moved into
powerpc/pic/intr.c, or protected by __INTR_PRIVATE.
 1.29 06-Jul-2020  rin branches: 1.29.2;
Include missing opt_ppcarch.h.
 1.28 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.27 20-Feb-2020  rin eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.26 03-Sep-2018  riastradh branches: 1.26.4; 1.26.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.25 19-Oct-2016  nonaka branches: 1.25.14; 1.25.16;
Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.24 26-May-2016  macallan branches: 1.24.2;
treat IPIs like regular interrupts at IPL_HIGH
should fix port-powerpc/44387
tested by chuq
 1.23 31-Aug-2012  macallan branches: 1.23.2; 1.23.16;
when calculating per-IPL virq masks, take into account that shared IRQs may
request different IPLs
fixes vr(4)-related problems seen on ofppc
 1.22 07-Jun-2012  macallan fix same thinko as in previous commit, in have_pending_intr_p()
 1.21 07-Jun-2012  macallan look at the right cpu_softints bits in pic_do_pending_int()
so we call the right softint handlers
 1.20 01-Feb-2012  matt branches: 1.20.2;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.19 14-Jan-2012  phx Some PICs have the capability to define the interrupt's polarity (OpenPIC
for example). So the accepted interrupt types have been extended to:
- IST_EDGE_FALLING (which is the same as IST_EDGE)
- IST_EDGE_RISING (new)
- IST_LEVEL_LOW (is the same as IST_LEVEL)
- IST_LEVEL_HIGH (new)
Old code will continue to work without modification.
 1.18 27-Sep-2011  jym branches: 1.18.2; 1.18.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.17 21-Jun-2011  rjs Make it compile when PIC_DEBUG is defined.
 1.16 20-Jun-2011  matt Cleanup includes. Explicitly include <powerpc/psl.h>
 1.15 17-Jun-2011  matt intr.h must not include cpu due to deadly embrace with SOFTINT_COUNT.
Cleanup intr.h so MD definitions can overload common definitions.
Rototill pic/intr.c. Virtual IRQs can now be reclaimed. separate virq
from hwirq from picirq. Redo intr mask calculations.
tested on pmppc and macppc (MP).
 1.14 17-Jun-2011  matt Change from level to ipl since we aren't dealing a mask anymore, just a
simple value.
Fix intr_calculatemasks to deal with ipl isn't a mask. Let establish
and disestablish determine the highest ipl for the interrut source being
modified. No reason to recompute that for every source when only one changes
at a time. Only change idepth while in the loop.
 1.13 16-Jun-2011  matt Make sure OEA ports without __HAVE_FAST_SOFTINTS still compile.
 1.12 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 1.11 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.10 20-Dec-2010  matt branches: 1.10.2; 1.10.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.9 12-May-2010  macallan make this work again
 1.8 24-Apr-2010  kiyohara Support 64-bit imask for powerpc/pic.
 1.7 10-Mar-2010  kiyohara branches: 1.7.2;
Remove white-spaces.
 1.6 29-Apr-2008  martin branches: 1.6.20;
Convert to new 2 clause license
 1.5 08-Apr-2008  garbled branches: 1.5.2; 1.5.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.4 11-Dec-2007  garbled branches: 1.4.8;
Fix the endless stream of 7's problem on i8259-like interrupt controllers
once and for all. The i8259 does not like to be read in a loop, when an
interrupt comes in, it will return a valid value, however, if you keep
reading it until there are no outstanding interrupts, it will return 7
(which is the lpt interrupt). Change the pic handler to give an argument
to the get_irq functions of mode, which indicates if this is the first
time we are asking, or if we are just rechecking in a loop. Non-i8259
handlers can safely ignore this argument.

Tested to fix the stream of 7's problem on prep and ofppc. Got rid of
the nasty hack in ofppc with this too, and the prep machine seems to take
less interrupts now, which is a good thing.
 1.3 03-Dec-2007  ad branches: 1.3.2; 1.3.4; 1.3.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8;
file intr.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.22 11-Oct-2007  macallan remove code that would restrict IRQs and softintrs to cpu0
 1.1.2.21 11-Oct-2007  macallan don't declare ipiops again
 1.1.2.20 10-Oct-2007  garbled New ppcoea-MI IPI infrastructure. This is similar to the PIC
infrastructure, but simplified greatly.

Also, convert macppc (the only port currently using IPI's) over to this new
infrastructure. Still some minor work left to do here.
 1.1.2.19 04-Oct-2007  macallan fix pasto - now we actually run IPIs on cpu0 again
 1.1.2.18 07-Sep-2007  macallan calculate interrupt maks after establishing the handler - otherwise the
last established IRQ handler would never be unblocked
 1.1.2.17 10-May-2007  garbled Change the biomask printf to aprint_normal.
 1.1.2.16 10-May-2007  garbled More cleanup:
1) Remove lcsplx, strayintr, and foosoft from all the converted ports.
None of this stuff is needed anymore.
2) because lcsplx is just "return spllower", just call spllower from
locore_subr.S instead.
3) Every port (except macppc) had a pretty similar cpu_configure(), so
take the common parts out and make a genppc_cpu_configure() in an attempt
to stop using imask[] outside of intr.c
 1.1.2.15 09-May-2007  matt Simplify intr_typename
 1.1.2.14 09-May-2007  macallan nuke #if(n)def __HAVE_GENERIC_SOFT_INTERRUPTS
 1.1.2.13 07-May-2007  garbled Rewrite how shared isa is done slightly. This will allow the individual
ports to override the shared functions if needed. Also, implement
isa_intr_alloc, which needed to be done inside pic/intr.c because it
needs access to structs which are static to the file.
 1.1.2.12 04-May-2007  nisimura follow up to the previous change for struct pic_ops, and make
pic_i8259.c compilable.
 1.1.2.11 04-May-2007  macallan adapt to picvar changes, call pic_establish_irq() with max priority in use on
the resp. IRQ
 1.1.2.10 03-May-2007  garbled Add splraise, splx, spllower and softintr here.
 1.1.2.9 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.1.2.8 03-May-2007  nisimura These two have no <machine/autoconf.h> dependency.
 1.1.2.7 03-May-2007  macallan add dummy establish_intr method
 1.1.2.6 03-May-2007  garbled Fix typo in pic_ack_irq
 1.1.2.5 03-May-2007  garbled Add some additional functions (pic_establish_irq) to enable use with an 8259
 1.1.2.4 03-May-2007  macallan remove pic_reenable_irq() from pic_handle_intr()
 1.1.2.3 03-May-2007  macallan fix some compiler warnings
 1.1.2.2 02-May-2007  macallan cosmetics:
- remove CPU number from pic_get_irq()
- add type parameter to enable/reenable
- add IRQ parameter to pic_ack_irq()
... and make intr.c compile again
 1.1.2.1 02-May-2007  macallan first try on a generic interrupt handler.
Features:
- PIC details are hidden by struct pic_ops
- PICs can easily be cascaded
- support for soft interrupts
tested so far only on macppc with a PowerBook 3400c
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file intr.c was added on branch matt-armv6 on 2007-11-06 23:20:53 +0000
 1.2.6.2 27-Dec-2007  mjf Sync with HEAD.
 1.2.6.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.4.4 21-Jan-2008  yamt sync with head
 1.2.4.3 07-Dec-2007  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file intr.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:59 +0000
 1.2.2.3 03-Dec-2007  ad Sync with HEAD.
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file intr.c was added on branch vmlocking on 2007-10-23 20:36:17 +0000
 1.3.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.3.4.1 13-Dec-2007  yamt sync with head.
 1.3.2.1 26-Dec-2007  ad Sync with head.
 1.4.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.2 11-Aug-2010  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.1 18-May-2008  yamt sync with head.
 1.6.20.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.2.3 12-Jun-2011  rmind sync with head
 1.7.2.2 05-Mar-2011  rmind sync with head
 1.7.2.1 30-May-2010  rmind sync with head
 1.10.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.6.1 18-Feb-2012  mrg merge to -current.
 1.18.2.2 30-Oct-2012  yamt sync with head
 1.18.2.1 17-Apr-2012  yamt sync with head
 1.20.2.2 03-Sep-2012  riz Pull up following revision(s) (requested by macallan in ticket #535):
sys/arch/powerpc/pic/intr.c: revision 1.23
when calculating per-IPL virq masks, take into account that shared =20
IRQs may
request different IPLs
fixes vr(4)-related problems seen on ofppc
 1.20.2.1 12-Jun-2012  riz branches: 1.20.2.1.2;
Pull up following revision(s) (requested by macallan in ticket #320):
sys/arch/powerpc/pic/intr.c: revision 1.21
sys/arch/powerpc/pic/intr.c: revision 1.22
look at the right cpu_softints bits in pic_do_pending_int()
so we call the right softint handlers
fix same thinko as in previous commit, in have_pending_intr_p()
 1.20.2.1.2.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.23.16.2 05-Dec-2016  skrll Sync with HEAD
 1.23.16.1 29-May-2016  skrll Sync with HEAD
 1.23.2.1 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 04-Nov-2016  pgoyette Sync with HEAD
 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.26.6.1 29-Feb-2020  ad Sync with head.
 1.26.4.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #730):

sys/arch/powerpc/conf/files.powerpc: revision 1.93
sys/arch/powerpc/include/pio.h: revision 1.8
sys/arch/powerpc/pic/intr.c: revision 1.27
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.50
sys/arch/powerpc/powerpc/pio_subr.S: revision 1.17

Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)

-

eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.29.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.31.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.34.10.1 02-Aug-2025  perseant Sync with HEAD
 1.34.4.1 22-Feb-2025  martin Pull up following revision(s) (requested by jmcneill in ticket #1056):

sys/arch/powerpc/pic/intr.c: revision 1.35
sys/arch/powerpc/pic/intr.c: revision 1.36
sys/arch/powerpc/pic/intr.c: revision 1.37
sys/arch/powerpc/pic/picvar.h: revision 1.14

powerpc: Fix ci_ipending corruption with cascaded pics
A cascaded pic will register pic_handle_intr as its interrupt handler,
but interrupt handlers are called with MSR[EE] = 1. This breaks
assumptions in pic callbacks and can result in eg. corrupt ci_ipending
due to a read/modify/write of the field with nested interrupts.

Fix this by always clearing MSR[EE] at the top of pic_handle_intr.

powerpc: Mask interrupts after returning from handler.
Now that we are explicitly masking interrupts on entry of pic_handle_intr,
we need to disable (instead of store) interrupts after calling
intr_deliver.

powerpc: Don't enable interrupts before calling cascaded intr handler.
Before calling a normal interrupt handler, the pic code adjusts cpl and
enables interrupts. Don't do this with interrupt sources that feed
cascaded pics as the resulting handler will do it anyway, and it can
result in multiple interrupts firing on the parent pic just to service
a single interrupt on the child.
 1.16 06-Jul-2020  rin Drop unused opt_altivec.h, opt_interrupt.h, opt_ipi.h, and opt_pic.h.
 1.15 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.14 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.13 24-Nov-2019  ad Add IPI_AST.
 1.12 23-Jan-2015  nonaka branches: 1.12.18;
ddb MP support
 1.11 19-May-2014  rmind branches: 1.11.4;
Implement MI IPI interface with cross-call support.
 1.10 20-Jun-2011  matt branches: 1.10.12; 1.10.26;
Cleanup includes. Explicitly include <powerpc/psl.h>
 1.9 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.8 02-May-2011  matt branches: 1.8.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.7 18-Jan-2011  matt Fix some fallout from building the macppc GENERIC.MP.
 1.6 25-Jun-2010  rmind branches: 1.6.2;
Add missing sys/xcall.h inclusion, remove sys/malloc.h one.
 1.5 22-Jun-2010  rmind Implement high priority (XC_HIGHPRI) xcall(9) mechanism - a facility
to execute functions from software interrupt context, at SOFTINT_CLOCK.
Functions must be lightweight. Will be used for passive serialization.

OK ad@.
 1.4 28-Apr-2008  martin branches: 1.4.20; 1.4.22;
Remove clause 3 and 4 from TNF licenses
 1.3 08-Apr-2008  garbled branches: 1.3.2; 1.3.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 10-Oct-2007  garbled branches: 1.1.2;
file ipi.c was initially added on branch ppcoea-renovation.
 1.1.2.1 10-Oct-2007  garbled New ppcoea-MI IPI infrastructure. This is similar to the PIC
infrastructure, but simplified greatly.

Also, convert macppc (the only port currently using IPI's) over to this new
infrastructure. Still some minor work left to do here.
 1.2.26.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.12.2 06-Nov-2007  matt sync with HEAD
 1.2.12.1 17-Oct-2007  matt file ipi.c was added on branch matt-armv6 on 2007-11-06 23:20:54 +0000
 1.2.8.2 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.2.8.1 17-Oct-2007  joerg file ipi.c was added on branch jmcneill-pm on 2007-11-02 13:34:46 +0000
 1.2.6.2 27-Oct-2007  yamt sync with head.
 1.2.6.1 17-Oct-2007  yamt file ipi.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:59 +0000
 1.2.4.2 23-Oct-2007  ad Sync with head.
 1.2.4.1 17-Oct-2007  ad file ipi.c was added on branch vmlocking on 2007-10-23 20:36:18 +0000
 1.2.2.2 18-Oct-2007  yamt sync with head.
 1.2.2.1 17-Oct-2007  yamt file ipi.c was added on branch yamt-x86pmap on 2007-10-18 08:32:45 +0000
 1.3.4.2 11-Aug-2010  yamt sync with head.
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.1 18-May-2008  yamt sync with head.
 1.4.22.4 12-Jun-2011  rmind sync with head
 1.4.22.3 31-May-2011  rmind sync with head
 1.4.22.2 05-Mar-2011  rmind sync with head
 1.4.22.1 03-Jul-2010  rmind sync with head
 1.4.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.26.1 10-Aug-2014  tls Rebase.
 1.10.12.2 03-Dec-2017  jdolecek update from HEAD
 1.10.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.4.1 06-Apr-2015  skrll Sync with HEAD
 1.12.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10 05-Mar-2021  rin Convert to intr_establish_xname().
 1.9 06-Jul-2020  rin branches: 1.9.2;
Style and cosmetic changes. No binary changes intended.
 1.8 26-May-2016  macallan treat IPIs like regular interrupts at IPL_HIGH
should fix port-powerpc/44387
tested by chuq
 1.7 01-Feb-2012  matt branches: 1.7.6; 1.7.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.6 20-Jun-2011  matt branches: 1.6.2; 1.6.6;
<arch/powerpc/... -> <powerpc/...
 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 28-Apr-2008  martin branches: 1.4.22; 1.4.28; 1.4.32;
Remove clause 3 and 4 from TNF licenses
 1.3 08-Apr-2008  garbled branches: 1.3.2; 1.3.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 10-Oct-2007  garbled branches: 1.1.2;
file ipi_openpic.c was initially added on branch ppcoea-renovation.
 1.1.2.2 10-Oct-2007  macallan - move IPI setup to ipi_openpic
- some cleanup
 1.1.2.1 10-Oct-2007  garbled New ppcoea-MI IPI infrastructure. This is similar to the PIC
infrastructure, but simplified greatly.

Also, convert macppc (the only port currently using IPI's) over to this new
infrastructure. Still some minor work left to do here.
 1.2.26.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.12.2 06-Nov-2007  matt sync with HEAD
 1.2.12.1 17-Oct-2007  matt file ipi_openpic.c was added on branch matt-armv6 on 2007-11-06 23:20:54 +0000
 1.2.8.2 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.2.8.1 17-Oct-2007  joerg file ipi_openpic.c was added on branch jmcneill-pm on 2007-11-02 13:34:46 +0000
 1.2.6.2 27-Oct-2007  yamt sync with head.
 1.2.6.1 17-Oct-2007  yamt file ipi_openpic.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:59 +0000
 1.2.4.2 23-Oct-2007  ad Sync with head.
 1.2.4.1 17-Oct-2007  ad file ipi_openpic.c was added on branch vmlocking on 2007-10-23 20:36:19 +0000
 1.2.2.2 18-Oct-2007  yamt sync with head.
 1.2.2.1 17-Oct-2007  yamt file ipi_openpic.c was added on branch yamt-x86pmap on 2007-10-18 08:32:46 +0000
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.1 18-May-2008  yamt sync with head.
 1.4.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.22.1 12-Jun-2011  rmind sync with head
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.7.24.1 29-May-2016  skrll Sync with HEAD
 1.7.6.1 03-Dec-2017  jdolecek update from HEAD
 1.9.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.12 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.11 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.10 24-Nov-2019  ad branches: 1.10.6;
Add IPI_AST.
 1.9 19-Apr-2018  christos branches: 1.9.2;
s/static inline/static __inline/g for consistency.
 1.8 23-Jan-2015  nonaka branches: 1.8.16;
ddb MP support
 1.7 19-May-2014  rmind branches: 1.7.4;
Implement MI IPI interface with cross-call support.
 1.6 13-Oct-2011  matt branches: 1.6.12; 1.6.26;
Don't declare cpu_send_ipi if BOOKE
 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 22-Jun-2010  rmind branches: 1.4.2; 1.4.6;
Implement high priority (XC_HIGHPRI) xcall(9) mechanism - a facility
to execute functions from software interrupt context, at SOFTINT_CLOCK.
Functions must be lightweight. Will be used for passive serialization.

OK ad@.
 1.3 28-Apr-2008  martin branches: 1.3.20; 1.3.22;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.26; 1.2.28; 1.2.30;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 10-Oct-2007  garbled branches: 1.1.2;
file ipivar.h was initially added on branch ppcoea-renovation.
 1.1.2.2 11-Oct-2007  macallan convenience
 1.1.2.1 10-Oct-2007  garbled New ppcoea-MI IPI infrastructure. This is similar to the PIC
infrastructure, but simplified greatly.

Also, convert macppc (the only port currently using IPI's) over to this new
infrastructure. Still some minor work left to do here.
 1.2.30.2 11-Aug-2010  yamt sync with head.
 1.2.30.1 16-May-2008  yamt sync with head.
 1.2.28.1 18-May-2008  yamt sync with head.
 1.2.26.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.12.2 06-Nov-2007  matt sync with HEAD
 1.2.12.1 17-Oct-2007  matt file ipivar.h was added on branch matt-armv6 on 2007-11-06 23:20:55 +0000
 1.2.8.2 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.2.8.1 17-Oct-2007  joerg file ipivar.h was added on branch jmcneill-pm on 2007-11-02 13:34:47 +0000
 1.2.6.2 27-Oct-2007  yamt sync with head.
 1.2.6.1 17-Oct-2007  yamt file ipivar.h was added on branch yamt-lazymbuf on 2007-10-27 11:28:00 +0000
 1.2.4.2 23-Oct-2007  ad Sync with head.
 1.2.4.1 17-Oct-2007  ad file ipivar.h was added on branch vmlocking on 2007-10-23 20:36:20 +0000
 1.2.2.2 18-Oct-2007  yamt sync with head.
 1.2.2.1 17-Oct-2007  yamt file ipivar.h was added on branch yamt-x86pmap on 2007-10-18 08:32:46 +0000
 1.3.22.2 12-Jun-2011  rmind sync with head
 1.3.22.1 03-Jul-2010  rmind sync with head
 1.3.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.26.1 10-Aug-2014  tls Rebase.
 1.6.12.2 03-Dec-2017  jdolecek update from HEAD
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.4.1 06-Apr-2015  skrll Sync with HEAD
 1.8.16.1 22-Apr-2018  pgoyette Sync with HEAD
 1.9.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.9 06-Jul-2020  rin Drop unused opt_interrupt.h.
 1.8 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.7 19-Sep-2013  christos use ci_index.
 1.6 01-Feb-2012  matt branches: 1.6.6; 1.6.10;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.5 20-Jun-2011  matt branches: 1.5.2; 1.5.6;
<arch/powerpc/... -> <powerpc/...
 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 29-Apr-2008  martin branches: 1.3.22; 1.3.28; 1.3.32;
Convert to new 2 clause license
 1.2 08-Apr-2008  garbled branches: 1.2.2; 1.2.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.1 17-Jan-2008  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.14;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 17-Jan-2008  matt file openpic_common.c was added on branch matt-armv6 on 2008-03-23 02:04:18 +0000
 1.1.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.6.1 17-Jan-2008  mjf file openpic_common.c was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.1.4.2 21-Jan-2008  yamt sync with head
 1.1.4.1 17-Jan-2008  yamt file openpic_common.c was added on branch yamt-lazymbuf on 2008-01-21 09:38:26 +0000
 1.1.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 17-Jan-2008  bouyer file openpic_common.c was added on branch bouyer-xeni386 on 2008-01-19 12:14:42 +0000
 1.2.4.1 16-May-2008  yamt sync with head.
 1.2.2.1 18-May-2008  yamt sync with head.
 1.3.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.22.1 12-Jun-2011  rmind sync with head
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 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 17-Apr-2012  yamt sync with head
 1.6.10.1 18-May-2014  rmind sync with head
 1.6.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.13 06-Jul-2020  rin Drop unused opt_interrupt.h.
 1.12 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.11 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.10 01-Jun-2017  chs branches: 1.10.8; 1.10.10;
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.9 01-Feb-2012  matt branches: 1.9.6; 1.9.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.8 14-Jan-2012  phx Some PICs have the capability to define the interrupt's polarity (OpenPIC
for example). So the accepted interrupt types have been extended to:
- IST_EDGE_FALLING (which is the same as IST_EDGE)
- IST_EDGE_RISING (new)
- IST_LEVEL_LOW (is the same as IST_LEVEL)
- IST_LEVEL_HIGH (new)
Old code will continue to work without modification.
 1.7 02-Jul-2011  mrg branches: 1.7.2; 1.7.6;
avoid some uninitialised variable warnings from GCC 4.5. i'm pretty
sure they can't happen in practise, but i can see why GCC isn't sure.
 1.6 20-Jun-2011  matt <arch/powerpc/... -> <powerpc/...
 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 10-May-2008  martin branches: 1.4.20; 1.4.26; 1.4.30;
Backout previous: the license sweep touched these files in error, so
restore the old license.
 1.3 29-Apr-2008  martin branches: 1.3.2;
Convert to new 2 clause license
 1.2 08-Apr-2008  garbled SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.1 17-Jan-2008  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.14;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 17-Jan-2008  matt file pic_distopenpic.c was added on branch matt-armv6 on 2008-03-23 02:04:18 +0000
 1.1.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.6.1 17-Jan-2008  mjf file pic_distopenpic.c was added on branch mjf-devfs on 2008-02-18 21:04:58 +0000
 1.1.4.2 21-Jan-2008  yamt sync with head
 1.1.4.1 17-Jan-2008  yamt file pic_distopenpic.c was added on branch yamt-lazymbuf on 2008-01-21 09:38:27 +0000
 1.1.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 17-Jan-2008  bouyer file pic_distopenpic.c was added on branch bouyer-xeni386 on 2008-01-19 12:14:43 +0000
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.30.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.20.1 12-Jun-2011  rmind sync with head
 1.7.6.1 18-Feb-2012  mrg merge to -current.
 1.7.2.1 17-Apr-2012  yamt sync with head
 1.9.24.1 28-Aug-2017  skrll Sync with HEAD
 1.9.6.1 03-Dec-2017  jdolecek update from HEAD
 1.10.10.1 10-Jun-2019  christos Sync with HEAD
 1.10.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.7 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.6 01-Feb-2012  matt branches: 1.6.6; 1.6.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.5 20-Jun-2011  matt branches: 1.5.2; 1.5.6;
<arch/powerpc/... -> <powerpc/...
 1.4 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.3 28-Apr-2008  martin branches: 1.3.32;
Remove clause 3 and 4 from TNF licenses
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.22; 1.2.24; 1.2.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 04-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pic_i8259.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.5 11-Oct-2007  macallan add NULL pic_finish_setup()
 1.1.2.4 10-Oct-2007  garbled Change pic_prepivr around a bit. Handle the default IRQ 7 from the 8259
better, and add a new motivr_get_irq(). The motorola machines require an
actual read from the 8259 for PCI irqs, so in that case, we read the
8259, and then read the IVR to ack the irq.

Move i8259_get_irq() to i8259_common.c for above.

Fix some minor typos in the chip id's for prep residual.

Fix ibmnws and prep to properly initialize the prep ivr depending on if
the machine is motorola, or IBM based.

Tested on a 7043 and an MTX604
 1.1.2.3 09-May-2007  garbled The i8259 and prepivr code had a bunch of functions that were duplicates
of one another. Break those out into i8259_common.c and share that file
between the two of them.
 1.1.2.2 04-May-2007  nisimura follow up to the previous change for struct pic_ops, and make
pic_i8259.c compilable.
 1.1.2.1 04-May-2007  garbled Add an i8259 pic. Compile tested only.
Add 8259 initialization code to prepivr. (Forgot to add this when I nuked
init_icu(), oddly enough, my machine didn't care, but I'm sure thats pure
luck.)
There is probably alot more sharing that can take place between these two
files, but I'm not sure how to accomplish it yet because of the PIC_XXX
options. That will be a TODO item.
 1.2.26.1 16-May-2008  yamt sync with head.
 1.2.24.1 18-May-2008  yamt sync with head.
 1.2.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pic_i8259.c was added on branch matt-armv6 on 2007-11-06 23:20:56 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pic_i8259.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:00 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pic_i8259.c was added on branch vmlocking on 2007-10-23 20:36:20 +0000
 1.3.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.6.24.1 28-Aug-2017  skrll Sync with HEAD
 1.6.6.1 03-Dec-2017  jdolecek update from HEAD
 1.9 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.8 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.7 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.6 01-Jun-2017  chs branches: 1.6.8; 1.6.10;
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.5 01-Feb-2012  matt branches: 1.5.6; 1.5.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.4 01-Feb-2012  matt Use C89 function prototypes.
 1.3 14-Jan-2012  phx Some PICs have the capability to define the interrupt's polarity (OpenPIC
for example). So the accepted interrupt types have been extended to:
- IST_EDGE_FALLING (which is the same as IST_EDGE)
- IST_EDGE_RISING (new)
- IST_LEVEL_LOW (is the same as IST_LEVEL)
- IST_LEVEL_HIGH (new)
Old code will continue to work without modification.
 1.2 20-Jun-2011  matt branches: 1.2.2; 1.2.6;
<arch/powerpc/... -> <powerpc/...
 1.1 19-Aug-2009  nisimura branches: 1.1.2; 1.1.12;
- Have pic_mpcsoc.c to adapt variations of Moto/Freescale OpenPIC
compliant interrupt controllers. Mostly the refrain of pic_openpic.c
and shall be useful for 85xx/86xx/QorIQ and Tundra product lines.
 1.1.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.2 19-Aug-2009  yamt sync with head.
 1.1.2.1 19-Aug-2009  yamt file pic_mpcsoc.c was added on branch yamt-nfs-mp on 2009-08-19 18:46:41 +0000
 1.2.6.1 18-Feb-2012  mrg merge to -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.5.24.1 28-Aug-2017  skrll Sync with HEAD
 1.5.6.1 03-Dec-2017  jdolecek update from HEAD
 1.6.10.1 10-Jun-2019  christos Sync with HEAD
 1.6.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.20 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.19 13-Jul-2020  rin Drop unused opt_interrupt.h include.
 1.18 12-Jul-2020  rin No need to test _KERNEL_OPT twice.
No binary changes.
 1.17 06-Jul-2020  rin Include missing opt_multiprocessor.h.
 1.16 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.15 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.14 16-May-2018  macallan branches: 1.14.2;
special case IPIs so we don't mess with hardware IRQ sources
now SMP works on my PCI-X G5
 1.13 22-Mar-2018  macallan don't call mapiodev() - the caller should hand us a usable address
 1.12 02-Mar-2018  macallan branches: 1.12.2;
IRQ0 is perfectly legal to use on at least some macppc, so don't treat it
as an error or something special
with this svwsata works on my PCI-X G5
 1.11 01-Mar-2018  macallan use mapiodev() so this can work on G5s
 1.10 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.9 26-May-2016  macallan treat IPIs like regular interrupts at IPL_HIGH
should fix port-powerpc/44387
tested by chuq
 1.8 01-Feb-2012  matt branches: 1.8.6; 1.8.24;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.7 14-Jan-2012  phx Some PICs have the capability to define the interrupt's polarity (OpenPIC
for example). So the accepted interrupt types have been extended to:
- IST_EDGE_FALLING (which is the same as IST_EDGE)
- IST_EDGE_RISING (new)
- IST_LEVEL_LOW (is the same as IST_LEVEL)
- IST_LEVEL_HIGH (new)
Old code will continue to work without modification.
 1.6 20-Jun-2011  matt branches: 1.6.2; 1.6.6;
<arch/powerpc/... -> <powerpc/...
 1.5 29-Apr-2008  martin branches: 1.5.32;
Convert to new 2 clause license
 1.4 17-Jan-2008  garbled branches: 1.4.6; 1.4.8; 1.4.10;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.3 11-Dec-2007  garbled Fix the endless stream of 7's problem on i8259-like interrupt controllers
once and for all. The i8259 does not like to be read in a loop, when an
interrupt comes in, it will return a valid value, however, if you keep
reading it until there are no outstanding interrupts, it will return 7
(which is the lpt interrupt). Change the pic handler to give an argument
to the get_irq functions of mode, which indicates if this is the first
time we are asking, or if we are just rechecking in a loop. Non-i8259
handlers can safely ignore this argument.

Tested to fix the stream of 7's problem on prep and ofppc. Got rid of
the nasty hack in ofppc with this too, and the prep machine seems to take
less interrupts now, which is a good thing.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8;
file pic_openpic.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.12 16-Oct-2007  macallan make interrupt distribution via OpenPIC optional
with options OPENPIC_DISTRIBUTE all CPUs will receive hardware interrupts,
otherwise only cpu0
 1.1.2.11 11-Oct-2007  macallan implement pic_finish_setup() to send interrupts to all attached CPUs
 1.1.2.10 10-Oct-2007  macallan - move IPI setup to ipi_openpic
- some cleanup
 1.1.2.9 04-Oct-2007  macallan make openpic_set_priority non-static for now since cpu.c calls it on SMP
kernels. This should go away when the hatch code is rewritten.
 1.1.2.8 03-Jun-2007  nisimura - make setup_openpic() to have every SRC_VECTOR(irq) register a value
0x8000'0000 during initialization. opic_establish_irq() will assign
acutual usage values later on.
- note a comment describing that writing S1C bit for OPENPIC_CONFIG
register should bring the sane initial operation state. #if-0'ed out
this time since it remains unknown wether every OpenPIC compliant
controller behave in the same way.
- nuke struct openpic_ops which contains enable_mask for no use.
 1.1.2.7 04-May-2007  macallan nuke unused pic_ops methods, honour priority in pic_establish_irq()
 1.1.2.6 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.1.2.5 03-May-2007  nisimura These two have no <machine/autoconf.h> dependency.
 1.1.2.4 03-May-2007  nisimura - files.pic
allow to choose files as designated for Makefile.
- pic_openpic.c, pic_prepivr.c
remove #ifdef PIC_xxx constructs.
- pic_openpic.c
honour OPENPIC feature register NIRQ field for max. number of
available irqs. Valid for MPC107/MPC824x EPIC.
 1.1.2.3 03-May-2007  macallan fix typo
 1.1.2.2 03-May-2007  macallan adapt to changes picvar.h
 1.1.2.1 02-May-2007  macallan OpenPIC support
 1.2.14.2 19-Jan-2008  bouyer Sync with HEAD
 1.2.14.1 13-Dec-2007  bouyer Sync with HEAD
 1.2.12.1 13-Dec-2007  yamt sync with head.
 1.2.10.1 26-Dec-2007  ad Sync with head.
 1.2.8.4 23-Mar-2008  matt sync with HEAD
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pic_openpic.c was added on branch matt-armv6 on 2007-11-06 23:20:56 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pic_openpic.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:01 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pic_openpic.c was added on branch vmlocking on 2007-10-23 20:36:21 +0000
 1.4.10.1 16-May-2008  yamt sync with head.
 1.4.8.1 18-May-2008  yamt sync with head.
 1.4.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.8.24.2 28-Aug-2017  skrll Sync with HEAD
 1.8.24.1 29-May-2016  skrll Sync with HEAD
 1.8.6.1 03-Dec-2017  jdolecek update from HEAD
 1.12.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.12.2.2 21-May-2018  pgoyette Sync with HEAD
 1.12.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.14.2.1 10-Jun-2019  christos Sync with HEAD
 1.9 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.8 28-Jul-2012  matt branches: 1.8.2; 1.8.16;
Fix -fno-common fallout.
 1.7 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.6 20-Jun-2011  matt branches: 1.6.2; 1.6.6;
<arch/powerpc/... -> <powerpc/...
 1.5 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 28-Apr-2008  martin branches: 1.4.32;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2007  garbled branches: 1.3.8; 1.3.10; 1.3.12;
Fix the endless stream of 7's problem on i8259-like interrupt controllers
once and for all. The i8259 does not like to be read in a loop, when an
interrupt comes in, it will return a valid value, however, if you keep
reading it until there are no outstanding interrupts, it will return 7
(which is the lpt interrupt). Change the pic handler to give an argument
to the get_irq functions of mode, which indicates if this is the first
time we are asking, or if we are just rechecking in a loop. Non-i8259
handlers can safely ignore this argument.

Tested to fix the stream of 7's problem on prep and ofppc. Got rid of
the nasty hack in ofppc with this too, and the prep machine seems to take
less interrupts now, which is a good thing.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8; 1.2.10; 1.2.12; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 03-May-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8;
file pic_prepivr.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.9 11-Oct-2007  macallan add NULL pic_finish_setup()
 1.1.2.8 10-Oct-2007  garbled Change pic_prepivr around a bit. Handle the default IRQ 7 from the 8259
better, and add a new motivr_get_irq(). The motorola machines require an
actual read from the 8259 for PCI irqs, so in that case, we read the
8259, and then read the IVR to ack the irq.

Move i8259_get_irq() to i8259_common.c for above.

Fix some minor typos in the chip id's for prep residual.

Fix ibmnws and prep to properly initialize the prep ivr depending on if
the machine is motorola, or IBM based.

Tested on a 7043 and an MTX604
 1.1.2.7 09-May-2007  garbled The i8259 and prepivr code had a bunch of functions that were duplicates
of one another. Break those out into i8259_common.c and share that file
between the two of them.
 1.1.2.6 07-May-2007  garbled add the third argument to prepivr_establish_irq()
 1.1.2.5 04-May-2007  nisimura follow up to the previous change for struct pic_ops, and make
pic_i8259.c compilable.
 1.1.2.4 04-May-2007  garbled Add an i8259 pic. Compile tested only.
Add 8259 initialization code to prepivr. (Forgot to add this when I nuked
init_icu(), oddly enough, my machine didn't care, but I'm sure thats pure
luck.)
There is probably alot more sharing that can take place between these two
files, but I'm not sure how to accomplish it yet because of the PIC_XXX
options. That will be a TODO item.
 1.1.2.3 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.1.2.2 03-May-2007  nisimura - files.pic
allow to choose files as designated for Makefile.
- pic_openpic.c, pic_prepivr.c
remove #ifdef PIC_xxx constructs.
- pic_openpic.c
honour OPENPIC feature register NIRQ field for max. number of
available irqs. Valid for MPC107/MPC824x EPIC.
 1.1.2.1 03-May-2007  garbled Add a generic prepIVR pic. used by ibmnws and prep.
 1.2.14.1 13-Dec-2007  bouyer Sync with HEAD
 1.2.12.1 13-Dec-2007  yamt sync with head.
 1.2.10.1 26-Dec-2007  ad Sync with head.
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pic_prepivr.c was added on branch matt-armv6 on 2007-11-06 23:20:57 +0000
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pic_prepivr.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:01 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pic_prepivr.c was added on branch vmlocking on 2007-10-23 20:36:22 +0000
 1.3.12.1 16-May-2008  yamt sync with head.
 1.3.10.1 18-May-2008  yamt sync with head.
 1.3.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.2 30-Oct-2012  yamt sync with head
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.8.16.1 28-Aug-2017  skrll Sync with HEAD
 1.8.2.1 03-Dec-2017  jdolecek update from HEAD
 1.5 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.4 10-May-2008  martin branches: 1.4.30;
Backout previous: the license sweep touched these files in error, so
restore the old license.
 1.3 29-Apr-2008  martin branches: 1.3.2;
Convert to new 2 clause license
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 11-May-2007  matt branches: 1.1.2; 1.1.6; 1.1.8;
file pic_soft.c was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.2 22-May-2007  matt Add IPL_SOFTI2C. Use common cas32.
 1.1.2.1 11-May-2007  matt Initial implementation of a "software interrupt" pic which is, of course,
completely in software without any backing hardware.
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file pic_soft.c was added on branch matt-armv6 on 2007-11-06 23:20:58 +0000
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file pic_soft.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:02 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file pic_soft.c was added on branch vmlocking on 2007-10-23 20:36:23 +0000
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.30.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2 17-Jun-2011  matt intr.h must not include cpu due to deadly embrace with SOFTINT_COUNT.
Cleanup intr.h so MD definitions can overload common definitions.
Rototill pic/intr.c. Virtual IRQs can now be reclaimed. separate virq
from hwirq from picirq. Redo intr mask calculations.
tested on pmppc and macppc (MP).
 1.1 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 1.15 05-Jul-2025  macallan add a function to find a PIC by its base address
 1.14 17-Feb-2025  jmcneill powerpc: Don't enable interrupts before calling cascaded intr handler.

Before calling a normal interrupt handler, the pic code adjusts cpl and
enables interrupts. Don't do this with interrupt sources that feed
cascaded pics as the resulting handler will do it anyway, and it can
result in multiple interrupts firing on the parent pic just to service
a single interrupt on the child.
 1.13 22-Mar-2021  rin branches: 1.13.16; 1.13.22;
Brush up previous, or make things more similar to x86:

- Prevent pic_name from appearing vmstat(1) twice.
- Restore "irq" in interrupt id fields of intrctl(8).

For these purposes,

- Add is_evname member to struct intr_source.
- Bump size of is_source to INTRIDBUF, and rename it to is_intrid for clarity.

Now, outputs from vmstat(1) and intrctl(8) are like:

----
$ vmstat -ev
...
openpic irq 39 3967 26 intr
...
$ intrctl list
interrupt id CPU0 device name(s)
...
openpic irq 39 3967* wdc1
...
----
 1.12 16-Apr-2020  rin branches: 1.12.2; 1.12.4;
Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.11 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.10 11-May-2018  macallan branches: 1.10.12;
use 128 as IPI_VECTOR to avoid overlap wth hardware interrupts
 1.9 18-Jun-2011  matt branches: 1.9.52;
Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.8 17-Jun-2011  matt Change from level to ipl since we aren't dealing a mask anymore, just a
simple value.
Fix intr_calculatemasks to deal with ipl isn't a mask. Let establish
and disestablish determine the highest ipl for the interrut source being
modified. No reason to recompute that for every source when only one changes
at a time. Only change idepth while in the loop.
 1.7 24-Apr-2010  kiyohara branches: 1.7.6;
Support 64-bit imask for powerpc/pic.
 1.6 19-Aug-2009  nisimura branches: 1.6.2; 1.6.4;
- Have pic_mpcsoc.c to adapt variations of Moto/Freescale OpenPIC
compliant interrupt controllers. Mostly the refrain of pic_openpic.c
and shall be useful for 85xx/86xx/QorIQ and Tundra product lines.
 1.5 29-Apr-2008  martin Convert to new 2 clause license
 1.4 17-Jan-2008  garbled branches: 1.4.6; 1.4.8; 1.4.10;
Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.3 11-Dec-2007  garbled Fix the endless stream of 7's problem on i8259-like interrupt controllers
once and for all. The i8259 does not like to be read in a loop, when an
interrupt comes in, it will return a valid value, however, if you keep
reading it until there are no outstanding interrupts, it will return 7
(which is the lpt interrupt). Change the pic handler to give an argument
to the get_irq functions of mode, which indicates if this is the first
time we are asking, or if we are just rechecking in a loop. Non-i8259
handlers can safely ignore this argument.

Tested to fix the stream of 7's problem on prep and ofppc. Got rid of
the nasty hack in ofppc with this too, and the prep machine seems to take
less interrupts now, which is a good thing.
 1.2 17-Oct-2007  garbled branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12; 1.2.14;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1 02-May-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8;
file picvar.h was initially added on branch ppcoea-renovation.
 1.1.8.1 18-Oct-2007  yamt sync with head.
 1.1.6.1 02-Nov-2007  joerg More diff reduce to HEAD due to botched up merging.
 1.1.2.14 11-Oct-2007  macallan add pic_ops.pic_finish_setup() for additional PIC setup after the CPUs attached
can be NULL.
 1.1.2.13 10-Oct-2007  garbled Change pic_prepivr around a bit. Handle the default IRQ 7 from the 8259
better, and add a new motivr_get_irq(). The motorola machines require an
actual read from the 8259 for PCI irqs, so in that case, we read the
8259, and then read the IVR to ack the irq.

Move i8259_get_irq() to i8259_common.c for above.

Fix some minor typos in the chip id's for prep residual.

Fix ibmnws and prep to properly initialize the prep ivr depending on if
the machine is motorola, or IBM based.

Tested on a 7043 and an MTX604
 1.1.2.12 04-Oct-2007  macallan #define IPI_VECTOR and add a prototype for an MD IPI handler
This should be abstracted away.
 1.1.2.11 09-May-2007  garbled The i8259 and prepivr code had a bunch of functions that were duplicates
of one another. Break those out into i8259_common.c and share that file
between the two of them.
 1.1.2.10 04-May-2007  nisimura follow up to the previous change for struct pic_ops, and make
pic_i8259.c compilable.
 1.1.2.9 04-May-2007  macallan nuke some unused function pointers from struct pic_ops
add a parameter to pic_establish_irq for priority
 1.1.2.8 04-May-2007  garbled Add an i8259 pic. Compile tested only.
Add 8259 initialization code to prepivr. (Forgot to add this when I nuked
init_icu(), oddly enough, my machine didn't care, but I'm sure thats pure
luck.)
There is probably alot more sharing that can take place between these two
files, but I'm not sure how to accomplish it yet because of the PIC_XXX
options. That will be a TODO item.
 1.1.2.7 03-May-2007  garbled Move the functions down from openpic.c into pic_openpic.c, as there
really is no need to have them over there when all the interrupt routines
will be using pic_openpic.c
Change the openpic setup to set all the irqs except 0 to negative polarity.
Set the spurious vector reg to 0xff.
Emit a nice printf showing the version of the openpic, and getrid of the
maxint thing.
Add a global, primary_pic, so machines can elect any registered pic as
the primary interrupt controller.
Clean up a few nits in pic_prepivr to make it more similar to the openpic
one, add a prototype for the setup_prepivr function, etc etc.
 1.1.2.6 03-May-2007  macallan fix merge muckup
 1.1.2.5 03-May-2007  macallan add dummy establish_intr method
 1.1.2.4 03-May-2007  garbled Add some additional functions (pic_establish_irq) to enable use with an 8259
 1.1.2.3 02-May-2007  macallan OpenPIC support
 1.1.2.2 02-May-2007  macallan cosmetics:
- remove CPU number from pic_get_irq()
- add type parameter to enable/reenable
- add IRQ parameter to pic_ack_irq()
... and make intr.c compile again
 1.1.2.1 02-May-2007  macallan first try on a generic interrupt handler.
Features:
- PIC details are hidden by struct pic_ops
- PICs can easily be cascaded
- support for soft interrupts
tested so far only on macppc with a PowerBook 3400c
 1.2.14.2 19-Jan-2008  bouyer Sync with HEAD
 1.2.14.1 13-Dec-2007  bouyer Sync with HEAD
 1.2.12.1 13-Dec-2007  yamt sync with head.
 1.2.10.1 26-Dec-2007  ad Sync with head.
 1.2.8.4 23-Mar-2008  matt sync with HEAD
 1.2.8.3 09-Jan-2008  matt sync with HEAD
 1.2.8.2 06-Nov-2007  matt sync with HEAD
 1.2.8.1 17-Oct-2007  matt file picvar.h was added on branch matt-armv6 on 2007-11-06 23:20:58 +0000
 1.2.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 27-Oct-2007  yamt sync with head.
 1.2.4.1 17-Oct-2007  yamt file picvar.h was added on branch yamt-lazymbuf on 2007-10-27 11:28:02 +0000
 1.2.2.2 23-Oct-2007  ad Sync with head.
 1.2.2.1 17-Oct-2007  ad file picvar.h was added on branch vmlocking on 2007-10-23 20:36:24 +0000
 1.4.10.3 11-Aug-2010  yamt sync with head.
 1.4.10.2 19-Aug-2009  yamt sync with head.
 1.4.10.1 16-May-2008  yamt sync with head.
 1.4.8.1 18-May-2008  yamt sync with head.
 1.4.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.4.1 30-May-2010  rmind sync with head
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.52.1 21-May-2018  pgoyette Sync with HEAD
 1.10.12.1 20-Apr-2020  bouyer Sync with HEAD
 1.12.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.12.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.13.22.1 02-Aug-2025  perseant Sync with HEAD
 1.13.16.1 22-Feb-2025  martin Pull up following revision(s) (requested by jmcneill in ticket #1056):

sys/arch/powerpc/pic/intr.c: revision 1.35
sys/arch/powerpc/pic/intr.c: revision 1.36
sys/arch/powerpc/pic/intr.c: revision 1.37
sys/arch/powerpc/pic/picvar.h: revision 1.14

powerpc: Fix ci_ipending corruption with cascaded pics
A cascaded pic will register pic_handle_intr as its interrupt handler,
but interrupt handlers are called with MSR[EE] = 1. This breaks
assumptions in pic callbacks and can result in eg. corrupt ci_ipending
due to a read/modify/write of the field with nested interrupts.

Fix this by always clearing MSR[EE] at the top of pic_handle_intr.

powerpc: Mask interrupts after returning from handler.
Now that we are explicitly masking interrupts on entry of pic_handle_intr,
we need to disable (instead of store) interrupts after calling
intr_deliver.

powerpc: Don't enable interrupts before calling cascaded intr handler.
Before calling a normal interrupt handler, the pic code adjusts cpl and
enables interrupts. Don't do this with interrupt sources that feed
cascaded pics as the resulting handler will do it anyway, and it can
result in multiple interrupts firing on the parent pic just to service
a single interrupt on the child.
 1.6 08-May-2003  christos rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 08-Jun-2000  kleink branches: 1.4.10;
Need <sys/systm.h> for panic() declaration.
 1.3 26-May-2000  thorpej branches: 1.3.2;
First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

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

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

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

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

Tested on i386 and Alpha. Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
 1.2 06-Nov-1996  cgd branches: 1.2.28;
Fix an inconsistency that came in with Lite: setrq() was renamed to
setrunqueue(), but remrq() was never renamed. Rename remrq() to
remrunqueue().
 1.1 30-Sep-1996  ws PowerPC port
 1.2.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.4.10.2 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.4.10.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.6 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.5 24-Feb-1998  mycroft ofd -> ofdisk
 1.4 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.3 26-Mar-1997  gwr Move findroot/setroot stuff from configure() to cpu_rootconf().
 1.2 31-Jan-1997  thorpej branches: 1.2.2;
Use the new machine-independent setroot().
 1.1 30-Sep-1996  ws branches: 1.1.2;
PowerPC port
 1.1.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.2.2.1 02-Mar-1997  mrg swapconf() is no more.
 1.3 18-Apr-2002  kleink Unused; already implemented in libkern.
 1.2 16-Apr-1997  thorpej branches: 1.2.36; 1.2.40;
RCS ID and #includes cleanup.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.40.1 20-Jun-2002  nathanw Catch up to -current.
 1.2.36.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.56 15-Dec-2023  rin powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.

Part of PR kern/57621
 1.55 26-Jul-2022  andvar branches: 1.55.4;
s/functin/function/ in copy pasted comment.
 1.54 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.53 16-Feb-2022  riastradh powerpc: Implement bus_dmamap_load_raw.

Can probably delete some of the round-trips between bus addresses and
physical addresses -- did these only to copy the logic already in
_bus_dmamap_load_buffer.
 1.52 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.51 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.50 20-Feb-2020  rin eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.49 03-Sep-2018  riastradh branches: 1.49.4; 1.49.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.48 27-Apr-2018  maxv branches: 1.48.2;
M_CLUSTER -> M_EXT_CLUSTER
 1.47 23-Dec-2016  cherry branches: 1.47.14;
"Make NetBSD great again!"

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

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

KeK (http://www.kek.org.in) for hosting the primary developers.
 1.46 01-Feb-2012  matt branches: 1.46.6; 1.46.24; 1.46.28;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.45 30-Jan-2012  matt Use ANSI prototype for _bus_dmamem_alloc_range.
Caught when compiling with -Wold-style-definition
 1.44 19-Jul-2011  matt branches: 1.44.2; 1.44.6;
Fix missed change of BUS_DMA_NOCACHE to BUS_DMA_DONTCACHE.
 1.43 17-Jul-2011  dyoung Enable new-style <sys/bus.h> on several PowerPC ports supporting PCI
buses. Make non-inline implementations of bus_space(9) and bus_dma(9)
routines and move them to appropriate .c files.

This may leave amigappc in a bad state, sorry. Fortunately, it will be
easy to repair by imitating the bus.h -> bus_{defs,funcs}.h split in
some other PowerPC port.
 1.42 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.41 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.40 13-Jun-2011  matt Use ptoa(x) instead of x << PGSHIFT
 1.39 08-Jun-2011  matt A small speedup, when mapping memory in bus_dmamem_map, if the memory is
cacheable and is in a single segment (physically contiguous) don't bother
allocating KVA for it, just use the physical address as the VA.
 1.38 18-Jan-2011  matt branches: 1.38.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.37 10-Nov-2010  uebayasi branches: 1.37.2;
Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.36 06-Nov-2010  uebayasi Machine dependent code is considered as part of UVM. Include
internal API header.
 1.35 07-Nov-2009  cegger branches: 1.35.2; 1.35.4;
Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.34 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.33 04-Jun-2008  ad branches: 1.33.6; 1.33.12; 1.33.20;
vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both.
 1.32 28-Apr-2008  martin branches: 1.32.2;
Remove clause 3 and 4 from TNF licenses
 1.31 29-Jan-2008  mrg branches: 1.31.6; 1.31.8; 1.31.10;
initialise "paddr_t lastaddr" to 0 in the cases it is not otherwise
set. previously, if the stack garbage happened to match the
"curaddr" in _bus_dmamap_load_buffer(), the wrong thing may have
happened.
 1.30 04-Mar-2007  christos branches: 1.30.20; 1.30.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.29 27-Oct-2006  garbled branches: 1.29.4;
Change an instance of curaddr to PHYS_TO_BUS_MEM(t, curaddr) in
_bus_dmamap_load_buffer, otherwise when attempting to DMA a buffer larger
than PAGE_SIZE on an arch where PHYS != BUS it will allways fail.
 1.28 07-Sep-2006  garbled branches: 1.28.2;
Apply the patch found in PR/28512 and PR/23801. Ok'd by a few people.
From the PR:
The cache is flushed using the bus address where the phys address
is required. Errors would be seen only on ports where address
translation is done between the bus and physical memory.
 1.27 12-Mar-2006  yamt branches: 1.27.10;
fix mistakes in yamt-uio_vmspace changes.
 1.26 01-Mar-2006  yamt branches: 1.26.2; 1.26.4;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.25 24-Dec-2005  perry branches: 1.25.2; 1.25.4; 1.25.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.24 11-Dec-2005  christos merge ktrace-lwp.
 1.23 24-Nov-2005  yamt bus_dmamem_map: honour BUS_DMA_NOWAIT. noted by Manuel Bouyer.
bus_space_map: always do NOWAIT allocation as it used to be before yamt-km.

we have too many copies!
 1.22 01-Apr-2005  yamt branches: 1.22.2; 1.22.8;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.21 09-Mar-2005  matt Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API
to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create). dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
 1.20 28-Nov-2004  thorpej branches: 1.20.4; 1.20.6;
bus_dmamap_load_mbuf(): Skip zero-length mbufs.
kern/24811
 1.19 17-Aug-2004  scw In _bus_dmamap_load_buffer(), honour the maximum segment size specified
when the DMA map was created.

The previous behaviour honoured the maximum segment size only when
coalescing adjacent segments.
 1.18 16-Aug-2004  aymeric fix typo in comment
 1.17 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 29-Jun-2003  fvdl branches: 1.15.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.14 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.13 12-Jun-2003  scw Back out the last change after consultation with Matt Thomas. It hurts
platforms with fully functional bus snooping.
 1.12 12-Jun-2003  scw In _bus_dmamem_map(), make BUS_DMA_COHERENT behave the same way as
BUS_DMA_NOCACHE.
 1.11 18-Apr-2003  scw Make sure _bus_dmamap_load_mbuf() converts cpu-relative addresses
to bus-relative addresses.

Spotted by John Gordon, on port-powerpc@.
 1.10 09-Apr-2003  matt Cleanup dmamap_sync a bit and add a few more comments. Add support for
cached physaddr's in mbufs.
 1.9 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.8 16-Mar-2003  matt Fix bus_dmamap_sync (add offset to ds->ds_addr when needed).
Add a set of parenthesis to PMAP_NC so it evaluates properly.
 1.7 15-Mar-2003  matt When mapping a page with BUS_SPACE_NOCACHE, make sure to flush the
physical page from the data cache.
 1.6 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.5 06-Feb-2003  matt Add a _bus_dmamap_sync which supports cache-incoherent implementations.
Support BUS_DMA_NOCACHE.
 1.4 25-Nov-2002  thorpej Avoid strict-alias warnings.
 1.3 02-Jun-2002  drochner move initialization of the "struct pglist" returned by uvm_pglistalloc()
from the calling code into uvm_pglistalloc() itself for consistency
and easier error handling
 1.2 10-Jun-2001  briggs branches: 1.2.2; 1.2.4; 1.2.10; 1.2.18;
Pull avail_start/avail_end logic for bus_dmamem_alloc() from macppc port,
as suggested by matt@netbsd.org--the vm_physmem array may not be in order.
 1.1 06-Jun-2001  matt Include a common bus.h and bus_dma.c that powerpc ports can use
if they so choose.
 1.2.18.1 15-Jul-2002  gehenna catch up with -current.
 1.2.10.3 11-Dec-2002  thorpej Sync with HEAD.
 1.2.10.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.10.1 10-Jun-2001  nathanw file bus_dma.c was added on branch nathanw_sa on 2002-06-20 03:40:34 +0000
 1.2.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.2.9 11-Dec-2005  christos Sync with head.
 1.15.2.8 01-Apr-2005  skrll Sync with HEAD.
 1.15.2.7 19-Feb-2005  skrll Don't deref a NULL struct lwp *. This shouldn't happen, but...
 1.15.2.6 18-Dec-2004  skrll Sync with HEAD.
 1.15.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.20.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.6.1 28-Jan-2005  yamt - don't leave page mapping at kva which is being freed.
- convert to new apis.
 1.20.4.1 29-Apr-2005  kent sync with -current
 1.22.8.1 29-Nov-2005  yamt sync with head.
 1.22.2.4 04-Feb-2008  yamt sync with head.
 1.22.2.3 03-Sep-2007  yamt sync with head.
 1.22.2.2 30-Dec-2006  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.25.6.1 22-Apr-2006  simonb Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.25.2.1 18-Feb-2006  yamt adapt the rest of MD code.
 1.26.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.26.2.2 14-Sep-2006  yamt sync with head.
 1.26.2.1 13-Mar-2006  yamt sync with head.
 1.27.10.1 18-Nov-2006  ad Sync with head.
 1.28.2.1 10-Dec-2006  yamt sync with head.
 1.29.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.30.20.1 23-Mar-2008  matt sync with HEAD
 1.31.10.3 11-Mar-2010  yamt sync with head
 1.31.10.2 04-May-2009  yamt sync with head.
 1.31.10.1 16-May-2008  yamt sync with head.
 1.31.8.2 17-Jun-2008  yamt sync with head.
 1.31.8.1 18-May-2008  yamt sync with head.
 1.31.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.20.1 07-Jan-2011  matt Add booke support.
 1.33.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.35.4.2 12-Jun-2011  rmind sync with head
 1.35.4.1 05-Mar-2011  rmind sync with head
 1.35.2.2 27-May-2010  uebayasi Fix build.
 1.35.2.1 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.37.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.44.6.1 18-Feb-2012  mrg merge to -current.
 1.44.2.1 17-Apr-2012  yamt sync with head
 1.46.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.46.24.1 05-Feb-2017  skrll Sync with HEAD
 1.46.6.1 03-Dec-2017  jdolecek update from HEAD
 1.47.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.47.14.1 02-May-2018  pgoyette Synch with HEAD
 1.48.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.2.1 10-Jun-2019  christos Sync with HEAD
 1.49.6.1 29-Feb-2020  ad Sync with head.
 1.49.4.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #730):

sys/arch/powerpc/conf/files.powerpc: revision 1.93
sys/arch/powerpc/include/pio.h: revision 1.8
sys/arch/powerpc/pic/intr.c: revision 1.27
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.50
sys/arch/powerpc/powerpc/pio_subr.S: revision 1.17

Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)

-

eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.55.4.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.39 10-Mar-2022  riastradh powerpc: Implement bus_space_barrier as eieio.
 1.38 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.37 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.36 09-Jul-2013  matt Fix typo (pa instead of va).
 1.35 11-Apr-2013  macallan branches: 1.35.4;
in memio_map() don't fail without trying to mapiodev() if we don't find a BAT
mapping or don't have BATs
now this works on G5
 1.34 18-Jul-2012  matt branches: 1.34.2;
Fix some boundary conditions (fence post errors).
 1.33 05-Jul-2012  kiyohara Don't call extent_free() in memio_unmap(), if not call extent_alloc() with
defined PPC_IBM4XX and extent_flags.
 1.32 01-Feb-2012  matt Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.31 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.30 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.29 17-Dec-2011  phx Allow defining a bus space with pbs_limit=0, which will have the effect to
create a space which ends with 0xffffffff.
This is needed, because pbs_limit=0xffffffff ends the space with 0xfffffffe.
 1.28 30-Jun-2011  matt branches: 1.28.2; 1.28.6;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.27 20-Jun-2011  matt Tidy up includes.
 1.26 05-Mar-2011  matt branches: 1.26.2;
Only call unmapiodev if va is non-zero.
 1.25 15-Feb-2011  macallan implement pmap_mmap_flags() and teach PowerPC's bus_space_mmap() to actually
use BUS_SPACE_MAP_PREFETCHABLE which, now that /dev/pci* knows how to use it,
helps improve X performance
 1.24 18-Jan-2011  matt branches: 1.24.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.23 06-Nov-2010  uebayasi branches: 1.23.2;
Machine dependent code is considered as part of UVM. Include
internal API header.
 1.22 18-Mar-2010  kiyohara Support PowerPC 405EX/EXr.
1. Add some new source and header files.
(MAL(split) and RGMII(new) relations for EMAC)
2. Create dcr4xx.h. Its moved from dcr405gp.h. Also remove dcr405xx.h.
3. intr.c supports MULTIUIC with virtual-irq. likes to oea.
support 32-virq/128-hwirq.
4. multiple emac support.
5. WALNUT and VIRTEX_* includes arch/powerpc/conf/files.ibm4xx.
6. WALNUT pci uses arch/powerpc/ibm4xx/pci/.
 1.21 25-Feb-2010  matt branches: 1.21.2;
Adapt to spr.h breakup.
 1.20 28-Apr-2008  martin branches: 1.20.20; 1.20.24;
Remove clause 3 and 4 from TNF licenses
 1.19 04-Mar-2008  mrg branches: 1.19.2; 1.19.4;
insert a .WAIT between include and include/foo subdirs, so that
include/ is created before include/foo.

fixes -j builds on ofppc for me.
 1.18 23-Feb-2008  matt Use BAT_VA2IDX()
 1.17 07-Feb-2008  garbled branches: 1.17.2; 1.17.6;
Code to disable BAT use on cpu's that either don't have BAT's, or don't
gain any benefit from them. This nets a small speedup on the POWER3, and
is probably needed for POWER5, which might not emulate BATs like the 3 does.
Also, thanks to Matt Thomas, who suggested re-using alitrap rather than
writing a new dsinobattrap that would have looked remarkably identical
when finished.
 1.16 06-Feb-2008  garbled Some minor cleanup in the PPC_OEA601 code, and a fix for bridge-mode
cpus, which apparently still need the non-601 code to zap various
instructions into nops.
 1.15 05-Feb-2008  garbled Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.14 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.13 17-Oct-2007  garbled branches: 1.13.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 09-Apr-2007  garbled branches: 1.12.4; 1.12.12; 1.12.14; 1.12.16; 1.12.18;
Fix the other instance of SR601_PA_MATCH_P in this file (the unmap case) too.
 1.11 09-Apr-2007  garbled When testing if something from the iosrtable is valid, don't call
SR601_PA_MATCH_P(), because that macro assumes the io region you are
mapping lies within the 32-bit address space addressable by the CPU,
which might not allways be the case.
 1.10 04-Mar-2007  christos branches: 1.10.2; 1.10.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 31-Aug-2006  freza branches: 1.9.8;
* move the "cheating" conditional into unmapiodev() implementation
itself (instead of memio_unmap()), as it differs between OEA and
ibm4xx.

OK by matt@
 1.8 31-Aug-2006  matt Call unmapiodev when unmapping bus_space to possibly reclaim the VA.
 1.7 05-Aug-2006  sanjayl 1st cut of Powermac G5 support (uses bridge mode).
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8;
merge ktrace-lwp.
 1.5 08-Jun-2004  kleink branches: 1.5.12;
Add MPC601 support.
 1.4 25-Jul-2003  scw Switch ibm4xx over to using the more flexible powerpc bus_space/bus_dma code.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 09-Apr-2003  matt branches: 1.2.2;
Add some debug printf's.
 1.1 15-Mar-2003  matt New generic powerpc bus_space framework.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.12.6 17-Mar-2008  yamt sync with head.
 1.5.12.5 27-Feb-2008  yamt sync with head.
 1.5.12.4 11-Feb-2008  yamt sync with head.
 1.5.12.3 27-Oct-2007  yamt sync with head.
 1.5.12.2 03-Sep-2007  yamt sync with head.
 1.5.12.1 30-Dec-2006  yamt sync with head.
 1.6.8.2 03-Sep-2006  yamt sync with head.
 1.6.8.1 11-Aug-2006  yamt sync with head
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.9.8.2 15-Apr-2007  yamt sync with head.
 1.9.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.4.1 11-Jul-2007  mjf Sync with head.
 1.10.2.2 23-Oct-2007  ad Sync with head.
 1.10.2.1 10-Apr-2007  ad Sync with head.
 1.12.18.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.16.1 18-Oct-2007  yamt sync with head.
 1.12.14.2 23-Mar-2008  matt sync with HEAD
 1.12.14.1 06-Nov-2007  matt sync with HEAD
 1.12.12.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.4.3 16-Oct-2007  garbled remove a #define DEBUG that got left in this file somehow
 1.12.4.2 02-Aug-2007  macallan bus_space_mmap() should honour pbs_offset
 1.12.4.1 02-Aug-2007  macallan bus addresses need to get the dtride treatment as well, not only sizes
 1.13.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.17.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.17.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.2.1 24-Mar-2008  keiichi sync with head.
 1.19.4.3 11-Aug-2010  yamt sync with head.
 1.19.4.2 11-Mar-2010  yamt sync with head
 1.19.4.1 16-May-2008  yamt sync with head.
 1.19.2.1 18-May-2008  yamt sync with head.
 1.20.24.1 07-Jan-2011  matt Add booke support.
 1.20.20.5 09-Nov-2010  uebayasi Sync with HEAD.
 1.20.20.4 09-Nov-2010  uebayasi Sync with HEAD.
 1.20.20.3 02-Nov-2010  uebayasi Drop the 'paddr_t avail_start' and 'paddr_t avail_end' arguments
from uvm_page_physload_device(9).

Those two arguments are used by uvm_page_physload(9) to specify a
range of physical memory available for general purpose pages (pages
which are linked to freelists). Totally irrelevant to device
segments.
 1.20.20.2 11-Aug-2010  uebayasi Support bus_space_physload(9) and friends.
 1.20.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.21.2.3 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.21.2.2 05-Mar-2011  rmind sync with head
 1.21.2.1 30-May-2010  rmind sync with head
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.26.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.28.6.1 18-Feb-2012  mrg merge to -current.
 1.28.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.28.2.2 30-Oct-2012  yamt sync with head
 1.28.2.1 17-Apr-2012  yamt sync with head
 1.34.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.2.1 23-Jun-2013  tls resync from head
 1.35.4.1 28-Aug-2013  rmind sync with head
 1.19 19-Oct-2024  jmcneill Improve delay() accuracy on Nintendo Wii.

The PowerPC delay() implementation converts the timebase frequency to
a number of nanoseconds per tick and uses that value to compute the
delay interval. On the Wii's Broadway processor with a timebase
frequency of 60.75 MHz, some precision is lost as each tick is
approximately 16.46 nanoseconds. The end result is that we sleep for
approximately 2.875% longer than necessary. This also has an impact
on CPU speed calculation on Broadway, which incorrectly reports itself
as 750MHz instead of 729MHz (2.875% faster).

Fix this by introducing an (optional) ticks_per_msec variable that can
be set by the platform and allows delay() to improve the accuracy of
longer delays.

Measured CPU frequency before this change:
[ 1.000000] cpu0: 750.00 MHz, 256KB WB with ECC L2 cache

Measured CPU frequency after this change:
[ 1.000000] cpu0: 729.00 MHz, 256KB WB with ECC L2 cache
 1.18 20-Jan-2024  jmcneill branches: 1.18.2;
powerpc: fix delay for large (> ~5sec) values

When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
 1.17 06-Jul-2020  rin branches: 1.17.20;
Include missing opt_ppcarch.h.
 1.16 18-Mar-2014  macallan > Can we use c99 field initializers here instead of comments?!?

Yes, yes we can.
 1.15 18-Mar-2014  macallan split 601 and generic PowerPC timecounter code a bit more
 1.14 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.13 25-Apr-2013  macallan branches: 1.13.4;
make delay() work with _ARCH_PPC64
 1.12 20-Jun-2011  matt branches: 1.12.2; 1.12.12;
cleanup includes (include <powerpc/psl.h explicitly)
 1.11 16-Jun-2011  macallan enable FAST_SOFTINTR support for all ports that use powerpc/pic/
This has been successfully tested on macppc
TODO:
- ibm4xx needs to be adapted
- SMP doesn't work yet, 2nd CPU crashes when trying to leave the idle loop
 1.10 18-Jan-2011  matt branches: 1.10.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.9 20-Dec-2010  matt branches: 1.9.2;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.8 24-Apr-2010  kiyohara Support 64-bit imask for powerpc/pic.
 1.7 25-Feb-2010  matt branches: 1.7.2;
Adapt to spr.h breakup.
 1.6 05-Feb-2008  garbled branches: 1.6.10; 1.6.30; 1.6.34;
Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.5 08-Jan-2008  joerg ANSIfy.
 1.4 17-Oct-2007  garbled branches: 1.4.2; 1.4.4; 1.4.10;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.3 28-May-1998  sakamoto branches: 1.3.28; 1.3.54; 1.3.56; 1.3.60; 1.3.62; 1.3.64;
Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 16-Apr-1997  thorpej Adjust for new machine_vec-based interrupt, from Wolfgang Solfrank.
 1.1 30-Sep-1996  ws PowerPC port
 1.3.64.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.62.1 18-Oct-2007  yamt sync with head.
 1.3.60.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.56.1 03-May-2007  garbled Add the new shared powerpc clock.c. Tested on prep. Based on the macppc
version which was based on the prep version.
 1.3.54.1 23-Oct-2007  ad Sync with head.
 1.3.28.3 11-Feb-2008  yamt sync with head.
 1.3.28.2 21-Jan-2008  yamt sync with head
 1.3.28.1 27-Oct-2007  yamt sync with head.
 1.4.10.1 08-Jan-2008  bouyer Sync with HEAD
 1.4.4.4 23-Mar-2008  matt sync with HEAD
 1.4.4.3 09-Jan-2008  matt sync with HEAD
 1.4.4.2 06-Nov-2007  matt sync with HEAD
 1.4.4.1 17-Oct-2007  matt file clock.c was added on branch matt-armv6 on 2007-11-06 23:20:59 +0000
 1.4.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.34.1 07-Jan-2011  matt Add booke support
 1.6.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.10.2 11-Aug-2010  yamt sync with head.
 1.6.10.1 11-Mar-2010  yamt sync with head
 1.7.2.2 05-Mar-2011  rmind sync with head
 1.7.2.1 30-May-2010  rmind sync with head
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.12.1 23-Jun-2013  tls resync from head
 1.12.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.4.1 18-May-2014  rmind sync with head
 1.17.20.2 26-Oct-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #986):

sys/arch/evbppc/wii/machdep.c: revision 1.8
sys/arch/powerpc/powerpc/clock.c: revision 1.19

Improve delay() accuracy on Nintendo Wii.

The PowerPC delay() implementation converts the timebase frequency to
a number of nanoseconds per tick and uses that value to compute the
delay interval. On the Wii's Broadway processor with a timebase
frequency of 60.75 MHz, some precision is lost as each tick is
approximately 16.46 nanoseconds. The end result is that we sleep for
approximately 2.875% longer than necessary. This also has an impact
on CPU speed calculation on Broadway, which incorrectly reports itself
as 750MHz instead of 729MHz (2.875% faster).

Fix this by introducing an (optional) ticks_per_msec variable that can
be set by the platform and allows delay() to improve the accuracy of
longer delays.

Measured CPU frequency before this change:
[ 1.000000] cpu0: 750.00 MHz, 256KB WB with ECC L2 cache
Measured CPU frequency after this change:
[ 1.000000] cpu0: 729.00 MHz, 256KB WB with ECC L2 cache
 1.17.20.1 03-Feb-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #561):

etc/etc.evbppc/Makefile.inc: revision 1.15
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.2
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.3
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.2
distrib/utils/embedded/files/evbppc_wii_icon.png: revision 1.1
usr.sbin/sysinst/arch/evbppc/md.h: revision 1.4
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.4
sys/arch/evbppc/wii/dev/viio.h: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.5
sys/arch/evbppc/wii/dev/mainbus.h: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.2
distrib/utils/embedded/conf/wii.conf: revision 1.3
sys/dev/sdmmc/sdhcvar.h: revision 1.34
sys/dev/sdmmc/sdhc.c: revision 1.118
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.1
distrib/utils/embedded/conf/evbppc.conf: revision 1.1
sys/dev/wsfb/genfb.c: revision 1.91
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.2
sys/dev/wscons/wsconsio.h: revision 1.127
sys/arch/powerpc/oea/oea_machdep.c: revision 1.85
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.1
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.2
sys/arch/evbppc/conf/std.wii: revision 1.3
sys/arch/powerpc/oea/cpu_subr.c: revision 1.109
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.1
sys/dev/usb/usb.h: revision 1.124
sys/arch/evbppc/wii/machdep.c: revision 1.1
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.1
sys/arch/powerpc/include/oea/hid.h: revision 1.14
sys/arch/evbppc/wii/mainbus.c: revision 1.1
sys/arch/evbppc/wii/machdep.c: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.1
sys/arch/evbppc/wii/mainbus.c: revision 1.2
sys/arch/evbppc/wii/machdep.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.2
sys/arch/evbppc/wii/mainbus.c: revision 1.3
sys/arch/evbppc/wii/machdep.c: revision 1.4
sys/arch/evbppc/wii/dev/hwgpio.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.2
sys/arch/evbppc/wii/wii_locore.S: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.1
sys/arch/evbppc/wii/wii_locore.S: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.2
sys/arch/evbppc/wii/dev/exi.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.2
sys/arch/evbppc/conf/files.wii: revision 1.3
sys/arch/powerpc/powerpc/clock.c: revision 1.18
sys/arch/evbppc/include/wii.h: revision 1.3
sys/arch/evbppc/conf/files.wii: revision 1.4
sys/arch/evbppc/include/wii.h: revision 1.4
sys/arch/evbppc/wii/dev/exi.h: revision 1.1
sys/arch/evbppc/wii/dev/avenc.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.5
sys/arch/evbppc/include/wii.h: revision 1.6
sys/arch/evbppc/include/wii.h: revision 1.7
sys/arch/evbppc/wii/dev/avenc.h: revision 1.1
distrib/utils/embedded/mkimage: revision 1.79
sys/arch/evbppc/conf/WII: revision 1.1
sys/arch/evbppc/conf/INSTALL_WII: revision 1.1
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.1
sys/arch/evbppc/wii/dev/vireg.h: revision 1.1
sys/arch/evbppc/conf/WII: revision 1.2
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.2
sys/arch/evbppc/wii/dev/vireg.h: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.3
sys/arch/evbppc/conf/WII: revision 1.4
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.11
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.1
sys/dev/usb/ehcivar.h: revision 1.52
sys/arch/evbppc/wii/pic_pi.c: revision 1.1
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.2
etc/etc.evbppc/ttys: revision 1.8
sys/arch/evbppc/wii/dev/bwai.c: revision 1.1
sys/arch/evbppc/wii/dev/bwai.c: revision 1.2
sys/arch/evbppc/wii/dev/bwai.c: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.1
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.1
sys/arch/evbppc/wii/dev/bwai.h: revision 1.1
sys/arch/evbppc/wii/autoconf.c: revision 1.2
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.2

powerpc: oea: Fix prefetchable mappings
Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
powerpc: oea: Decode IBM750CL L2 cache information.
sdmmc: add support for optional delay after register write
wscons: Add HOLLYWOOD display and YUY2 pixel format types
wsfb: add support for optional "devcmap" property
A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.
ehci: add EHCIF_32BIT_ACCESS flag to force 32-bit MMIO
fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
powerpc: fix delay for large (> ~5sec) values
When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
usb: increase USB_PORT_RESET_RECOVERY from 10ms to 20ms
I changed this from 250ms to 10ms back in 2021 based on a similar FreeBSD
change, but it seems to be a bit too aggressive for some platforms.
evbppc: Add initial support for the Nintendo Wii
wii: support RB_POWERDOWN
build fix: use dd with count=1 for compat with NetBSD dd(1)
wii: Add NTSC 480p support.
In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.
wii: Add 128x48 icon to SD card image
wii: Fix a comment
wii: Add drivers for Broadway DSP and Audio interface.
0: [*] audio0 @ bwdsp0: Broadway DSP
playback: 16, 2ch, 48000Hz
record: unavailable
(P-) slinear_be 16/16, 2ch, { 48000 }
wii: Add screenblank support.
wii: Use screen dimming register for screen blanking.
wii: Add GPIO, I2C, and basic A/V encoder driver.
wii: Use A/V encoder volume controls instead of using a software filter.
wii: Simply DSP driver - no interrupt handler required.
wii: provide device names to intr_establish
wii$ intrctl list
interrupt id CPU0 device name(s)
pi irq 14 64769* hollywood0
hollywood irq 36 5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0
wii: Add support for passing boot options to the kernel.
wii: Add External interface bus and RTC support
wii: Remove objcopy after kernel build.
HBC will do the right thing.
Add wsvt25 entries (off by default) for ttyE0-ttyE3.
Add support for "PAL" (576i) mode on Wii.
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.23 19-Jun-2024  rin powerpc64: Provide dummy stubs for compat1[36]

as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
 1.22 13-Mar-2022  andvar branches: 1.22.4;
s/hander/handler/ and s/hader/header/ in comments and documentation.
 1.21 13-Dec-2011  kiyohara Remove white-spaces.
 1.20 20-Jun-2011  matt branches: 1.20.2; 1.20.6;
cleanup includes (include <powerpc/psl.h explicitly)
 1.19 16-Mar-2011  matt branches: 1.19.2;
Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.18 18-Jan-2011  matt 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.17 27-Nov-2009  rmind branches: 1.17.4; 1.17.6;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.16 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.15 21-Nov-2008  he Wrap include of opt* header with _KERNEL_OPT.
 1.14 24-Apr-2008  ad branches: 1.14.2; 1.14.4; 1.14.8; 1.14.10; 1.14.20;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.13 20-Dec-2007  dsl branches: 1.13.6; 1.13.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.12 09-Feb-2007  ad branches: 1.12.24; 1.12.32; 1.12.36;
Merge newlock2 to head.
 1.11 11-Dec-2005  christos branches: 1.11.20;
merge ktrace-lwp.
 1.10 14-Sep-2005  he We need <compat/sys/signal.h> and <compat/sys/signalvar.h> here
for native_sigset13_to_sigset, sigset13_t, and sigvec.
The includes in sparc's machdep.c is conditional on COMPAT_13, as is
the use of native_sigset13_to_sigset.
 1.9 15-Apr-2004  matt branches: 1.9.12;
Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.8 27-Sep-2003  matt ANSIfy.
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 03-Feb-2003  matt branches: 1.6.2;
Don't use trapframe in sigcontext. Instead define a new structure
utrapframe that fixed in size (and the same size as the trapframe
in NetBSD 1.5). This preserves binary compatibility for those programs
that dealt looked at sigcontexts.
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 25-Sep-2002  thorpej Don't include <sys/map.h>.
 1.3 28-May-2001  matt branches: 1.3.2; 1.3.8;
Use structure assignment instead of bcopy.
 1.2 22-Dec-2000  jdolecek branches: 1.2.2;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.1 13-Sep-1998  thorpej branches: 1.1.12;
Make signal delivery work again.
 1.1.12.1 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.8.5 18-Oct-2002  nathanw Catch up to -current.
 1.3.8.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.3.8.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.3.8.1 28-May-2001  briggs file compat_13_machdep.c was added on branch nathanw_sa on 2001-11-05 19:46:17 +0000
 1.3.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.12.3 21-Jan-2008  yamt sync with head
 1.9.12.2 26-Feb-2007  yamt sync with head.
 1.9.12.1 21-Jun-2006  yamt sync with head.
 1.11.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.20.1 28-Jan-2007  ad powerpc changes.
 1.12.36.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.32.1 26-Dec-2007  ad Sync with head.
 1.12.24.1 09-Jan-2008  matt sync with HEAD
 1.13.8.1 18-May-2008  yamt sync with head.
 1.13.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.20.1 07-Jan-2011  matt Adapt to new trapframe.
 1.14.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.8.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.4.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

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

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

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

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

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

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.14.2.2 11-Mar-2010  yamt sync with head
 1.14.2.1 04-May-2009  yamt sync with head.
 1.17.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.4.2 21-Apr-2011  rmind sync with head
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.20.6.1 18-Feb-2012  mrg merge to -current.
 1.20.2.1 17-Apr-2012  yamt sync with head
 1.22.4.1 22-Jun-2024  martin Pull up following revision(s) (requested by pgoyette in ticket #724):

sys/modules/compat_netbsd32_16/Makefile: revision 1.5
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.25
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.26
sys/modules/compat_16/Makefile: revision 1.3
sys/modules/compat_netbsd32_13/Makefile: revision 1.5
sys/modules/compat_16/Makefile: revision 1.4
sys/arch/sun2/sun2/genassym.cf: revision 1.17
sys/arch/sun2/sun2/enable.h: revision 1.5
sys/modules/compat_13/Makefile: revision 1.3
sys/modules/compat_13/Makefile: revision 1.4
sys/modules/compat_13/Makefile: revision 1.5
sys/arch/mips/mips/netbsd32_machdep_16.c: revision 1.8
sys/modules/Makefile.compat: revision 1.1
sys/arch/mips/mips/netbsd32_machdep_13.c: revision 1.4
share/mk/bsd.kmodule.mk: revision 1.86
sys/arch/aarch64/aarch64/netbsd32_machdep_16.c: revision 1.4
sys/arch/powerpc/powerpc/compat_13_machdep.c: revision 1.23
sys/arch/aarch64/aarch64/netbsd32_machdep_13.c: revision 1.4

Import AFLAGS to allow processing of assembler files in modules.
Prerequisite for kern/583346.

Introduce sys/modules/Makefile.compat and hook some compat_1[36]
machdep code into the modules. kern/58346

Ooops missed a source file!

Proteect #include of kernel options files with #ifdef _KERNEL_OPT

XXX Add to existing 10.0 and 9.0 tickets for kern/583346

Include required headers

Add required include for compat_16 machdep code

fix the m68k compat_13 build.

include Makefile.assym to generate assym.h.
use -I. and -x assembler-with-cpp to actually use cpp and find assym.h.
also apply m68k assym.h fix here as well as compat_13.

powerpc64: Provide dummy stubs for compat1[36]
as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
sun2/genassym.cf: Skip KERNBASE for _MODULE
as it is not a compile-time constant; see sun2/vmparam.h.

It should not be, and is not actually, used for modules.

PR kern/58346

sun2/enable.h: Fix -Wold-style-definition for WARNS=5 build as modules
Finally fix sun2 build for PR kern/58346
 1.26 19-Jun-2024  rin powerpc64: Provide dummy stubs for compat1[36]

as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
 1.25 17-Jun-2024  pgoyette Add required include for compat_16 machdep code
 1.24 27-May-2023  andvar fix word endings toin -> tion in comments.
 1.23 13-Mar-2022  andvar branches: 1.23.4;
s/hander/handler/ and s/hader/header/ in comments and documentation.
 1.22 30-Oct-2021  thorpej - In vec_restore_from_mcontext() and vec_save_to_mcontext(), allows the
mcontext argument to be NULL.
- In sendsig_sigcontext(), don't set PSL_VEC in the saved MSR; we can't
actually round-trip the AltiVec registers. At least get them saved
into the PCB by calling vec_save_to_mcontext() (with a NULL mcontext
argument).
- In compat_16_sys___sigreturn14(), call vec_restore_from_mcontext()
with a NULL mcontext argument, which will force any subsequent use
of AltiVec to re-load the AltiVec registers from the PCB.

This isn't ideal, but it's the best we can do with the limited capability
of sigcontext.

Fixes PR port-powerpc/56471.
 1.21 27-Oct-2021  thorpej Use the signal trampoline version constants from <sys/signal.h>.
 1.20 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.19 20-Jun-2011  matt cleanup includes (include <powerpc/psl.h explicitly)
 1.18 02-May-2011  matt branches: 1.18.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.17 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.16 18-Jan-2011  matt 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.15 14-Jan-2011  rmind branches: 1.15.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.14 27-Nov-2009  rmind branches: 1.14.4;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.13 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.12 21-Nov-2008  he Wrap includes of opt* headers with _KERNEL_OPT.
Adapt sendsig_sigcontext() to the new prototype, and compute sig
and code patterned after the sparc code.
 1.11 24-Apr-2008  ad branches: 1.11.2; 1.11.4; 1.11.8; 1.11.10; 1.11.20;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.10 20-Dec-2007  dsl branches: 1.10.6; 1.10.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.9 05-Mar-2007  tsutsui branches: 1.9.20; 1.9.28; 1.9.32;
Use (char *) cast on pointer arith.
 1.8 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 09-Feb-2007  ad branches: 1.7.2;
Merge newlock2 to head.
 1.6 11-Dec-2005  christos branches: 1.6.20;
merge ktrace-lwp.
 1.5 14-Sep-2005  he We need <compat/sys/signal.h> and <compat/sys/signalvar.h> here
for native_sigset13_to_sigset, sigset13_t, and sigvec.
The includes in sparc's machdep.c is conditional on COMPAT_13, as is
the use of native_sigset13_to_sigset.
 1.4 15-Apr-2004  matt branches: 1.4.2; 1.4.14;
Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.3 04-Apr-2004  matt Make sure that the SRR1 we pass to userland reflects PSL_FE0|PSL_FE1 even
if the lwp doesn't currently own the FPU. When returning, copy those bits
back to the PCB. (In case the user decided to the FP exception mode in the
signal handler).
 1.2 25-Sep-2003  matt Deal with the constification of ksiginfo_t and sigset_t in signalling.
 1.1 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.4.14.4 21-Jan-2008  yamt sync with head
 1.4.14.3 03-Sep-2007  yamt sync with head.
 1.4.14.2 26-Feb-2007  yamt sync with head.
 1.4.14.1 21-Jun-2006  yamt sync with head.
 1.4.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 15-Apr-2004  skrll file compat_16_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:39:37 +0000
 1.6.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.6.20.1 28-Jan-2007  ad powerpc changes.
 1.7.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.28.1 26-Dec-2007  ad Sync with head.
 1.9.20.1 09-Jan-2008  matt sync with HEAD
 1.10.8.1 18-May-2008  yamt sync with head.
 1.10.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.20.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.11.20.1 07-Jan-2011  matt Adapt to new trapframe.
 1.11.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.8.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.4.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

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

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

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

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

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

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.11.2.2 11-Mar-2010  yamt sync with head
 1.11.2.1 04-May-2009  yamt sync with head.
 1.14.4.3 31-May-2011  rmind sync with head
 1.14.4.2 21-Apr-2011  rmind sync with head
 1.14.4.1 05-Mar-2011  rmind sync with head
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.4.1 22-Jun-2024  martin Pull up following revision(s) (requested by pgoyette in ticket #724):

sys/modules/compat_netbsd32_16/Makefile: revision 1.5
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.25
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.26
sys/modules/compat_16/Makefile: revision 1.3
sys/modules/compat_netbsd32_13/Makefile: revision 1.5
sys/modules/compat_16/Makefile: revision 1.4
sys/arch/sun2/sun2/genassym.cf: revision 1.17
sys/arch/sun2/sun2/enable.h: revision 1.5
sys/modules/compat_13/Makefile: revision 1.3
sys/modules/compat_13/Makefile: revision 1.4
sys/modules/compat_13/Makefile: revision 1.5
sys/arch/mips/mips/netbsd32_machdep_16.c: revision 1.8
sys/modules/Makefile.compat: revision 1.1
sys/arch/mips/mips/netbsd32_machdep_13.c: revision 1.4
share/mk/bsd.kmodule.mk: revision 1.86
sys/arch/aarch64/aarch64/netbsd32_machdep_16.c: revision 1.4
sys/arch/powerpc/powerpc/compat_13_machdep.c: revision 1.23
sys/arch/aarch64/aarch64/netbsd32_machdep_13.c: revision 1.4

Import AFLAGS to allow processing of assembler files in modules.
Prerequisite for kern/583346.

Introduce sys/modules/Makefile.compat and hook some compat_1[36]
machdep code into the modules. kern/58346

Ooops missed a source file!

Proteect #include of kernel options files with #ifdef _KERNEL_OPT

XXX Add to existing 10.0 and 9.0 tickets for kern/583346

Include required headers

Add required include for compat_16 machdep code

fix the m68k compat_13 build.

include Makefile.assym to generate assym.h.
use -I. and -x assembler-with-cpp to actually use cpp and find assym.h.
also apply m68k assym.h fix here as well as compat_13.

powerpc64: Provide dummy stubs for compat1[36]
as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
sun2/genassym.cf: Skip KERNBASE for _MODULE
as it is not a compile-time constant; see sun2/vmparam.h.

It should not be, and is not actually, used for modules.

PR kern/58346

sun2/enable.h: Fix -Wold-style-definition for WARNS=5 build as modules
Finally fix sun2 build for PR kern/58346
 1.7 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.6 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.5 16-Oct-1997  christos fix chrtoblk declaration
 1.4 13-Oct-1997  explorer o Make usage of /dev/random dependant on
pseudo-device rnd # /dev/random and in-kernel generator
in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
that this code is derived in part from Ted Tyso's linux code.
 1.3 16-Apr-1997  thorpej branches: 1.3.4;
Add hooks for berkeley packet filter.
 1.2 16-Oct-1996  ws Indent properly
 1.1 30-Sep-1996  ws PowerPC port
 1.3.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4 24-Jul-2002  chs reimplement copy{in,out}str() similarly to copy{in,out}()
(instead of the old way of calling [fs]ubyte() in a loop).
 1.3 19-Feb-2000  chs branches: 1.3.8; 1.3.12; 1.3.20;
handle a NULL "done" pointer.
for the userspace versions, return EFAULT instead of EACCES
when the user address is bogus.
 1.2 10-Jan-1999  tsubai branches: 1.2.8;
Fix void * arithmetic.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.20.1 31-Aug-2002  gehenna catch up with -current.
 1.3.12.1 01-Aug-2002  nathanw Catch up to -current.
 1.3.8.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4 24-Jul-2002  chs reimplement copy{in,out}str() similarly to copy{in,out}()
(instead of the old way of calling [fs]ubyte() in a loop).
 1.3 19-Feb-2000  chs branches: 1.3.8; 1.3.12; 1.3.20;
handle a NULL "done" pointer.
for the userspace versions, return EFAULT instead of EACCES
when the user address is bogus.
 1.2 10-Jan-1999  tsubai branches: 1.2.8;
Fix void * arithmetic.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.20.1 31-Aug-2002  gehenna catch up with -current.
 1.3.12.1 01-Aug-2002  nathanw Catch up to -current.
 1.3.8.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7 30-Jun-2020  maxv Make copystr() a MI C function, part of libkern and shared on all
architectures.

Notes:

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

Could test on amd64 only, but should be fine.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Sep-2003  matt ANSIfy.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 08-Jun-2000  kleink branches: 1.3.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.2 19-Feb-2000  chs branches: 1.2.2;
handle a NULL "done" pointer.
for the userspace versions, return EFAULT instead of EACCES
when the user address is bogus.
 1.1 30-Sep-1996  ws branches: 1.1.28;
PowerPC port
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.26.1 03-Aug-2004  skrll Sync with HEAD
 1.11 06-Jul-2020  rin Drop unused opt_ppcarch.h.
 1.10 20-Nov-2019  pgoyette Move all non-emulation-specific coredump code into the coredump module,
and remove all #ifdef COREDUMP conditional compilation. Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
 1.9 01-Jan-2014  dsl branches: 1.9.30;
Change the type of the 'cookie' that holds the state of the core dump file
from 'void *' to the actual type 'struct coredump_iostate *'.
In most of the code the contents of the structure are still unknown.
This just stops the wrong type of pointer being passed to the 'void *'
parameter.
I hope I've found everything, amd64 GENERIC and i386 GENERIC & ALL compile.
 1.8 13-Jun-2011  matt branches: 1.8.2; 1.8.12; 1.8.16;
Deal with PCU state when performing coredumps. As the kernel moves each LWP
into LSSUSPENDED state, have that LWP save its PCU state for the coredump and
release its PCU status since its probably going to be exiting very soon.
Make pcu_save_all tolerate for being called for non-curlwp if that lwp belongs
to the same process, has a state of LSSUSPENDED, and no PCUs are in use.

Make the MD coredump code use pcu_save_all(l) since it'll need to save all
the PCU state anyways and can take advantage of the above tests.
 1.7 02-May-2011  matt branches: 1.7.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.6 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.5 18-Jan-2011  matt 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.4 21-Nov-2009  rmind branches: 1.4.4; 1.4.6;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.3 15-Aug-2009  matt Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for us.
 1.2 21-Nov-2008  he branches: 1.2.4; 1.2.6; 1.2.8; 1.2.12;
Wrap includes of opt* headers in _KERNEL_OPT.
 1.1 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.2.12.4 11-Mar-2010  yamt sync with head
 1.2.12.3 19-Aug-2009  yamt sync with head.
 1.2.12.2 04-May-2009  yamt sync with head.
 1.2.12.1 21-Nov-2008  yamt file core_machdep.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:44 +0000
 1.2.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.8.1 21-Nov-2008  skrll file core_machdep.c was added on branch nick-hppapmap on 2009-01-19 13:16:37 +0000
 1.2.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.6.1 21-Nov-2008  mjf file core_machdep.c was added on branch mjf-devfs2 on 2009-01-17 13:28:26 +0000
 1.2.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.4.1 21-Nov-2008  haad file core_machdep.c was added on branch haad-dm on 2008-12-13 01:13:24 +0000
 1.4.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.3 31-May-2011  rmind sync with head
 1.4.4.2 21-Apr-2011  rmind sync with head
 1.4.4.1 05-Mar-2011  rmind sync with head
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.16.1 18-May-2014  rmind sync with head
 1.8.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.10 17-Jan-2011  matt Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.9 13-Apr-2009  he branches: 1.9.4; 1.9.6;
Define _NOREGNAMES before including <machine/asm.h> so that the
assembler doesn't get confused.
 1.8 04-May-2008  martin branches: 1.8.8; 1.8.14;
Move to 2 clause TNF license
 1.7 14-Feb-2008  garbled branches: 1.7.6; 1.7.8; 1.7.10;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.6 11-Dec-2005  christos branches: 1.6.50; 1.6.56;
merge ktrace-lwp.
 1.5 25-Jul-2004  manu branches: 1.5.2; 1.5.14;
Added a simple bigcopy, from Srinivasa Kanduru
 1.4 08-Jul-2004  manu Fix semantic problems with commpage functions, by Wolfgang Solfrank
 1.3 08-Jul-2004  manu I copy/pasted the copyright notice from another file but I forgot to
change the name of the contributor: Wasabi Systems did not contribute
that file.
 1.2 06-Jul-2004  manu Assembly versions of commpage functions for Powerpc, by Peter Grehan.
bigcopy is still missing
gettimeofday is implemented as a system call, whereas on Darwin, it reads
the data from the commpage (the kernel updates it).
 1.1 03-Jul-2004  manu Move all the MD bits of commpage to a new file.
Map the comm page as RW in kernel (we want to modify it but not to execute it),
and RX in userland (no need to modify it but we want to execute it
 1.5.14.1 27-Feb-2008  yamt sync with head.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 25-Jul-2004  skrll file darwin_commpage_machdep.S was added on branch ktrace-lwp on 2004-08-03 10:39:37 +0000
 1.6.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.50.1 23-Mar-2008  matt sync with HEAD
 1.7.10.2 04-May-2009  yamt sync with head.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.4.2 31-May-2011  rmind sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.31 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.30 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.29 26-Feb-2011  kiyohara Include <uvm/uvm_extern.h>.
s/tf->/tf->tf_/.
 1.28 13-Apr-2009  he branches: 1.28.4; 1.28.6; 1.28.8;
Add the include of compat/darwin/darwin_types.h, so that this builds
again with COMPAT_DARWIN defined. Fix from KIYOHARA Takashi.
 1.27 18-Mar-2009  cegger bzero -> memset
 1.26 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.25 28-Apr-2008  martin branches: 1.25.2; 1.25.8; 1.25.14;
Remove clause 3 and 4 from TNF licenses
 1.24 20-Dec-2007  dsl branches: 1.24.6; 1.24.8; 1.24.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.23 17-Oct-2007  garbled branches: 1.23.4; 1.23.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.22 08-Jul-2007  pooka branches: 1.22.10;
Initialize the link context in a signal frame to the receiving lwp's
link context instead of NULL. Otherwise, if we got a signal while the
lwp had a link context set, the link context would be set to NULL upon
return from signal delivery.

christos@tech-kern: "I think you are right."
 1.21 25-Apr-2007  manu branches: 1.21.2;
Fix build
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 11-Dec-2005  christos branches: 1.19.26;
merge ktrace-lwp.
 1.18 03-Oct-2005  manu Fix COMPAT_DARWIN build. This closes PR#31336
 1.17 28-Jul-2004  manu branches: 1.17.12;
Empty shell for Darwin audit API
 1.16 07-Jul-2004  christos kill duplicate code.
 1.15 04-Jul-2004  manu MacOS X.3 introduces a new sigreturn for PowerPC, with a usercontext
versionning argument. For now we only implement the X.2 flavor.
 1.14 18-Apr-2004  matt Fix tpyo.
 1.13 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.12 16-Dec-2003  manu Enable SA_SIGINFO for COMPAT_DARWIN
 1.11 16-Dec-2003  manu GPR5 does not hold code, it holds the signal number (this is the first
argument to the signal handler). It's an extraordinary luck that test
programs worked so far.
 1.10 08-Oct-2003  thorpej Use ksi_signo and ksi_code accessor macros.
 1.9 30-Sep-2003  manu Build PowerPC again with _HAS_SIGINFO. Remove the ifdef on _HAS_SIGINFO
in the header file since all platforms supported by COMPAT_DARWIN now have it.
 1.8 27-Sep-2003  matt ANSIfy.
 1.7 10-Feb-2003  manu branches: 1.7.2;
Build again
 1.6 24-Jan-2003  manu Make the beast build again (but it is still probably broken)
 1.5 08-Dec-2002  manu branches: 1.5.2;
A working fork/vfork implementation. Darwin fork differs from our fork by
two ways:
- the child gets its pid as retval[0] (userland stub will turn it into a 0),
retval[1] is 1 and it is 0 in the parent.
- in the child, the fork syscall is successful, hence we must skip the next
instruction.
 1.4 08-Dec-2002  manu Introduce BSD system calls with alternate patch checking (in /emul) in
compat/common, so that they can be shared by several emulations, and use
them for Darwin.

This removes the ugly dependance on FreeBSD freebsd_file.c for COMPAT_DARWIN
 1.3 29-Nov-2002  manu Build the beast again after siginfo changes
 1.2 26-Nov-2002  manu Add signal delivery for the PowerPC. Everything is implemented except siginfo.
The stack layout is observed from stack dumps on Darwin, so it should be
very accurate.
 1.1 25-Nov-2002  manu Added an empty shell for signal delivery. Now we just have to fill the
machine dependant bits.
 1.5.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.5.2.1 08-Dec-2002  thorpej file darwin_machdep.c was added on branch nathanw_sa on 2002-12-11 06:11:44 +0000
 1.7.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.12.3 21-Jan-2008  yamt sync with head
 1.17.12.2 03-Sep-2007  yamt sync with head.
 1.17.12.1 21-Jun-2006  yamt sync with head.
 1.19.26.2 07-May-2007  yamt sync with head.
 1.19.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.4.1 11-Jul-2007  mjf Sync with head.
 1.20.2.2 15-Jul-2007  ad Sync with head.
 1.20.2.1 27-May-2007  ad Sync with head.
 1.21.2.2 03-Oct-2007  garbled Sync with HEAD
 1.21.2.1 02-Aug-2007  macallan sync with HEAD
 1.22.10.2 09-Jan-2008  matt sync with HEAD
 1.22.10.1 06-Nov-2007  matt sync with HEAD
 1.23.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.4.1 26-Dec-2007  ad Sync with head.
 1.24.10.2 04-May-2009  yamt sync with head.
 1.24.10.1 16-May-2008  yamt sync with head.
 1.24.8.1 18-May-2008  yamt sync with head.
 1.24.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.25.2.2 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

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

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.28.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.28.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.4.3 31-May-2011  rmind sync with head
 1.28.4.2 21-Apr-2011  rmind sync with head
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.31 12-Apr-2023  riastradh powerpc/ddb: Use db_read_bytes, not direct pointer access.

Mark some powerpc-variant ifdefs with XXX crash(8), not sure yet what
to do about them.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.30 12-Apr-2023  riastradh crash(8): Add powerpc support.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.29 06-Jul-2020  rin branches: 1.29.20;
Include missing opt_ppcarch.h.
 1.28 04-Jul-2013  joerg Don't use non-literal strings as format string.
 1.27 23-Mar-2012  matt branches: 1.27.2; 1.27.4;
Decode isel{lt,gt,eq}
 1.26 28-Jan-2010  phx branches: 1.26.12; 1.26.16; 1.26.18;
Fixed some more instructions and their operands.
Print the register-indirect operand with displacement in load/store
instructions as d(rN).
Conditional branches are printed with their simplified mnemonic (i.e.
beq instead of bc x,y). Also append the branch-prediction flag +/-i.
Print real labels for 16-bit branches instead of just an offset.
Use the simplified mnemonic cmpw and cmpd, and much more enhancements...
 1.25 28-Jan-2010  phx Reverted last commit for db_disasm.c and db_inteface.c.
Sorry, erroneously commited them...
 1.24 28-Jan-2010  phx Fixed typo: PPC_OEA64_BIRDGE -> PPC_OEA64_BRIDGE
 1.23 20-Feb-2008  phx branches: 1.23.10;
A few bug fixes, approved by garbled:
1. The 'S' operand field has to be swapped with the 'A' operand in the
output, as long as it is not a store-instruction. To achieve that, I
have introduced a new operand type Op_ST for the store instructions.
2. srawi has an immediate shift count as third operand, not a register.
3. extsh has only two operands, not three.
 1.22 21-Feb-2007  thorpej branches: 1.22.22;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.21 30-Oct-2006  garbled branches: 1.21.4;
Make these files compile with -Wextra -Wno-unused.
 1.20 11-Dec-2005  christos branches: 1.20.20; 1.20.22;
merge ktrace-lwp.
 1.19 02-Jun-2005  he branches: 1.19.2;
Adapt to now compiling with -Wcast-qual - char pointers initialized
to string constants now need to be "const char*".
 1.18 09-Jun-2004  kleink Print SPR 0x100 as VRSAVE on non-4xx.
 1.17 17-Aug-2003  chs lots-o-stuff:
- fix opcodes_base[10] to allow us to find "cmpli".
- fix "cmp" definition.
- add various missing SPRs.
- use the right bits for the "BI" operand.
- fix operand calculation for "rlwinm" and friends, and display
the operands in the same order as the manuals do.
- make the buffer bigger to avoid overflow.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 17-May-2003  he branches: 1.15.2;
In disasm_fields(), add a buffer length argument and keep track of
the remaining length of the buffer to use with the modified
db_symstr() interface. Also, convert to using snprintf() via some
local macros appending to the result buffer.
 1.14 22-Jan-2003  kleink Recognize %mq, and adjust disasm_fields() slightly to print it.
 1.13 25-Nov-2002  thorpej Statements after labels.
 1.12 05-Jan-2002  jhawk Print negative SIMM operands correctly; previously, negative numbers
were bogus.
 1.11 05-Jan-2002  jhawk Remove gratuitous ", " after the last opcode for SIMM and UIMM opcodes.
 1.10 05-Jan-2002  jhawk Print addresses symbolicly using the new ddb helper function, db_symstr().
This disassembler still needs a fair chunk of work.
 1.9 13-Jun-2001  simonb branches: 1.9.2; 1.9.8;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.8 12-Jun-2001  simonb Get the opcode mask right for almost all the Op_OE opcodes (only two were
correct).
 1.7 06-May-2001  simonb Fix spr and tbr register number extraction. tbr is untested, but is the
same format as spr and had the same mistake.
 1.6 06-May-2001  simonb Remove duplicate opcode.
 1.5 06-May-2001  simonb Fix a bunch of other typos.
 1.4 06-May-2001  simonb Fix typos in two instruction codes.
 1.3 06-Apr-2001  simonb Fix typo - s/dbcst/dcbst/.
 1.2 09-Jun-2000  kleink branches: 1.2.4;
Pull in missing headers for declarations, and add missing local function
declarations.
 1.1 27-Jan-1998  sakamoto branches: 1.1.14; 1.1.22;
Import DDB from OpenBSD/powerpc.
 1.1.22.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.14.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.9.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.9.8.3 28-Feb-2002  nathanw Catch up to -current.
 1.9.8.2 11-Jan-2002  nathanw More catchup.
 1.9.8.1 13-Jun-2001  nathanw file db_disasm.c was added on branch nathanw_sa on 2002-01-11 23:38:42 +0000
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.3 27-Feb-2008  yamt sync with head.
 1.19.2.2 26-Feb-2007  yamt sync with head.
 1.19.2.1 30-Dec-2006  yamt sync with head.
 1.20.22.1 10-Dec-2006  yamt sync with head.
 1.20.20.1 18-Nov-2006  ad Sync with head.
 1.21.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.22.1 23-Mar-2008  matt sync with HEAD
 1.23.10.1 11-Mar-2010  yamt sync with head
 1.26.18.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #244):
sys/arch/powerpc/powerpc/db_disasm.c: revision 1.27
Decode isel{lt,gt,eq}
 1.26.16.1 05-Apr-2012  mrg sync to latest -current.
 1.26.12.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.12.1 17-Apr-2012  yamt sync with head
 1.27.4.1 28-Aug-2013  rmind sync with head
 1.27.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.20.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #283):

usr.sbin/crash/arch/powerpc.c: revision 1.1
sys/arch/powerpc/powerpc/db_trace.c: revision 1.61
sys/arch/powerpc/powerpc/db_trace.c: revision 1.62
sys/arch/powerpc/powerpc/db_trace.c: revision 1.63
usr.sbin/crash/crash.c: revision 1.15
sys/arch/powerpc/powerpc/db_disasm.c: revision 1.30
sys/arch/powerpc/powerpc/db_disasm.c: revision 1.31
usr.sbin/crash/arch/generic.c: revision 1.2
usr.sbin/crash/Makefile: revision 1.47
usr.sbin/crash/arch/powerpc64.c: revision 1.1

crash(8): Add powerpc support.

powerpc/ddb: Use db_read_bytes, not direct pointer access.
Mark some powerpc-variant ifdefs with XXX crash(8), not sure yet what
to do about them.

powerpc/ddb: Fix one more load to use db_read_bytes.
Fix some typos in crash(8) comments too.
 1.61 08-Sep-2024  andvar juggle around DDB guarded blocks to make them consistent and make code
build with or without DDB/KGDB options enabled for powerpc.
 1.60 26-Oct-2022  riastradh branches: 1.60.8;
ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.
 1.59 12-Sep-2022  rin Make ibm4xx kernels compiled by clang.

As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...

No binary changes for GCC-compiled kernels.
 1.58 10-Nov-2021  msaitoh s/Reseting/Resetting/
 1.57 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.56 30-Mar-2021  rin branches: 1.56.2;
G/C misleading <evbppc/tlb.h>. Use <powerpc/ibm4xx/tlb.h> directly.
 1.55 23-Feb-2021  mrg branches: 1.55.2;
introduce DDB_END_CMD and replace more than 20 copies of the same
list of NULLs and 0. idea from rillig@.

all touched ports built, several booted.
 1.54 06-Jul-2020  rin branches: 1.54.2;
Style and cosmetic changes. No binary changes intended.
 1.53 23-Jan-2015  nonaka ddb MP support
 1.52 04-Jul-2013  joerg branches: 1.52.8;
One const is good enough.
 1.51 01-Aug-2012  matt branches: 1.51.2; 1.51.4;
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.50 01-Feb-2012  matt Need runtime checks for mach mmu command.
 1.49 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.48 13-Dec-2011  kiyohara Remove white-spaces.
 1.47 20-Jun-2011  matt branches: 1.47.2; 1.47.6;
cleanup includes (explicit inclusion of <powerpc/psl.h> or <powerpc/userret.h>)
 1.46 18-Jun-2011  matt Use <sys/foo.h> instead of <machine/foo.h> if such a file exists.
Don't assume <sys/cpu.h> includes <powerpc/subarch/cpu*.h>. Include it
explicitly.
 1.45 18-Jan-2011  matt branches: 1.45.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.44 25-Feb-2010  matt branches: 1.44.2; 1.44.4;
Adapt to spr.h breakup.
 1.43 28-Jan-2010  phx branches: 1.43.2;
New machine commands for PPC OEA:
bat: prints the BAT registers and translations
mmu: prints MMU registers (sdr1, sr0..15)
 1.42 28-Jan-2010  phx Reverted last commit for db_disasm.c and db_inteface.c.
Sorry, erroneously commited them...
 1.41 28-Jan-2010  phx Fixed typo: PPC_OEA64_BIRDGE -> PPC_OEA64_BRIDGE
 1.40 23-Jan-2010  mrg document powerpc ddb commands. PR#38307.
 1.39 17-Oct-2007  garbled branches: 1.39.20; 1.39.42;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.38 22-Sep-2007  martin branches: 1.38.2; 1.38.4;
Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.37 22-Feb-2007  matt branches: 1.37.4; 1.37.12; 1.37.20; 1.37.22;
More boolean_t -> bool lossage.
 1.36 24-Dec-2005  perry branches: 1.36.26;
bare asm -> __asm
 1.35 11-Dec-2005  christos merge ktrace-lwp.
 1.34 03-Jun-2005  scw branches: 1.34.2;
Appease -Wcast-qual for the IBM4XX case.
 1.33 17-Dec-2003  simonb Nuke register prefix for local variables, clean up indentation a little.
 1.32 09-Oct-2003  matt Add code to drop into DDB if you get a DSI fault on the current stack page.
 1.31 27-Sep-2003  matt ANSIfy.
 1.30 25-Sep-2003  matt Remove db_onpanic check.
 1.29 15-Jul-2003  lukem __KERNEL_RCSID()
 1.28 03-Feb-2003  matt branches: 1.28.2;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.27 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.26 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.25 04-Jan-2003  thorpej On the IBM 4xx, don't enter DDB on user mode traps. Fixes
port-powerpc/19662.

Some minor cleanup while here.
 1.24 20-Dec-2002  scw Use Software Single Stepping for now when PPC_IBM4xx is defined. The
existing hardware assisted method doesn't work on this cpu.

Also correct the "I_B" constant in db_machine.h.
 1.23 19-Dec-2002  scw Add a range check for the DCR address in db_ppc4xx_dcr().
 1.22 19-Dec-2002  scw Add a "machine dcr" command, for the IBM4XX case, which permits
reading/writing of the cpu's DCR registers.
 1.21 25-Nov-2002  thorpej Use tlbrelo and tlbrehi.
 1.20 13-May-2002  matt Nuke local extern label_t *db_recover; it's now in <ddb/db_extern.h>
 1.19 13-May-2002  matt Eliminate commons.
 1.18 22-Feb-2002  kleink Handle the 601's Run Mode/Trace Exception.
 1.17 06-Jan-2002  dbj add support for kgdb over zs
 1.16 30-Dec-2001  dbj allow ddb access to lr, ctr, cr and xer registers when not on PPC_IBM4XX
 1.15 27-Dec-2001  dbj fix single stepping and continuing from breakpoints in ddb
 1.14 24-Dec-2001  dbj revert revision 1.13
this turns single stepping back off since it doesn't correctly work
note that without single stepping, several things do not work as
expected, including continuing from interrupts
 1.13 23-Dec-2001  dbj restore msr on return from ddb, this allows single stepping
 1.12 22-Jul-2001  wiz branches: 1.12.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.11 22-Jun-2001  simonb branches: 1.11.2;
Add a db_active variable that indicates if a call to the debugger is
active. Seems to be required by the MI com driver nowadays.
 1.10 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.9 04-Feb-2001  briggs branches: 1.9.2;
Build with -Wall -Wetc.
 1.8 24-Nov-2000  tsubai When fatal trap occurs, enter DDB with trapframe rather than just "Debugger()".
 1.7 11-Jun-2000  tsubai Make this compile again.
 1.6 09-Jun-2000  kleink Pull in missing DDB headers.
 1.5 12-Oct-1999  jdolecek branches: 1.5.2; 1.5.8;
rename the MD Debugger() to cpu_Debugger()
add MI Debugger() which switches to console if wscons is used prior
to calling cpu_Debugger()
 1.4 31-Aug-1998  tsubai branches: 1.4.12;
vm_offset_t --> [pv]addr_t
 1.3 04-Jul-1998  jonathan defopt DDB.
 1.2 23-Feb-1998  mycroft Fix layout of powerpc_saved_state; copy in saved MSR.
 1.1 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.4.12.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.8.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.5.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.11.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.1 03-Aug-2001  lukem update to -current
 1.12.6.8 04-Jan-2003  thorpej Sync with HEAD.
 1.12.6.7 29-Dec-2002  thorpej Sync with HEAD.
 1.12.6.6 11-Dec-2002  thorpej Sync with HEAD.
 1.12.6.5 20-Jun-2002  nathanw Catch up to -current.
 1.12.6.4 28-Feb-2002  nathanw Catch up to -current.
 1.12.6.3 11-Jan-2002  nathanw More catchup.
 1.12.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.12.6.1 22-Jul-2001  nathanw file db_interface.c was added on branch nathanw_sa on 2002-01-08 00:27:11 +0000
 1.28.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.1 03-Aug-2004  skrll Sync with HEAD
 1.34.2.3 27-Oct-2007  yamt sync with head.
 1.34.2.2 26-Feb-2007  yamt sync with head.
 1.34.2.1 21-Jun-2006  yamt sync with head.
 1.36.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.37.22.1 06-Nov-2007  matt sync with HEAD
 1.37.20.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.37.20.1 02-Oct-2007  joerg Sync with HEAD.
 1.37.12.2 03-Oct-2007  garbled Sync with HEAD
 1.37.12.1 28-May-2007  freza Add KGDB support to evbppc/virtex port. From Jean-Francois Boudreault,
cosmetics by me.

While there, generalize virtex_console_tag() to virtex_bus_space_tag()
and fix one instance of yamt-idlelwp fallout (ci_need_resched renamed
to ci_want_resched).

XXX Only compile tested since my access to suitable Virtex HW is sporadic
XXX at best.
 1.37.4.2 23-Oct-2007  ad Sync with head.
 1.37.4.1 09-Oct-2007  ad Sync with head.
 1.38.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.38.2.1 18-Oct-2007  yamt sync with head.
 1.39.42.2 28-Jan-2011  matt If a CPU has HIGHBAT, then use them. We dynamically change dsitrap to
select between bats 4-7 when HIGHBAT is detected.
 1.39.42.1 07-Jan-2011  matt Add booke support
 1.39.20.1 11-Mar-2010  yamt sync with head
 1.43.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.44.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.44.2.1 05-Mar-2011  rmind sync with head
 1.45.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.47.6.1 18-Feb-2012  mrg merge to -current.
 1.47.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.47.2.2 30-Oct-2012  yamt sync with head
 1.47.2.1 17-Apr-2012  yamt sync with head
 1.51.4.1 28-Aug-2013  rmind sync with head
 1.51.2.2 03-Dec-2017  jdolecek update from HEAD
 1.51.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.8.1 06-Apr-2015  skrll Sync with HEAD
 1.54.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.55.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.56.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.60.8.1 02-Aug-2025  perseant Sync with HEAD
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 02-Jun-2005  matt constify and adapt for newly enabled warnings.
 1.7 27-Sep-2003  matt ANSIfy.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 27-Dec-2001  dbj branches: 1.5.16;
sync the instruction cache even when only writing 2 or 4 bytes
 1.4 18-May-2001  matt branches: 1.4.2; 1.4.8;
Call __syncicache in db_write_bytes. (makes breakpoints work better).
 1.3 29-Jun-2000  mrg branches: 1.3.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 31-Aug-1998  tsubai branches: 1.2.12;
vm_offset_t --> [pv]addr_t
 1.1 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.2 08-Jan-2002  nathanw Catch up to -current.
 1.4.8.1 18-May-2001  nathanw file db_memrw.c was added on branch nathanw_sa on 2002-01-08 00:27:12 +0000
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.16.1 03-Aug-2004  skrll Sync with HEAD
 1.63 13-Apr-2023  riastradh powerpc/ddb: Fix one more load to use db_read_bytes.

Fix some typos in crash(8) comments too.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.62 12-Apr-2023  riastradh powerpc/ddb: Use db_read_bytes, not direct pointer access.

Mark some powerpc-variant ifdefs with XXX crash(8), not sure yet what
to do about them.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.61 12-Apr-2023  riastradh crash(8): Add powerpc support.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.60 06-Jul-2020  rin branches: 1.60.20;
Style and cosmetic changes. No binary changes intended.
 1.59 06-Jul-2020  rin db_stack_trace_print():
For ibm4xx, show fault address in dear register also for EXC_DTMISS.
 1.58 28-Feb-2018  mrg switch an assert in backtrace to an error return.
 1.57 13-Dec-2011  kiyohara Remove white-spaces.
 1.56 20-Jun-2011  matt branches: 1.56.2; 1.56.6;
cleanup includes (explicit inclusion of <powerpc/psl.h> or <powerpc/userret.h>)
 1.55 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.54 18-Jan-2011  matt branches: 1.54.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.53 14-Jan-2011  rmind branches: 1.53.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.52 01-Jul-2010  rmind Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

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

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

Fixes PR/43176.
 1.51 25-Feb-2010  matt branches: 1.51.2;
Adapt to spr.h breakup.
 1.50 21-Nov-2009  rmind branches: 1.50.2;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.49 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.48 02-Jul-2008  rmind branches: 1.48.18;
Remove proc_representative_lwp(), use a simple LIST_FIRST() instead.
OK by <ad>.
 1.47 05-Feb-2008  garbled branches: 1.47.6; 1.47.10; 1.47.12; 1.47.14;
Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.46 22-Feb-2007  thorpej branches: 1.46.22; 1.46.28;
TRUE -> true, FALSE -> false
 1.45 22-Feb-2007  matt More boolean_t -> bool lossage.
 1.44 21-Feb-2007  thorpej Pick up some additional files that were missed before due to conflicts
with newlock2 merge:

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

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

Reviewed by Andrew Doran.
 1.41 09-Feb-2007  ad branches: 1.41.2;
Merge newlock2 to head.
 1.40 30-Oct-2006  garbled Make these files compile with -Wextra -Wno-unused.
 1.39 06-Sep-2006  ad branches: 1.39.2; 1.39.4;
Use p_find(addr, PFIND_LOCKED) in case the proclist_lock is held.
 1.38 11-Dec-2005  christos branches: 1.38.4; 1.38.8;
merge ktrace-lwp.
 1.37 31-May-2005  chs branches: 1.37.2;
adapt to const changes.
 1.36 29-Mar-2004  simonb branches: 1.36.2;
Use "%#x" instead of "%x" so it's obvious the printed number is in hex.
 1.35 17-Dec-2003  simonb Nuke register prefix for local variables, clean up indentation a little.
 1.34 27-Sep-2003  matt ANSIfy.
 1.33 24-Aug-2003  chs remove bogus code that terminates stack trace too early on OEA.
 1.32 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.31 15-Jul-2003  lukem __KERNEL_RCSID()
 1.30 10-Jul-2003  matt Don't do vtophys on instruction addresses. This would cause problems for
user addresses (think trap from user mode) or lkms).
 1.29 09-Jul-2003  matt Enhance db_trace to understand syscalls and print the syscall number
that the user requested. For example:

0xd5c56f40: SC trap #240 by 0x15668c60: srr1=0xd032
r1=0xffffe470 cr=0x44000045 xer=0 ctr=0xeff27ab8
 1.28 02-Apr-2003  thorpej branches: 1.28.2;
Use PAGE_SIZE rather than NBPG.
 1.27 14-Mar-2003  matt Make ALI trap print DSISR.
 1.26 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.25 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.24 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.23 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.22 25-Nov-2002  thorpej Avoid a trigraph.
 1.21 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.20 13-May-2002  matt branches: 1.20.2;
Nuke local extern label_t *db_recover; it's now in <ddb/db_extern.h>
 1.19 15-Mar-2002  eeh Fixup distinguishing between user and kernel addresses for IBM 4xx CPUs.
 1.18 22-Feb-2002  kleink Handle the 601's Run Mode/Trace Exception.
 1.17 03-Jan-2002  jhawk Support
t/t PID
on the powerpc. (remember to use 0tPID if pid is in decimal...)
 1.16 31-Dec-2001  dbj handle have_address=TRUE
 1.15 30-Dec-2001  dbj allow ddb access to lr, ctr, cr and xer registers when not on PPC_IBM4XX
 1.14 30-Aug-2001  matt branches: 1.14.6;
Teach db_trace that some low addresses are ok to trace.
 1.13 17-Jun-2001  simonb branches: 1.13.2;
Make this compile and work for the IBM 4xx series CPUs.
 1.12 15-Jun-2001  matt Replace printf with (*pr)
 1.11 15-Jun-2001  matt Globalize trapexit. Improve db_trace.c so that you can trace thru traps!
Rework the output so that is also prints the frame address by default.
 1.10 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.9 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.8 29-Mar-2001  eeh Make `trace' useful even w/o symbols and add /f option to dump parameters.
 1.7 04-Feb-2001  briggs branches: 1.7.2;
Build with -Wall -Wetc.
 1.6 18-Jan-2001  jdolecek make db_[e]regs[] const
 1.5 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 26-May-2000  jhawk Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).

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

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

Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
 1.3 05-Mar-1999  tsubai branches: 1.3.8;
Add RSS accounting.
 1.2 23-Feb-1998  mycroft Fix layout of powerpc_saved_state; copy in saved MSR.
 1.1 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.3.8.3 21-Apr-2001  bouyer Sync with HEAD
 1.3.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.13.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.13.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.13.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.14.6.9 11-Dec-2002  thorpej Sync with HEAD.
 1.14.6.8 01-Aug-2002  nathanw Catch up to -current.
 1.14.6.7 20-Jun-2002  nathanw Catch up to -current.
 1.14.6.6 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.14.6.5 28-Feb-2002  nathanw Use proc_representative_lwp() instead of LIST_FIRST(&p->p_lwps) when
selecting a LWP for thread tracing.
XXX This doesn't affect t/t of single-LWP processes, but a better interface
XXX is needed to select a specific LWP of a multi-LWP process.
 1.14.6.4 28-Feb-2002  nathanw Catch up to -current.
 1.14.6.3 11-Jan-2002  nathanw More catchup.
 1.14.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.14.6.1 30-Aug-2001  nathanw file db_trace.c was added on branch nathanw_sa on 2002-01-08 00:27:12 +0000
 1.20.2.1 16-Jul-2002  gehenna catch up with -current.
 1.28.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.2.2 29-Mar-2004  simonb Use "%#x" instead of "%x" so it's obvious the printed number is in hex.
 1.36.2.1 29-Mar-2004  simonb file db_trace.c was added on branch netbsd-2-0 on 2004-03-29 01:12:02 +0000
 1.37.2.3 11-Feb-2008  yamt sync with head.
 1.37.2.2 26-Feb-2007  yamt sync with head.
 1.37.2.1 30-Dec-2006  yamt sync with head.
 1.38.8.1 14-Sep-2006  yamt sync with head.
 1.38.4.1 09-Sep-2006  rpaulo sync with head
 1.39.4.1 10-Dec-2006  yamt sync with head.
 1.39.2.2 18-Nov-2006  ad Sync with head.
 1.39.2.1 21-Oct-2006  ad Update for proc_representative_lwp() / calcru() signature change.
 1.41.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.46.28.1 18-Feb-2008  mjf Sync with HEAD.
 1.46.22.1 23-Mar-2008  matt sync with HEAD
 1.47.14.1 03-Jul-2008  simonb Sync with head.
 1.47.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.47.10.3 11-Aug-2010  yamt sync with head.
 1.47.10.2 11-Mar-2010  yamt sync with head
 1.47.10.1 04-May-2009  yamt sync with head.
 1.47.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.48.18.1 07-Jan-2011  matt Add booke support
 1.50.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.2.2 05-Mar-2011  rmind sync with head
 1.51.2.1 03-Jul-2010  rmind sync with head
 1.53.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.56.6.1 18-Feb-2012  mrg merge to -current.
 1.56.2.1 17-Apr-2012  yamt sync with head
 1.60.20.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #283):

usr.sbin/crash/arch/powerpc.c: revision 1.1
sys/arch/powerpc/powerpc/db_trace.c: revision 1.61
sys/arch/powerpc/powerpc/db_trace.c: revision 1.62
sys/arch/powerpc/powerpc/db_trace.c: revision 1.63
usr.sbin/crash/crash.c: revision 1.15
sys/arch/powerpc/powerpc/db_disasm.c: revision 1.30
sys/arch/powerpc/powerpc/db_disasm.c: revision 1.31
usr.sbin/crash/arch/generic.c: revision 1.2
usr.sbin/crash/Makefile: revision 1.47
usr.sbin/crash/arch/powerpc64.c: revision 1.1

crash(8): Add powerpc support.

powerpc/ddb: Use db_read_bytes, not direct pointer access.
Mark some powerpc-variant ifdefs with XXX crash(8), not sure yet what
to do about them.

powerpc/ddb: Fix one more load to use db_read_bytes.
Fix some typos in crash(8) comments too.
 1.4 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.3 02-Mar-1998  drochner Change MBR partition type for NetBSD to 0xa9, like the i386 port.
Provide compatibility via COMPAT_386BSD_MBRPART.
 1.2 26-Mar-1997  gwr Renames: /dumpconf/cpu_dumpconf/, /boot/cpu_reboot/
 1.1 30-Sep-1996  ws PowerPC port
 1.2 02-Jun-2022  rin As a tiny optimization, rearrange cases as follows:

(1) load/store of format D (base + disp)
(2) load/store of format X (base + index)
(3) lmw and stmw

For clang-compiled userland (*), their frequencies are roughly,
(1) > (2) >> (3) ~ 0.

Improvement should be minor; we are already trapped in the alignment
fault handler.

(*) clang unconditionally emits unaligned memory access for powerpc.
Undocumented -disable-ppc-unaligned option does not work...
 1.1 30-May-2022  rin Add routines to fix unaligned memory access for userland process.

Mainly intended for 403, which cannot handle unaligned memory access
at all (not only ones across page boundaries like 601).

For more details, see comments in fix_unaligned.c.
 1.13 01-Jan-2022  macallan more KASSERT vs. DIAGNOSTIC fallout
 1.12 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.11 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.10 02-Aug-2014  joerg Fix !DIAGNOSTIC build.
 1.9 01-Aug-2014  matt Deal with the code LLVM generates for stubs.
 1.8 03-Mar-2014  macallan branches: 1.8.2;
support ppc601
from scole_mail, ok matt@
 1.7 28-Feb-2014  matt Use register_t instead of int for register values.
 1.6 07-Nov-2013  nisimura move DIAGNOSTIC only variable inside #ifdef
 1.5 01-Jul-2011  matt branches: 1.5.2; 1.5.12; 1.5.16;
Change assert to panic.
 1.4 15-Jun-2011  matt Move booke_fixup_stubs() to fixup.c and rename it to cpu_fixup_stubs().
This makes it easier for other PPC variants to use it.
 1.3 12-Feb-2011  matt branches: 1.3.2; 1.3.4;
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 fixup.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.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 12-Feb-2011  rmind file fixup.c was added on branch rmind-uvmplock on 2011-03-05 20:51:40 +0000
 1.5.16.1 18-May-2014  rmind sync with head
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.2.1 10-Aug-2014  tls Rebase.
 1.42 15-Jul-2020  rin Expose fpu_get_fault_code() even if !PPC_HAVE_FPU, and
adjust it to systems without FPU.
 1.41 06-Jul-2020  rin Drop unused opt_multiprocessor.h includes.
 1.40 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.39 20-Feb-2020  rin Provide no-op's as pcu_ops_md_defs[PCU_FPU] even if !PPC_HAVE_FPU.

This is required by subr_pcu.c rev 1.21 and later:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_pcu.c#rev1.21

Otherwise, panic occurs when FP instruction is emulated on machines
without FPU.

Note that PowerPC UISA as well as SVR4 ABI require FP instructions,
and emulation is enabled unconditionally on machines without FPU.
 1.38 16-Mar-2017  chs branches: 1.38.14; 1.38.18; 1.38.20;
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.37 09-Mar-2017  chs use kpreempt_disable() rather than splsoftclock() to disable preemption.
 1.36 06-Jul-2015  matt branches: 1.36.2; 1.36.4;
Don't reload the FPU register if this is just a re-enable.
 1.35 16-May-2014  rmind branches: 1.35.2; 1.35.4;
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.34 23-Aug-2013  matt branches: 1.34.2;
Get rid of MDLWP_USED{FPU,VEC}
 1.33 22-Aug-2013  drochner -extend the pcu(9) API by a function which saves all context on the
current CPU, and use it if a CPU is taken offline
-add a bool argument to pcu_discard which tells whether the internal
"LWP has used the coprocessor" flag should be set or reset. The flag
is reported by pcu_used_p(). If set, future accesses should use the
state stored in the PCB. If reset, it should be reset to default.
The former case is useful for setmcontext().
With that, it should not be necessary anymore to manage the "FPU used"
state by an additional MD variable.

approved by matt
 1.32 26-Dec-2012  matt branches: 1.32.2;
Update to new pcu_state_{load,state,release} definitions
 1.31 07-Jun-2011  matt branches: 1.31.2; 1.31.8; 1.31.12;
zero PCU area when loading used area.
 1.30 07-Jun-2011  matt Switch alpha to use PCU to manage the FPU.
Tested by mhitch and review by rmind.
 1.29 02-May-2011  matt branches: 1.29.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.28 08-Feb-2011  matt Powerpc send_ipi use ci_cpuid, not cpu_index
 1.27 23-Jan-2011  matt Clear ownership bit after saving contents to PCB.
 1.26 18-Jan-2011  matt branches: 1.26.2;
Fix some fallout from building the macppc GENERIC.MP.
 1.25 18-Jan-2011  matt 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.24 14-Jan-2011  rmind branches: 1.24.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.23 27-Nov-2009  rmind branches: 1.23.4;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.22 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.21 08-Apr-2008  garbled branches: 1.21.4; 1.21.26;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.20 17-Oct-2007  garbled branches: 1.20.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.19 24-Dec-2005  perry branches: 1.19.30; 1.19.38; 1.19.48; 1.19.50; 1.19.52; 1.19.54;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.18 11-Dec-2005  christos merge ktrace-lwp.
 1.17 22-Feb-2005  matt branches: 1.17.4;
Don't clear PCB_FPU/PCB_ALTIVEC when releasing the FPU/AltiVec unit. Add
new flags to indicate whether the PCB currently owns the FPU/AltiVec unit.
 1.16 16-Apr-2004  matt branches: 1.16.4; 1.16.6;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.15 05-Apr-2004  simonb Fix tyop.
 1.14 04-Apr-2004  matt When trying to figure out which code to return, use the exception enable
bits to mask out the undesired exceptions. (Thanks to Todd Whitesel for
the idea).
 1.13 04-Apr-2004  matt Add SIGFPE handling code. Report the proper SIGINFO ksi_code when a SIGFPE
happens. When a SIGFPE occurs, disable the exception enables in the FPSCR.
 1.12 04-Apr-2004  matt Reformat the __asm a bit.
 1.11 27-Sep-2003  matt ANSIfy.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 14-Mar-2003  matt branches: 1.9.2;
Use __asm and __volatile to make lint happy.
 1.8 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.6 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.5 22-Jul-2001  wiz branches: 1.5.6; 1.5.14;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.4 22-Mar-2001  tsubai branches: 1.4.2;
Merge my MP tree. At this point, Daystar dual 604 card (i.e. Power Macintosh
9500/180MP and 9600/200MP) runs at least into single-user mode, possibly
multi-user mode (not stable yet).
 1.3 08-Jun-2000  kleink branches: 1.3.4;
Need <sys/systm.h> for declaration of bzero().
 1.2 07-Dec-1999  danw branches: 1.2.2;
Fix "FPCSR" to "FPSCR". ("Floating Point Status and Control Register")
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.34;
PowerPC port
 1.1.34.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.28.2 27-Mar-2001  bouyer Sync with HEAD.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.4.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.1 03-Aug-2001  lukem update to -current
 1.5.14.2 31-Aug-2002  gehenna catch up with -current.
 1.5.14.1 16-Jul-2002  gehenna catch up with -current.
 1.5.6.5 01-Aug-2002  nathanw LWPify
 1.5.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.6.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.5.6.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.5.6.1 22-Jul-2001  briggs file fpu.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.9.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.4.1 29-Apr-2005  kent sync with -current
 1.17.4.2 27-Oct-2007  yamt sync with head.
 1.17.4.1 21-Jun-2006  yamt sync with head.
 1.19.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.19.52.1 18-Oct-2007  yamt sync with head.
 1.19.50.1 06-Nov-2007  matt sync with HEAD
 1.19.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.19.38.1 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.19.30.1 23-Oct-2007  ad Sync with head.
 1.20.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.26.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.21.26.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.21.4.1 11-Mar-2010  yamt sync with head
 1.23.4.3 12-Jun-2011  rmind sync with head
 1.23.4.2 31-May-2011  rmind sync with head
 1.23.4.1 05-Mar-2011  rmind sync with head
 1.24.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.29.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.31.12.3 03-Dec-2017  jdolecek update from HEAD
 1.31.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.12.1 25-Feb-2013  tls resync with head
 1.31.8.3 19-Nov-2015  bouyer Revert ticket 1310 (second try):
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.31.8.2 16-Nov-2015  bouyer Revert ticket 1310:
> sys/arch/powerpc/include/psl.h 1.20
> sys/arch/powerpc/include/userret.h 1.29, 1.30
> sys/arch/powerpc/oea/altivec.c 1.30
> sys/arch/powerpc/oea/oea_machdep.c 1.72
> sys/arch/powerpc/powerpc/fpu.c 1.36
>
> powerpc PCU fixes

because it breaks the build:
http://releng.netbsd.org/builds/netbsd-6/201511152000Z/
 1.31.8.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by matt in ticket #1310):
sys/arch/powerpc/include/userret.h: revision 1.30
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revision 1.29
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/oea/altivec.c: revision 1.30
Add a check to make sure that if PSL_FP is set, we own the FPU.
Don't clear PSL_FP/PSL_VEC
Don't reload if just re-enabling
Don't reload the FPU register if this is just a re-enable.
Remove PSL_SPV from BOOKE PSL_USERMOD
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.31.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.31.2.1 23-Jan-2013  yamt sync with head
 1.32.2.2 18-May-2014  rmind sync with head
 1.32.2.1 28-Aug-2013  rmind sync with head
 1.34.2.1 10-Aug-2014  tls Rebase.
 1.35.4.2 28-Aug-2017  skrll Sync with HEAD
 1.35.4.1 22-Sep-2015  skrll Sync with HEAD
 1.35.2.1 17-Jul-2015  snj Pull up following revision(s) (requested by matt in ticket #868):
sys/arch/powerpc/include/psl.h: revision 1.20
sys/arch/powerpc/include/userret.h: revisions 1.29, 1.30
sys/arch/powerpc/oea/altivec.c: revision 1.30
sys/arch/powerpc/oea/oea_machdep.c: revision 1.72
sys/arch/powerpc/powerpc/fpu.c: revision 1.36
Add a check to make sure that if PSL_FP is set, we own the FPU.
--
Don't clear PSL_FP/PSL_VEC
--
Don't reload if just re-enabling
--
Don't reload the FPU register if this is just a re-enable.
--
Remove PSL_SPV from BOOKE PSL_USERMOD
--
Don't preserve PSL_FP/PSL_VEC in cpu_setmcontext.
 1.36.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.36.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.38.20.1 29-Feb-2020  ad Sync with head.
 1.38.18.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #733):

sys/arch/powerpc/powerpc/fpu.c: revision 1.39
sys/arch/powerpc/powerpc/powerpc_machdep.c: revision 1.77

Provide no-op's as pcu_ops_md_defs[PCU_FPU] even if !PPC_HAVE_FPU.

This is required by subr_pcu.c rev 1.21 and later:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_pcu.c#rev1.21

Otherwise, panic occurs when FP instruction is emulated on machines
without FPU.

Note that PowerPC UISA as well as SVR4 ABI require FP instructions,
and emulation is enabled unconditionally on machines without FPU.
 1.38.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 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 17-Jan-2011  matt branches: 1.1.2;
file fpu_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.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 18-Jan-2011  jruoho file fpu_subr.S was added on branch jruoho-x86intr on 2011-06-06 09:06:30 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file fpu_subr.S was added on branch rmind-uvmplock on 2011-03-05 20:51:41 +0000
 1.6 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.5 11-Dec-2005  christos branches: 1.5.166;
merge ktrace-lwp.
 1.4 27-Sep-2003  matt ANSIfy.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 08-Jun-2000  kleink branches: 1.2.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.166.1 10-Jun-2019  christos Sync with HEAD
 1.6 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.5 11-Dec-2005  christos branches: 1.5.166;
merge ktrace-lwp.
 1.4 27-Sep-2003  matt ANSIfy.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 08-Jun-2000  kleink branches: 1.2.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.166.1 10-Jun-2019  christos Sync with HEAD
 1.2 16-Apr-1997  thorpej Use genassym.sh to facilitate cross-compiling.
 1.1 30-Sep-1996  ws PowerPC port
 1.12 08-Jan-2020  ad Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
calling cpu_switchto(). It's not safe to let other actors mess with the
LWP (in particular l->l_cpu) while it's still context switching. This
removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead. Everything
is in cache anyway so it wasn't buying much by trying to avoid saving old
state. This means cpu_switchto() will never be called with prevlwp ==
NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
 1.11 23-Nov-2019  ad branches: 1.11.2;
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.10 30-Aug-2013  matt branches: 1.10.30;
Add CACHE_INFO_DCACHE_LINE_SIZE to assym.h
 1.9 01-Aug-2012  matt branches: 1.9.2; 1.9.4;
Add diagnostic code emptyidlespin verifying that the current IPL
is IPL_NONE and EE is set in the MSR.
 1.8 20-Jun-2011  matt branches: 1.8.2; 1.8.4;
If this is a MODULAR kernel, export USRSTACK and CPU_MAXNUM as linker symbols
so modules can access them.
 1.7 18-Jun-2011  matt Make a common genassym.cf (powerpc/genassym.cf) and then
only put specific stuff in foo/genassym.cf
 1.6 12-Aug-2003  matt Remove this. The architecture specific ones are now used.
 1.5 19-Jan-2003  matt branches: 1.5.2;
Add CALLFRAMELEN and use it.
 1.4 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.3 19-May-2002  augustss Add CPU_CI symbol so that bzero.S actually compiles on ports other than walnut.
 1.2 29-Nov-2001  mjl branches: 1.2.8;
Need CACHELINESIZE for libkern memset.
 1.1 16-Apr-1997  thorpej branches: 1.1.36; 1.1.40;
Use genassym.sh to facilitate cross-compiling.
 1.1.40.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.40.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.40.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.1.36.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.36.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.1 30-May-2002  gehenna Catch up with -current.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.4.1 30-Oct-2012  yamt sync with head
 1.8.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.2.1 20-Jun-2011  cherry file genassym.cf was added on branch cherry-xenmp on 2011-06-23 14:19:34 +0000
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.2.1 17-Jan-2020  ad Sync with head.
 1.10 24-Dec-2005  perry __asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 15-Jul-2003  lukem branches: 1.7.16;
__KERNEL_RCSID()
 1.6 05-Aug-2002  enami branches: 1.6.6;
A cosmetic change.
 1.5 05-Aug-2002  enami - Care about carry bit when adding short value to force 4 byte boundary.
It may contain any 32 bit value there.
- Use correct instruction to clear carry bit.
- Don't use series of load with update instruction. It's slower.
 1.4 29-Jul-2002  itojun be friendly with gcc-3.1.1 -O2, which takes advantage of ANSI C
pointer aliasing rule (gcc optimization/7427). from tsubai, sync w/kame
 1.3 13-Jun-2001  simonb branches: 1.3.2; 1.3.8; 1.3.16; 1.3.18;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.2 08-Jun-2000  kleink branches: 1.2.4;
Need <netinet/in.h> for declaration.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.18.1 05-Aug-2002  lukem Pull up revision 1.5 (requested by enami in ticket #627):
- Care about carry bit when adding short value to force 4 byte boundary.
It may contain any 32 bit value there.
- Use correct instruction to clear carry bit.
- Don't use series of load with update instruction. It's slower.
 1.3.16.1 31-Aug-2002  gehenna catch up with -current.
 1.3.8.3 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.3.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.3.8.1 13-Jun-2001  nathanw file in_cksum.c was added on branch nathanw_sa on 2002-08-01 02:43:09 +0000
 1.3.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.7 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.6 06-Jul-2020  rin Make this compile without __HAVE_FAST_SOFTINTS for debug.
 1.5 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.4 29-Mar-2014  christos branches: 1.4.6; 1.4.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.3 29-Jun-2011  matt branches: 1.3.2; 1.3.4; 1.3.14; 1.3.18;
Add cpu_send_ipi stub
 1.2 15-Jun-2011  matt branches: 1.2.2;
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.1 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.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 15-Jun-2011  cherry file intr_stubs.c was added on branch cherry-xenmp on 2011-06-23 14:19:34 +0000
 1.3.18.1 18-May-2014  rmind sync with head
 1.3.14.2 03-Dec-2017  jdolecek update from HEAD
 1.3.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.3.2.1 29-Jun-2011  matt file intr_stubs.c was added on branch matt-nb5-pq3 on 2011-10-14 17:21:26 +0000
 1.4.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.6.1 05-Dec-2016  skrll Sync with HEAD
 1.12 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.11 18-Jan-2011  matt branches: 1.11.56; 1.11.58;
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.10 14-Mar-2009  dsl branches: 1.10.4; 1.10.6;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 24-Jan-2007  hubertf branches: 1.9.48; 1.9.56; 1.9.62; 1.9.70;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.8 24-Dec-2005  perry branches: 1.8.20;
bare asm -> __asm
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 27-Sep-2003  matt branches: 1.6.16;
ANSIfy.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 06-Feb-2003  matt branches: 1.4.2;
Include vmparam.h to get USER_SR.
 1.3 23-Dec-2001  dbj add declaration of ipkdb_trap_glue
 1.2 16-Apr-1997  thorpej branches: 1.2.36; 1.2.40;
Update to ipkdb register handling, from Wolfgang Solfrank.
 1.1 17-Oct-1996  ws Forgot to "cvs add" this in the last:
Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.2.40.1 08-Jan-2002  nathanw Catch up to -current.
 1.2.36.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.2 26-Feb-2007  yamt sync with head.
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.8.20.1 01-Feb-2007  ad Sync with head.
 1.9.70.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.9.62.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.56.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.48.1 04-May-2009  yamt sync with head.
 1.10.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.11.58.1 10-Jun-2019  christos Sync with HEAD
 1.11.56.1 28-Jul-2018  pgoyette Sync with HEAD
 1.2 16-Oct-1996  ws Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.1 30-Sep-1996  ws PowerPC port
 1.26 08-Sep-2024  andvar include <machine/psl.h> for the PSL_DR definition (for KGDB enabled build only).
 1.25 24-Oct-2023  andvar branches: 1.25.6;
declare batl for PPC_OEA601 only, since it is unused by OEA or OEA64_BRIDGE.
 1.24 06-Jul-2020  rin - Drop unused opt_ddb.h.
- Include missing opt_ppcarch.h.
 1.23 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.22 02-Mar-2010  matt Add missing <powerpc/FOO/spr.h> to a few files missed on the first pass.
 1.21 11-Jan-2009  cegger branches: 1.21.4;
adaption for making kgdb_dev a dev_t
 1.20 05-Feb-2008  garbled branches: 1.20.6; 1.20.10; 1.20.18; 1.20.30;
Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.19 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.18 01-Feb-2007  freza branches: 1.18.24; 1.18.30;
Local variables bat{u,l} are only needed by OEA code, so ifdef them.
 1.17 01-Feb-2007  freza On ibm405 (which the true meaning of PPC_IBM4XX), anything outside
kernel VM range is supposed to be mapped via reserved TLB entries,
so allow such VAs through.

Fixes kgdb failure observed by Jean-Francois Boudreault on port-powerpc
(thanks for testing, too).
 1.16 05-Aug-2006  sanjayl branches: 1.16.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.15 24-Dec-2005  perry branches: 1.15.4; 1.15.8;
bare asm -> __asm
 1.14 11-Dec-2005  christos merge ktrace-lwp.
 1.13 23-Aug-2004  nathanw branches: 1.13.12;
Don't prohibit DDB and KGDB together.
 1.12 02-Aug-2004  uebayasi Fix an apparent syntax error.
 1.11 02-Mar-2004  kleink Pull in SPRs via <powerpc/spr.h> in this single instance, and dispose of
<machine/spr.h> again.
 1.10 30-Dec-2003  manu Fix PowerPC ports build with KGDB.
 1.9 20-Oct-2003  matt Reorganize the way powerpc port install machine specific headers.
Use <powerpc/oea/bat.h> exclusively and remove <machine/bat.h> and
<powerpc/bat.h>. Remove unneeded <machine/cpufunc.h>. To insure
1:1 correspondence of <powerpc/FOO.h> to <machine/FOO.h> include
"../../powerpc/include/Makefile" in "arch/FOO/include/Makefile".
Incororpate <byte_swap.h> into <bswap.h> and then byte_swap.h
 1.8 27-Sep-2003  matt ANSIfy.
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 03-Feb-2003  matt branches: 1.6.2;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.5 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.4 13-Jan-2003  augustss Make it compile on MPC6xx. I'm not sure about MPC40x.
 1.3 06-Jan-2002  dbj add support for kgdb over zs
 1.2 30-Dec-2001  dbj remove unused variable in kgdb_acc
 1.1 20-Jun-2001  briggs branches: 1.1.2; 1.1.8;
Build for kgdb as well as for ddb (mutually exclusive).
 1.1.8.5 15-Jan-2003  thorpej Sync with HEAD.
 1.1.8.4 28-Feb-2002  nathanw Catch up to -current.
 1.1.8.3 11-Jan-2002  nathanw More catchup.
 1.1.8.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.8.1 20-Jun-2001  nathanw file kgdb_machdep.c was added on branch nathanw_sa on 2002-01-08 00:27:12 +0000
 1.1.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.4 11-Feb-2008  yamt sync with head.
 1.13.12.3 26-Feb-2007  yamt sync with head.
 1.13.12.2 30-Dec-2006  yamt sync with head.
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.15.8.1 11-Aug-2006  yamt sync with head
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.16.4.1 09-Feb-2007  ad Sync with HEAD.
 1.18.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.24.1 23-Mar-2008  matt sync with HEAD
 1.20.30.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.20.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.10.2 11-Mar-2010  yamt sync with head
 1.20.10.1 04-May-2009  yamt sync with head.
 1.20.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.21.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.25.6.1 02-Aug-2025  perseant Sync with HEAD
 1.8 28-Apr-2023  skrll Pass local symbols relocations in both passes and provide the kobj_reloc
implementation visibility of these relocations.

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

Sent on tech-kern@.
 1.6 06-Mar-2014  matt Adapt to new elf_machdep.h
Add limited ELF64 support.
 1.5 08-Jun-2011  matt branches: 1.5.2; 1.5.12; 1.5.16;
Rework to support more relocations. Reorganize so code doesn't need to be
replicated over and over.
 1.4 25-Mar-2011  riz branches: 1.4.2;
Call __syncicache() when loading a kobj. Now I can load kernel modules
on my macppc with a ppc7400 without crashing.
 1.3 18-Jan-2010  jmmv branches: 1.3.4; 1.3.6;
Define kobj_machdep and module_init_md empty functions so that powerpc
kernels (at least macppc) with 'options MODULAR' can be built.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 04-Jan-2008  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18;
Linker stuff for powerpc.
 1.1.18.2 11-Mar-2010  yamt sync with head
 1.1.18.1 16-May-2008  yamt sync with head.
 1.1.16.1 18-May-2008  yamt sync with head.
 1.1.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 04-Jan-2008  mjf file kobj_machdep.c was added on branch mjf-devfs on 2008-02-18 21:04:59 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 04-Jan-2008  yamt file kobj_machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:38:28 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 04-Jan-2008  matt file kobj_machdep.c was added on branch matt-armv6 on 2008-01-09 01:47:56 +0000
 1.1.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 04-Jan-2008  bouyer file kobj_machdep.c was added on branch bouyer-xeni386 on 2008-01-08 22:10:19 +0000
 1.3.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.2 12-Jun-2011  rmind sync with head
 1.3.4.1 21-Apr-2011  rmind sync with head
 1.4.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.16.1 18-May-2014  rmind sync with head
 1.5.12.2 03-Dec-2017  jdolecek update from HEAD
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 15-Jul-2004  manu Remove an outdated comment.
 1.4 20-Jan-2003  matt branches: 1.4.2;
Kill all references to struct __gregs and use the _REG_xx names.
 1.3 19-Jan-2003  matt Improve sigcode.S template so linux_sigcode.S can use it as well. Add a
netbsd32_sigcode.S.
 1.2 11-Apr-2001  manu branches: 1.2.8;
Integrated security review for signal delivery by Wolfgang Solfrank
 1.1 19-Jan-2001  manu branches: 1.1.2; 1.1.4;
Added powerpc specific code for Linux compatibility on powerpc ports
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 19-Jan-2001  bouyer file linux_sigcode.S was added on branch thorpej_scsipi on 2001-02-11 19:11:36 +0000
 1.2.8.2 11-Apr-2001  manu Integrated security review for signal delivery by Wolfgang Solfrank
 1.2.8.1 11-Apr-2001  manu file linux_sigcode.S was added on branch nathanw_sa on 2001-04-11 19:41:03 +0000
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 03-Nov-2002  manu branches: 1.4.2; 1.4.110; 1.4.112; 1.4.114;
Added support for Darwin's PowerPC-only system calls:
ppccalls, with system call numbers starting at 0x6000
fasttraps, with system call numbers starting at 0x7FF0

Because the Mach system call dispatching code has grown a bit
too much, introduce an inline function to handle it (mach_syscall_dispatch).

While we are there, remove the Mach and Linux includes from
arch/powerpc/powerpc/syscall.c and push them into
arch/powerpc/powerpc/{mach|linux}_syscall.c
 1.3 30-Oct-2002  matt Move child_return back to syscall.c
Fix syscall to use emulations SYS_syscall/SYS___syscall definitions.
Use the emulation NSYSENT to limit code.
Don't define *syscall_fancy if it will never be used.
 1.2 30-Oct-2002  manu Fixed mistakes
 1.1 30-Oct-2002  manu Prepare syscall.c for COMPAT_MACH support. linux_syscall_intern is
moved to a Linux specific file, child_return is moved to trap.c,
and we introduce a EMULNAME macro co that syscall.c can be included to
define the system call handler for another emulation.
 1.4.114.1 16-May-2008  yamt sync with head.
 1.4.112.1 18-May-2008  yamt sync with head.
 1.4.110.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.2 11-Nov-2002  nathanw Catch up to -current
 1.4.2.1 03-Nov-2002  nathanw file linux_syscall.c was added on branch nathanw_sa on 2002-11-11 22:02:59 +0000
 1.10 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 09-Feb-2007  ad branches: 1.8.44; 1.8.46; 1.8.48;
Merge newlock2 to head.
 1.7 11-Dec-2005  christos branches: 1.7.20;
merge ktrace-lwp.
 1.6 26-Mar-2004  drochner branches: 1.6.16;
all ports define __HAVE_SIGINFO now, so remove the CPP conditionals
 1.5 25-Sep-2003  matt Deal with the constification of ksiginfo_t and sigset_t in signalling.
 1.4 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 18-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1 18-Jun-2001  christos branches: 1.1.2; 1.1.10;
Add a linux specific trapsignal() function. This is just a passthrough
on all platforms but the i386. On the i386 we look at T_PROTFLT and send
a SIGSEGV instead of SIGBUS. This makes allegro lisp 5.0 and pvs (a proof
verification system) to work.

XXX[1]: We need to go through each architecture and verify that we send
the correct signal on each trap type.
XXX[2]: trap.c on all other architectures but i386 needs to be modified
to s/trapsignal/(*p->p_emul->e_trapsignal)/g
 1.1.10.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.1.10.1 18-Jun-2001  briggs file linux_trap.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 26-Feb-2007  yamt sync with head.
 1.7.20.1 28-Jan-2007  ad powerpc changes.
 1.8.48.2 11-Mar-2010  yamt sync with head
 1.8.48.1 16-May-2008  yamt sync with head.
 1.8.46.1 18-May-2008  yamt sync with head.
 1.8.44.1 02-Jun-2008  mjf Sync with HEAD.
 1.14 06-Apr-2022  riastradh Nix trailing whitespace in files of membars, atomics, and lock stubs.

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

No functional change intended.
 1.13 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.12 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.11 21-Jan-2020  thorpej Update for changes to <sys/rwlock.h> -- owner field is now bits 5-N.
 1.10 28-Feb-2014  matt branches: 1.10.30; 1.10.34; 1.10.36;
Make 64-bit clean
 1.9 23-Sep-2012  mrg branches: 1.9.2;
correct some comments on #endif to match their #if.
 1.8 05-Jun-2011  matt branches: 1.8.2; 1.8.12;
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 17-Jan-2011  matt branches: 1.7.4;
Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.6 25-May-2008  chs branches: 1.6.20; 1.6.26;
enable profiling of assembly functions.
 1.5 28-Apr-2008  martin branches: 1.5.2;
Remove clause 3 and 4 from TNF licenses
 1.4 23-Feb-2008  matt branches: 1.4.2; 1.4.4;
Add rw_enter/rw_tryenter/rw_exit stubs (untested).
 1.3 14-Feb-2008  garbled branches: 1.3.2; 1.3.6;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.2 09-Feb-2007  ad branches: 1.2.4; 1.2.26; 1.2.32;
Merge newlock2 to head.
 1.1 28-Jan-2007  ad branches: 1.1.2;
file lock_stubs.S was initially added on branch newlock2.
 1.1.2.1 28-Jan-2007  ad powerpc changes.
 1.2.32.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.26.1 23-Mar-2008  matt sync with HEAD
 1.2.4.3 27-Feb-2008  yamt sync with head.
 1.2.4.2 26-Feb-2007  yamt sync with head.
 1.2.4.1 09-Feb-2007  yamt file lock_stubs.S was added on branch yamt-lazymbuf on 2007-02-26 09:07:55 +0000
 1.3.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.2.1 24-Mar-2008  keiichi sync with head.
 1.4.4.2 04-May-2009  yamt sync with head.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.2 04-Jun-2008  yamt sync with head
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.6.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.20.2 12-Jun-2011  rmind sync with head
 1.6.20.1 05-Mar-2011  rmind sync with head
 1.7.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.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.8.2.1 30-Oct-2012  yamt sync with head
 1.9.2.1 18-May-2014  rmind sync with head
 1.10.36.1 25-Jan-2020  ad Sync with head.
 1.10.34.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.10.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.6 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.5 08-Oct-1997  thorpej Fix a typo.
 1.4 29-Aug-1997  thorpej Fix typo(?) in dlmiss handler ("store" bit erronenously set). From
Kazuki Sakamoto <sakamoto@cec.co.jp>, PR #3583.
 1.3 16-Apr-1997  thorpej branches: 1.3.4;
Several changes from Wolfgang Solfrank, Charles Hannum, and myself:
- Clean up symbol goop - use macros in asm.h where appropriate.
- Add, correct, and generally clean up comments.
- Properly align save areas and temporary stacks.
- Fix the 603 tlb reload code.
- Fix several bogus constants and modifiers.
- Some stylistic changes.
 1.2 16-Oct-1996  ws Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.1 30-Sep-1996  ws PowerPC port
 1.3.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3 18-Jul-2003  matt Elimindate MD setrunqueue/remrunqueue (which were out-of-date compared to
the canonical versions in kern_synch.c). Define __HAVE_BITENDIAN_BITOPS
so the canonical versions will be used but will store priorities in the
desired (MSB) order for PowerPC (which allows the use of the cntlzw (count
leading zeroes, word) instruction in locore_subr.S to find the proper
priority).
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 08-May-2003  christos branches: 1.1.2;
rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.68 01-Mar-2023  riastradh powerpc: Optimization: Omit needless membar when triggering softint.

When we are triggering a softint, it can't already hold any mutexes.
So any path to mutex_exit(mtx) must go via mutex_enter(mtx), which is
always done with atomic r/m/w, and we need not issue any explicit
barrier between ci->ci_curlwp = softlwp and a potential load of
mtx->mtx_owner in mutex_exit.

PR kern/57240

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.67 23-Feb-2023  riastradh powerpc: Add missing barriers in cpu_switchto.

Details in comments.

PR kern/57240

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.66 16-Mar-2022  andvar branches: 1.66.4;
s/frmae/frame/
 1.65 06-Mar-2021  rin For ibm4xx and booke, restore saved PSL_EE bit as done for oea,
instead of forcibly enabling interrupts.
 1.64 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.63 06-Jul-2020  rin branches: 1.63.2;
Drop unused opt_lockdebug.h.
 1.62 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.61 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.60 25-Feb-2020  rin Comment out do_ucas_32(), only user of which, _ucas_32(), is commented out
since powerpc/trap.c rev 1.156:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.156
 1.59 08-Jan-2020  skrll oldlwp is always non-NULL in cpu_switchto so remove the test for NULL.
 1.58 08-Jan-2020  ad Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
calling cpu_switchto(). It's not safe to let other actors mess with the
LWP (in particular l->l_cpu) while it's still context switching. This
removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead. Everything
is in cache anyway so it wasn't buying much by trying to avoid saving old
state. This means cpu_switchto() will never be called with prevlwp ==
NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
 1.57 06-Apr-2019  thorpej branches: 1.57.4; 1.57.6;
Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.56 04-May-2018  macallan branches: 1.56.2;
when spinning up secondary CPUs, put them in bridge mode if the primary cpu is
 1.55 28-Feb-2017  chs branches: 1.55.6; 1.55.12;
in cpu_switchto() and the fast-softint context switch code,
put back the stwcx. instruction to clear the reservation.
we used to have this in the old cpu_switch() until it was
if-0'd in 2003 and removed completely in 2007.
this fixes hangs I've seen where a softint thread is
blocked waiting for a mutex that is not held.
this should also fix PR 44387.
 1.54 30-Jul-2014  matt branches: 1.54.2; 1.54.4; 1.54.8; 1.54.12;
Fix diagnostic trap to be correct. PSL_EE@l would be sign-extended and this
could never match the result of the andi. before it.
 1.53 30-Jul-2014  joerg Correct last, ha+l uses lis+addi, so use h+l.
 1.52 30-Jul-2014  joerg Build 32bit constant with lis+ori, not lis+addi. The instructions
differ on the sign extension handling of the immediate.
 1.51 29-Jul-2014  joerg Official PPC ISA documentation has no SP register, so use R1 directly.
 1.50 23-Aug-2013  matt branches: 1.50.2;
Simplify since we know curlwp is in %r13
 1.49 01-Aug-2012  matt branches: 1.49.2; 1.49.4;
Add diagnostic code emptyidlespin verifying that the current IPL
is IPL_NONE and EE is set in the MSR.
 1.48 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.47 13-Dec-2011  kiyohara Remove white-spaces.
 1.46 21-Jun-2011  matt branches: 1.46.2; 1.46.6;
remove a #if 0 block
 1.45 20-Jun-2011  matt If this is a MODULAR kernel, export USRSTACK and CPU_MAXNUM as linker symbols
so modules can access them.
 1.44 17-Jun-2011  matt Call splraise(IPL_HIGH) instead splhigh. Easier to a nasty problem.
 1.43 17-Jun-2011  matt USPRG0 is only on BOOKE
 1.42 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.41 18-Jan-2011  matt branches: 1.41.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.40 07-Jul-2010  chs branches: 1.40.2;
implement ucas_* for powerpc/oea.
 1.39 10-Dec-2009  rmind branches: 1.39.2; 1.39.4;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.38 07-Jun-2009  martin Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.37 10-Apr-2008  matt branches: 1.37.4; 1.37.14; 1.37.20;
On MP systems, make sure to update l->l_cpu with the cpu_info of the current
processor (in case it was running on a different processor before).
 1.36 08-Apr-2008  garbled SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.35 14-Feb-2008  garbled branches: 1.35.6;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.34 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.33 17-Oct-2007  garbled branches: 1.33.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.32 21-Jul-2007  matt branches: 1.32.4; 1.32.6; 1.32.8; 1.32.10;
Don't call proc_trampoline_mp when starting a lwp. (XXX why did we do this
before?)
 1.31 17-May-2007  yamt branches: 1.31.2; 1.31.4;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.30 09-Feb-2007  ad branches: 1.30.2; 1.30.6; 1.30.8; 1.30.14;
Merge newlock2 to head.
 1.29 05-Aug-2006  sanjayl branches: 1.29.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.28 11-Dec-2005  christos branches: 1.28.4; 1.28.8;
merge ktrace-lwp.
 1.27 19-Jan-2005  matt branches: 1.27.8;
Split the hw-dependent powermanglement into its own function and make
Idle call that. Add a ci_idlespin function pointer to cpu_info.
Update INIT_CPUINFO to initialize it to a naked 'blr' instruction.
In oea/cpu_subr.c, add cpu_idlespin and make ci_idlespin point to it.
 1.26 04-Dec-2004  matt branches: 1.26.4;
Make sure to enable interrupts before lower IPL so we don't block any
interrupts (IPI) we shouldn't.
 1.25 09-Jul-2004  matt Add some comments, clean things up so routines can be called from the
idle loop.
 1.24 21-Nov-2003  matt Restore ci_curpm since it re-enables 603 to working state.
 1.23 17-Oct-2003  matt Remove worthless load.
Save curcpu before doing uniprocessor dispatch.
 1.22 17-Oct-2003  matt Don't zero curlwp/curpcb in cpu_switchto.
Use correct register in the store conditional.
Add DIAGNOSTIC check for null curpcb on cpu_switch exit.
 1.21 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.20 27-Aug-2003  matt Move SFRAMELEN to frame.h and use it in vm_machdep.c. In setfunc, setup
callframe linkages correctly. Restore use of ldptr to locore_subr.S
[pthreads and gdb no longer crash/hang the system]
 1.19 27-Aug-2003  matt Switch back to adjusting stack by addi instead of ldptr until I can locate
who's setting up the stack wrong.
 1.18 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.17 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.16 11-Aug-2003  matt When getting the lwp to switch to, test to see if the scheduling queue is
empty, and if so panic. Change references to "proc/process" to lwp.
 1.15 04-Aug-2003  matt Eliminate stmw/lmw substituting the individual load/store instructions.
Use more symbolic constants. These are now safe for use on PPC64.
 1.14 31-Jul-2003  matt Switch to regiser prefixes. Also change numeric constants to symbolic ones.
 1.13 23-Jun-2003  martin branches: 1.13.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.12 12-Mar-2003  matt Same code exists in both halves in #ifdef/#else/#endif. move it outside.
 1.11 11-Mar-2003  hannken Add support for the IBM 403GCX cpu. Enabled with "options PPC_IBM403".

- different set of device control registers.
- non-standard access to the time base.
- 16 byte cache lines.

Approved by: Eduardo Horvath <eeh@netbsd.org>
 1.10 21-Feb-2003  matt witch from xor r,r,r to li r,0 to set a register to 0. It's clearer (and
better for G4 processors).
 1.9 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.8 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.7 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6 19-Dec-2002  thorpej Merge the IBM 4xx into the common powerpc/locore_subr.S, and
eliminate all the duplicated context switch related code in
the IBM 4xx port.
 1.5 28-Jul-2002  chs propagate the MP idle-loop fix to ppc from the other ports:

Move call to sched_unlock_idle to later in the context switch to
eliminate a race where another processor could grab the outgoing
process before we were done saving our state into it, with predictable
results.

Bug spotted by Frank van der Linden <fvdl@wasabisystems.com>

also, don't re-enable interrupts temporarily in the middle of
switching to a new process, just wait until we're completely switched.
this didn't work on MP and it's not worth the effort.
 1.4 16-Jul-2002  matt Add machdep.powerpc sysctl. Change the default value of powersave to -1
(< 0 mean no powersave available). Enable powersave by default for
750/7400/7410 but leave if off for 7450/7455.
 1.3 21-Jun-2002  matt Don't load the SR registers on a context switch. They get switched from
the user's SR registers to the kernel's SR registers on an exception or
interrupt from user level and restored with the user's SR register when the
exception or interrupt returns back to user level.
 1.2 28-Feb-2001  tsubai branches: 1.2.4; 1.2.6; 1.2.10; 1.2.18; 1.2.20;
Fix a bug in cpu_switch().
Reported by Tad Hunt <tad@entrisphere.com> on port-powerpc.
 1.1 25-Feb-2001  matt Get the ofppc/prep/macppc/sandpoint/bebox to share the process switch
/ setfault / fork_trampoline code.
 1.2.20.1 21-Jun-2002  lukem Pull up revision 1.3 (requested by matt in ticket #334):
Don't load the SR registers on a context switch. They get switched from
the user's SR registers to the kernel's SR registers on an exception or
interrupt from user level and restored with the user's SR register when the
exception or interrupt returns back to user level.
 1.2.18.3 31-Aug-2002  gehenna catch up with -current.
 1.2.18.2 21-Jul-2002  gehenna catch up with -current.
 1.2.18.1 16-Jul-2002  gehenna catch up with -current.
 1.2.10.10 05-Jan-2003  thorpej * Merge switch_exit() and switch_lwp_exit().
* Keep the stack 16-byte aligned; adjust by USPACE-16, not USPACE-20.
 1.2.10.9 31-Dec-2002  thorpej Rename cpu_preempt() to cpu_switchto(), and make the caller remove the
new process from its run queue before calling cpu_switchto().

While here, make a few cpu_switch() and cpu_switchto() implementations
get the outgoing LWP from the args, rather than looking at the curlwp
variable.
 1.2.10.8 19-Dec-2002  thorpej Add IBM 4xx case to cpu_preempt().
 1.2.10.7 19-Dec-2002  thorpej Sync with HEAD.
 1.2.10.6 01-Aug-2002  nathanw Catch up to -current.
 1.2.10.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.2.10.4 15-Nov-2001  briggs Update sched_whichqs properly in cpu_preempt().
Ensure cpu_preempt() stack hack keeps stack pointer 16-byte aligned.
Reduce code duplication by jumping from cpu_preempt() into cpu_switch()
to do post-new-lwp-selection work (thanks for the idea, thorpej).
 1.2.10.3 13-Nov-2001  briggs Improve upcall to better work with libpthread.
 1.2.10.2 08-Nov-2001  briggs Ensure cpu_preempt and cpu_switch both use the same amount of stack.
Go ahead and fill lwp->l_cpu with &cpu_info_store on !MULTIPROCESSOR.
 1.2.10.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.2.6.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 28-Feb-2001  bouyer file locore_subr.S was added on branch thorpej_scsipi on 2001-03-12 13:29:14 +0000
 1.13.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.13.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.26.4.1 29-Apr-2005  kent sync with -current
 1.27.8.6 27-Feb-2008  yamt sync with head.
 1.27.8.5 11-Feb-2008  yamt sync with head.
 1.27.8.4 27-Oct-2007  yamt sync with head.
 1.27.8.3 03-Sep-2007  yamt sync with head.
 1.27.8.2 26-Feb-2007  yamt sync with head.
 1.27.8.1 30-Dec-2006  yamt sync with head.
 1.28.8.1 11-Aug-2006  yamt sync with head
 1.28.4.1 09-Sep-2006  rpaulo sync with head
 1.29.4.2 30-Jan-2007  ad For now always call sched_unlock_idle/sched_lock_idle. They will be
removed by yamt's cpu_switchto() changes.
 1.29.4.1 28-Jan-2007  ad powerpc changes.
 1.30.14.5 11-Oct-2007  garbled Move a bunch of the macppc SMP code out of macppc, and down into the
generic OEA code. Add a set of md callbacks into these shared routines,
that any oeappc SMP machine needs to provide. This allows for generally
shared SMP startup code, but still allows for machine-specific
differences in the setup and kicking of the new CPU.

Convert macppc to this new layout. Tested by Macallan.

Add an initial attempt at SMP to prep. Tested on UP machine only,
untested on SMP yet.
 1.30.14.4 03-Oct-2007  garbled Sync with HEAD
 1.30.14.3 02-Aug-2007  macallan sync with HEAD
 1.30.14.2 22-May-2007  matt Update to HEAD.
 1.30.14.1 10-May-2007  garbled More cleanup:
1) Remove lcsplx, strayintr, and foosoft from all the converted ports.
None of this stuff is needed anymore.
2) because lcsplx is just "return spllower", just call spllower from
locore_subr.S instead.
3) Every port (except macppc) had a pretty similar cpu_configure(), so
take the common parts out and make a genppc_cpu_configure() in an attempt
to stop using imask[] outside of intr.c
 1.30.8.1 11-Jul-2007  mjf Sync with head.
 1.30.6.3 23-Oct-2007  ad Sync with head.
 1.30.6.2 20-Aug-2007  ad Sync with HEAD.
 1.30.6.1 27-May-2007  ad Sync with head.
 1.30.2.2 07-Apr-2007  matt Save curlwp in cpu_switchto
 1.30.2.1 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.31.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.31.2.1 07-Aug-2007  matt Sync with HEAD.
 1.32.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.32.8.1 18-Oct-2007  yamt sync with head.
 1.32.6.2 23-Mar-2008  matt sync with HEAD
 1.32.6.1 06-Nov-2007  matt sync with HEAD
 1.32.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.33.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.35.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.20.1 09-Jun-2009  snj branches: 1.37.20.1.2;
Pull up following revision(s) (requested by martin in ticket #801):
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.38
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.77
Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.37.20.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.37.14.1 09-Jun-2009  snj branches: 1.37.14.1.4;
Pull up following revision(s) (requested by martin in ticket #801):
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.38
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.77
Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.37.14.1.4.1 07-Jan-2011  matt Add fast softint support.
Add booke support.
 1.37.4.3 11-Aug-2010  yamt sync with head.
 1.37.4.2 11-Mar-2010  yamt sync with head
 1.37.4.1 20-Jun-2009  yamt sync with head
 1.39.4.2 12-Jun-2011  rmind sync with head
 1.39.4.1 05-Mar-2011  rmind sync with head
 1.39.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.40.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.41.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.46.6.2 24-Feb-2012  mrg sync to -current.
 1.46.6.1 18-Feb-2012  mrg merge to -current.
 1.46.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.2 30-Oct-2012  yamt sync with head
 1.46.2.1 17-Apr-2012  yamt sync with head
 1.49.4.1 28-Aug-2013  rmind sync with head
 1.49.2.2 03-Dec-2017  jdolecek update from HEAD
 1.49.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.2.1 10-Aug-2014  tls Rebase.
 1.54.12.1 21-Apr-2017  bouyer Sync with HEAD
 1.54.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.54.4.1 28-Aug-2017  skrll Sync with HEAD
 1.54.2.1 19-Apr-2017  snj Pull up following revision(s) (requested by phx in ticket #1382):
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.55
in cpu_switchto() and the fast-softint context switch code,
put back the stwcx. instruction to clear the reservation.
we used to have this in the old cpu_switch() until it was
if-0'd in 2003 and removed completely in 2007.
this fixes hangs I've seen where a softint thread is
blocked waiting for a mutex that is not held.
this should also fix PR 44387.
 1.55.12.1 21-May-2018  pgoyette Sync with HEAD
 1.55.6.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1859):

sys/arch/ia64/ia64/vm_machdep.c: revision 1.18
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.67
sys/arch/aarch64/aarch64/locore.S: revision 1.91
sys/arch/mips/include/asm.h: revision 1.74
sys/arch/hppa/include/cpu.h: revision 1.13
sys/arch/arm/arm/armv6_start.S: revision 1.38
(applied also to sys/arch/arm/cortex/a9_mpsubr.S,
sys/arch/arm/cortex/a9_mpsubr.S,
sys/arch/arm/cortex/cortex_init.S)
sys/arch/evbmips/ingenic/cpu_startup.S: revision 1.2
sys/arch/mips/mips/locore.S: revision 1.229
sys/arch/alpha/include/asm.h: revision 1.45
(applied to sys/arch/alpha/alpha/multiproc.s)
sys/arch/sparc64/sparc64/locore.s: revision 1.432
sys/arch/vax/vax/subr.S: revision 1.42
sys/arch/mips/mips/locore_mips3.S: revision 1.116
sys/arch/ia64/ia64/machdep.c: revision 1.44
sys/arch/arm/arm32/cpuswitch.S: revision 1.106
sys/arch/sparc/sparc/locore.s: revision 1.284
(all via patch)

aarch64: Add missing barriers in cpu_switchto.
Details in comments.

Note: This is a conservative change that inserts a barrier where
there was a comment saying none is needed, which is probably correct.
The goal of this change is to systematically add barriers to be
confident in correctness; subsequent changes may remove some bariers,
as an optimization, with an explanation of why each barrier is not
needed.

PR kern/57240

alpha: Add missing barriers in cpu_switchto.
Details in comments.

arm32: Add missing barriers in cpu_switchto.
Details in comments.

hppa: Add missing barriers in cpu_switchto.
Not sure hppa has ever had working MULTIPROCESSOR, so maybe no
pullups needed?

ia64: Add missing barriers in cpu_switchto.
(ia64 has never really worked, so no pullups needed, right?)

mips: Add missing barriers in cpu_switchto.
Details in comments.

powerpc: Add missing barriers in cpu_switchto.
Details in comments.

sparc: Add missing barriers in cpu_switchto.

sparc64: Add missing barriers in cpu_switchto.
Details in comments.

vax: Note where cpu_switchto needs barriers.

Not sure vax has ever had working MULTIPROCESSOR, though, and I'm not
even sure how to spell store-before-load barriers on VAX, so no
functional change for now.
 1.56.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.56.2.1 10-Jun-2019  christos Sync with HEAD
 1.57.6.2 29-Feb-2020  ad Sync with head.
 1.57.6.1 17-Jan-2020  ad Sync with head.
 1.57.4.3 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1676):

sys/arch/ia64/ia64/vm_machdep.c: revision 1.18
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.67
sys/arch/aarch64/aarch64/locore.S: revision 1.91
sys/arch/mips/include/asm.h: revision 1.74
sys/arch/hppa/include/cpu.h: revision 1.13
sys/arch/arm/arm/armv6_start.S: revision 1.38
sys/arch/evbmips/ingenic/cpu_startup.S: revision 1.2
sys/arch/mips/mips/locore.S: revision 1.229
sys/arch/aarch64/aarch64/cpuswitch.S: revision 1.40
sys/arch/alpha/include/asm.h: revision 1.45
sys/arch/sparc64/sparc64/locore.s: revision 1.432
sys/arch/vax/vax/subr.S: revision 1.42
sys/arch/mips/mips/locore_mips3.S: revision 1.116
sys/arch/ia64/ia64/machdep.c: revision 1.44
sys/arch/arm/arm32/cpuswitch.S: revision 1.106
sys/arch/sparc/sparc/locore.s: revision 1.284
(all via patch)

aarch64: Add missing barriers in cpu_switchto.
Details in comments.

Note: This is a conservative change that inserts a barrier where
there was a comment saying none is needed, which is probably correct.
The goal of this change is to systematically add barriers to be
confident in correctness; subsequent changes may remove some bariers,
as an optimization, with an explanation of why each barrier is not
needed.

PR kern/57240

alpha: Add missing barriers in cpu_switchto.
Details in comments.

arm32: Add missing barriers in cpu_switchto.
Details in comments.

hppa: Add missing barriers in cpu_switchto.
Not sure hppa has ever had working MULTIPROCESSOR, so maybe no
pullups needed?

ia64: Add missing barriers in cpu_switchto.
(ia64 has never really worked, so no pullups needed, right?)

mips: Add missing barriers in cpu_switchto.
Details in comments.

powerpc: Add missing barriers in cpu_switchto.
Details in comments.

sparc: Add missing barriers in cpu_switchto.

sparc64: Add missing barriers in cpu_switchto.
Details in comments.

vax: Note where cpu_switchto needs barriers.

Not sure vax has ever had working MULTIPROCESSOR, though, and I'm not
even sure how to spell store-before-load barriers on VAX, so no
functional change for now.
 1.57.4.2 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.57.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #737):

sys/arch/powerpc/powerpc/trap.c: revision 1.157
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.60

Comment out do_ucas_32(), only user of which, _ucas_32(), is commented out
since powerpc/trap.c rev 1.156:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.156
 1.63.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.66.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #264):

sys/arch/ia64/ia64/vm_machdep.c: revision 1.18
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.67
sys/arch/aarch64/aarch64/locore.S: revision 1.91
sys/arch/mips/include/asm.h: revision 1.74
sys/arch/hppa/include/cpu.h: revision 1.13
sys/arch/arm/arm/armv6_start.S: revision 1.38
sys/arch/evbmips/ingenic/cpu_startup.S: revision 1.2
sys/arch/mips/mips/locore.S: revision 1.229
sys/arch/aarch64/aarch64/cpuswitch.S: revision 1.40
sys/arch/alpha/include/asm.h: revision 1.45
sys/arch/sparc64/sparc64/locore.s: revision 1.432
sys/arch/vax/vax/subr.S: revision 1.42
sys/arch/mips/mips/locore_mips3.S: revision 1.116
sys/arch/riscv/riscv/cpu_switch.S: revision 1.3
sys/arch/ia64/ia64/machdep.c: revision 1.44
sys/arch/arm/arm32/cpuswitch.S: revision 1.106
sys/arch/sparc/sparc/locore.s: revision 1.284

aarch64: Add missing barriers in cpu_switchto.
Details in comments.

Note: This is a conservative change that inserts a barrier where
there was a comment saying none is needed, which is probably correct.
The goal of this change is to systematically add barriers to be
confident in correctness; subsequent changes may remove some bariers,
as an optimization, with an explanation of why each barrier is not
needed.

PR kern/57240

alpha: Add missing barriers in cpu_switchto.
Details in comments.

arm32: Add missing barriers in cpu_switchto.
Details in comments.

hppa: Add missing barriers in cpu_switchto.
Not sure hppa has ever had working MULTIPROCESSOR, so maybe no
pullups needed?

ia64: Add missing barriers in cpu_switchto.
(ia64 has never really worked, so no pullups needed, right?)

mips: Add missing barriers in cpu_switchto.
Details in comments.

powerpc: Add missing barriers in cpu_switchto.
Details in comments.

riscv: Add missing barriers in cpu_switchto.
Details in comments.

sparc: Add missing barriers in cpu_switchto.

sparc64: Add missing barriers in cpu_switchto.
Details in comments.

vax: Note where cpu_switchto needs barriers.

Not sure vax has ever had working MULTIPROCESSOR, though, and I'm not
even sure how to spell store-before-load barriers on VAX, so no
functional change for now.
 1.32 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.31 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.30 26-Feb-2011  kiyohara s/tf_tf_/tf_/.
 1.29 18-Jan-2011  matt branches: 1.29.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.28 21-Nov-2009  rmind branches: 1.28.4; 1.28.6;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.27 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.26 15-Oct-2008  wrstuden branches: 1.26.2; 1.26.8; 1.26.16;
Merge wrstuden-revivesa into HEAD.
 1.25 28-Apr-2008  martin branches: 1.25.2; 1.25.6;
Remove clause 3 and 4 from TNF licenses
 1.24 24-Apr-2008  ad branches: 1.24.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.23 09-Feb-2007  ad branches: 1.23.44; 1.23.46;
Merge newlock2 to head.
 1.22 15-Sep-2006  yamt merge yamt-pdpolicy branch.
- separate page replacement policy from the rest of kernel
- implement an alternative replacement policy
 1.21 11-Dec-2005  christos branches: 1.21.8; 1.21.20;
merge ktrace-lwp.
 1.20 14-Jul-2004  manu branches: 1.20.12;
Correctly set MSR static user bits on thread creation, as the calling
process might not have done it. This fixes crashes on thread creation.
 1.19 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.18 29-Nov-2003  manu Implement vm_read, vm_write, and a framework for vm_machine_attribute.
THe machine dependent bit nees to be written.
 1.17 11-Nov-2003  manu Added mach_thread_set_state
 1.16 11-Nov-2003  manu Implement mach_thread_get_state.
While we are here, try to tag machine dependent functions in header files.
also transformed darwin_ppc_*_state into mach_ppc_*_state, as this is
what they really are (COMPAT_DARWIN is on the top of COMPAT_MACH, not the
other way around)
 1.15 30-Sep-2003  manu Build PowerPC again with _HAS_SIGINFO. Remove the ifdef on _HAS_SIGINFO
in the header file since all platforms supported by COMPAT_DARWIN now have it.
 1.14 27-Sep-2003  matt ANSIfy.
 1.13 03-Feb-2003  matt branches: 1.13.2;
Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.12 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.11 26-Jan-2003  manu Remove right duplication on thread creation, which became useless now we
are using lwp.
Enable kill -9 to kill parent thread waiting for its child.
Use upcallret instead of child_return for the newly created lwp.
Add debug messages for thread creation.

Thread creation are still broken...
 1.10 21-Jan-2003  matt Do a preliminary switchover of the mach code to lwp's. It compiles now
but probably doesn't work. That's for someone who understand this code
better.
 1.9 08-Jan-2003  simonb Fix a tyop and some grammar.
 1.8 27-Dec-2002  manu Several things:
1) rights should be shared by the threads within a process. While it would
be easier to handle this with the struct proc/struct lwp split, we attempt to
do this now by sharing the right lists. Because each right holds a reference
to struct proc, this might cause some problems later.
2) in pthread_exit, really exit the thread. Also reintialize the righ tlist to
make sure we will not destroy the parent's right list
3) rights can hold multiple permissions on a port (ie: send and receive). Fix th
is.
4) first attempt on right carried by messages. We still have to do rights carrie
d in the message body (complex messages).
 1.7 12-Dec-2002  manu Bug fixes:
- In case of ailure in the child, kill the child and wakeup the parent
- Do call child_return
- The src and dst args were mixed up when copying regs 0-31 to the trapframe

This makes pthread_create(3) fully working (test program works).
 1.6 12-Dec-2002  manu Added a few Mach traps: mach_boostrap_register, mach_port_set_attributes,
mach_port_move_member, mach_port_set_attributes, mach_task_set_special_port,
(none do anything)
Added mach_thread_create_running, which creates a new Mach thread. It
provides the register context of the new thread. We use it in a child
function provided to fork1(). The child function is machine dependent and
is not yet implemented for i386.

The new thread crashes quickly, but at least it starts.
 1.5 17-Nov-2002  manu Correctly report the CPU type in Mach host_info(BASIC_INFO)
 1.4 16-Nov-2002  manu Implment map_fd mach trap
Fix host_info(BASIC_INFO) which was broken wrt to the number of field
returned.
 1.3 15-Nov-2002  manu Make it build again
 1.2 14-Nov-2002  christos get the cpu basic info.
 1.1 30-Oct-2002  manu branches: 1.1.2;
Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.1.2.6 15-Jan-2003  thorpej Sync with HEAD.
 1.1.2.5 29-Dec-2002  thorpej Sync with HEAD.
 1.1.2.4 19-Dec-2002  thorpej Sync with HEAD.
 1.1.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 30-Oct-2002  nathanw file mach_machdep.c was added on branch nathanw_sa on 2002-11-11 22:03:00 +0000
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.12.2 26-Feb-2007  yamt sync with head.
 1.20.12.1 30-Dec-2006  yamt sync with head.
 1.21.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.21.20.1 18-Nov-2006  ad Sync with head.
 1.21.8.1 05-Mar-2006  yamt separate page replacement policy from the rest of kernel.
 1.23.46.1 18-May-2008  yamt sync with head.
 1.23.44.2 17-Jan-2009  mjf Sync with HEAD.
 1.23.44.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.2.3 11-Mar-2010  yamt sync with head
 1.24.2.2 04-May-2009  yamt sync with head.
 1.24.2.1 16-May-2008  yamt sync with head.
 1.25.6.1 19-Oct-2008  haad Sync with HEAD.
 1.25.2.3 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.25.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.26.16.1 07-Jan-2011  matt More trapframe changes.
 1.26.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.28.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.4.3 31-May-2011  rmind sync with head
 1.28.4.2 21-Apr-2011  rmind sync with head
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.29.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.5 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.4 28-Apr-2008  martin branches: 1.4.22; 1.4.28;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.76; 1.3.78;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 30-Oct-2002  manu branches: 1.1.2; 1.1.8;
Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 30-Oct-2002  nathanw file mach_sigcode.S was added on branch nathanw_sa on 2002-11-11 22:03:01 +0000
 1.3.78.1 16-May-2008  yamt sync with head.
 1.3.76.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.22.1 31-May-2011  rmind sync with head
 1.10 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.9 28-Apr-2008  martin branches: 1.9.22; 1.9.28;
Remove clause 3 and 4 from TNF licenses
 1.8 11-Dec-2005  christos branches: 1.8.74; 1.8.76; 1.8.78;
merge ktrace-lwp.
 1.7 27-Sep-2003  matt ANSIfy.
 1.6 26-Nov-2002  manu branches: 1.6.6;
There is too much debugging, it's getting annoying. Let's remove some.
 1.5 13-Nov-2002  matt Change syscall to bound code so that systrace and ktrace won't fall off
the end of a table. XXX this is wrong since code does not indicate the
sysent table for which code was used as an index.
 1.4 04-Nov-2002  matt branches: 1.4.2;
Get rid of nsysent. Use EMULNAMEU to use the appropriate constant.
Revamp the mach_syscall_dispatch function to be much simplier (pass in
a syscall code and return a const struct sysent * pointer).
 1.3 03-Nov-2002  manu Added support for Darwin's PowerPC-only system calls:
ppccalls, with system call numbers starting at 0x6000
fasttraps, with system call numbers starting at 0x7FF0

Because the Mach system call dispatching code has grown a bit
too much, introduce an inline function to handle it (mach_syscall_dispatch).

While we are there, remove the Mach and Linux includes from
arch/powerpc/powerpc/syscall.c and push them into
arch/powerpc/powerpc/{mach|linux}_syscall.c
 1.2 30-Oct-2002  matt Move child_return back to syscall.c
Fix syscall to use emulations SYS_syscall/SYS___syscall definitions.
Use the emulation NSYSENT to limit code.
Don't define *syscall_fancy if it will never be used.
 1.1 30-Oct-2002  manu Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.4.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.4.2.2 11-Nov-2002  nathanw Catch up to -current
 1.4.2.1 04-Nov-2002  nathanw file mach_syscall.c was added on branch nathanw_sa on 2002-11-11 22:03:02 +0000
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.78.1 16-May-2008  yamt sync with head.
 1.8.76.1 18-May-2008  yamt sync with head.
 1.8.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.22.1 31-May-2011  rmind sync with head
 1.18 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.17 08-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.16 19-Feb-1998  thorpej Disable the message buffer during crash dumps by clearing msgbufenabled,
not msgbufmapped.
 1.15 02-Feb-1998  thorpej Rearrange slightly the way the debugger exception vectors are initialized.
 1.14 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.13 13-Nov-1997  veego s/NETHER/NARP/ and s/ether.h/arp.h/ for the 'new' arp system.
 1.12 12-Sep-1997  mycroft branches: 1.12.2;
Oops; didn't delete two retval[] usages in setregs().
 1.11 11-Sep-1997  mycroft Fix execve(2) and *setregs() interfaces so emulations can set registers in a
more correct way. (See tech-kern.)
 1.10 12-Jun-1997  mrg branches: 1.10.4; 1.10.6;
bring mrg-vm-swap2 onto mainilne.
 1.9 09-Jun-1997  veego Initialize machine from MACHINE and machine_arch from MACHINE_ARCH.
 1.8 06-Jun-1997  veego Add 'char machine_arch[] = "xxx";' for the new sysctl hw.machine_arch.
 1.7 16-Apr-1997  thorpej branches: 1.7.2;
Several changes from Wolfgang Solfrank, Charles Hannum, and myself:
- Make setregs() conform to the PowerPC SVR4 ABI, plus one NetBSD
extention (for ps_strings).
- machine == powerpc, not PowerPC.
- Set up machine vector for OpenFirmware.
- Nuke the msgbuf for now; it's not mapped correctly.
- Add missing casts in some asm() directives.
- Enable PSL_RI earlier, and do *not* disable it in fake_spl(), since it
is needed for page faults.
- Some general cleanup.
 1.6 27-Mar-1997  thorpej Don't allocate mclrefcnt[]; it's dead and gone.
 1.5 26-Mar-1997  gwr Renames: /dumpconf/cpu_dumpconf/, /boot/cpu_reboot/
 1.4 16-Oct-1996  ws branches: 1.4.4;
Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB
 1.3 13-Oct-1996  christos backout previous kprintf change
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 30-Sep-1996  ws PowerPC port
 1.4.4.1 12-Feb-1997  mrg don't allocate swap map in allocsys.
 1.7.2.1 04-May-1997  mrg re-merge mrg-vm-swap into -current, and call it mrg-vm-swap2.
 1.10.6.1 08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.10.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.2.1 15-Nov-1997  mellon Pull rev 1.13 up from trunk (veego)
 1.3 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.2 28-Apr-2008  martin branches: 1.2.22; 1.2.28;
Remove clause 3 and 4 from TNF licenses
 1.1 30-Oct-2002  manu branches: 1.1.2; 1.1.110; 1.1.112; 1.1.114;
Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.1.114.1 16-May-2008  yamt sync with head.
 1.1.112.1 18-May-2008  yamt sync with head.
 1.1.110.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 30-Oct-2002  nathanw file macho_machdep.c was added on branch nathanw_sa on 2002-11-11 22:03:02 +0000
 1.2.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.22.1 31-May-2011  rmind sync with head
 1.2 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.1 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.31 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.30 08-Feb-2011  rmind branches: 1.30.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.29 04-Mar-2007  christos branches: 1.29.40; 1.29.64; 1.29.66; 1.29.72; 1.29.74;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 24-Jan-2007  hubertf branches: 1.28.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.27 26-Dec-2006  elad Make machdep scope architecture-agnostic by removing all arch-specific
requests and centralizing them all. The result is that some of these
are not used on some architectures, but the documentation was updated
to reflect that.
 1.26 22-Dec-2006  elad Add requests indicating access to unmanaged memory for arm, pc532, powerpc,
sh3, sh5, and vax, and use them instead of KAUTH_GENERIC_ISSUSER.

Update documentation and example secmodel code.
 1.25 30-Oct-2006  garbled branches: 1.25.2;
Make these files compile with -Wextra -Wno-unused.
 1.24 25-Jul-2006  elad branches: 1.24.4; 1.24.6;
fix typoe; thanks ober
 1.23 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.22 14-May-2006  elad integrate kauth.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 27-Sep-2003  matt branches: 1.20.16;
ANSIfy.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

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

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

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

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

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.15 27-Feb-2002  kleink branches: 1.15.8;
Fix pastos & typoe.
 1.14 27-Feb-2002  christos - Use DEV_ constants, instead of documenting the numbers!
- Delete cdev_decl(mm); where appropriate, and other hand-crufting [hi powerpc!]
 1.13 30-Nov-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.12 30-Sep-2001  mycroft branches: 1.12.4;
Unlike most other platforms, PowerPC uses a 1:1 mapping for d_mmap and
pmap_phys_address()...
 1.11 29-Sep-2001  mycroft /dev/mem was severely broken. If you tried to access outside managed memory,
it would go into an infinite loop. Instead, allow such I/O.

Also, implement mmap(2) for /dev/mem.
 1.10 22-Jul-2001  wiz branches: 1.10.2;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.9 04-Feb-2001  briggs branches: 1.9.4;
Build with -Wall -Wetc.
 1.8 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.6 04-Dec-1999  ragge branches: 1.6.4;
CL* discarding.
 1.5 10-Feb-1999  kleink branches: 1.5.8; 1.5.14;
Use of casts as lvalues is a GNU C extension; rearrange slightly.
 1.4 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


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

by someone!
 1.3 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.2 07-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.1 30-Sep-1996  ws branches: 1.1.14;
PowerPC port
 1.1.14.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.5.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.5.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.9.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.9.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.4.1 03-Aug-2001  lukem update to -current
 1.10.2.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.10.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.12.4.8 11-Nov-2002  nathanw Catch up to -current
 1.12.4.7 17-Sep-2002  nathanw Catch up to -current.
 1.12.4.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.12.4.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.12.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.12.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.12.4.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.12.4.1 30-Sep-2001  briggs file mem.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.15.8.1 17-May-2002  gehenna Add the character device switch.
 1.17.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.6.1 03-Aug-2004  skrll Sync with HEAD
 1.20.16.4 03-Sep-2007  yamt sync with head.
 1.20.16.3 26-Feb-2007  yamt sync with head.
 1.20.16.2 30-Dec-2006  yamt sync with head.
 1.20.16.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.10.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.21.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.21.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

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

Work and depression still in progress.
 1.29.64.1 30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.29.40.1 29-Mar-2008  mjf Add a mem_init() function for each architecture that requests a device
node for /dev/mem, /dev/null, /dev/zero, etc.

This will disappear when I move this code (and others) to be a
pseudo-device. When we have machine-independent mem code this will all be
unnecessary anyway.
 1.30.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2 28-Feb-2014  matt Use the right file.
 1.1 19-Jan-2003  matt branches: 1.1.142; 1.1.152; 1.1.158;
Improve sigcode.S template so linux_sigcode.S can use it as well. Add a
netbsd32_sigcode.S.
 1.1.158.1 18-May-2014  rmind sync with head
 1.1.152.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.142.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.36 12-Dec-2022  martin Move the last remaining kernel printf to ofprint.
 1.35 10-Dec-2022  martin Move some output to DEBUG-only state
 1.34 10-Dec-2022  martin Convert more kernel printfs that might happen very early (before kernel
console is usable) to ofprint.
 1.33 24-Nov-2022  macallan in ofprint() only append \r if the last character is \n
 1.32 24-Nov-2022  macallan move ofprint() to powerpc/ofw_machdep.c and make it official
now that console output uses locks it needs more of the kernel to function, so
for now use direct OF calls for earliest debug output
 1.31 12-Oct-2022  andvar fix few typos in comments.
 1.30 02-Mar-2021  thorpej - Add a boolean "ofwbootcons_suppress" that, when true, suppresses
ofwbootcons I/O (i.e. "doesn't call into OFW"). This allows
platform code to ensure that early console I/O doesn't occur in certain
critical sections.
- When printing the translations, put phys next to virt for easier
visual comparisons.
 1.29 20-Feb-2021  thorpej Query real-mode? at startup and cache the result.
 1.28 19-Feb-2021  thorpej Shuffle around a couple of things that aren't particularly OEA-specific:

- Early bootstrap console initialization moves to ofw_machdep.c, and
is called a bit earlier, from ofw_bootstrap().

- Decoding the "translations" property from /chosen/mmu is specified
in the general OpenFirmware PowerPC bindings, and is not specific to
any particular PowerPC flavor. It's now decoded a bit earlier in
ofw_bootstrap().

The *interpretation* of the mode field of a translation is, however,
implementation-specific, so that remains in ofwoea_machdep.c.
 1.27 18-Feb-2021  thorpej Add an ofw_bootstrap() function, called during early bootstrap from
ofwinit() to perform additional early initialization in C code. Use
this to get the memory config while we're still running in the OpenFirmware
client environment, rather than waiting until we've started fiddling with
the system state.
 1.26 27-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.
 1.25 28-Feb-2014  matt branches: 1.25.42;
Use PRIx64
 1.24 12-Jun-2013  kiyohara branches: 1.24.2;
Fix lost avail memory over 256M.
 1.23 12-May-2013  macallan cleanup mem_regions:
- use different variables for / and /memory nodes
- remove redundant OF_finddevice("/")
- assume 32bit addresses/sizes in "available" on Apple hardware
 1.22 11-Apr-2013  macallan fix off-by-one
noticed by Phileas Fogg
 1.21 11-Apr-2013  macallan KNF nits
 1.20 01-Apr-2013  macallan deal with /memory "reg" property which may contain 64bit addresses on G5
 1.19 01-Feb-2012  matt branches: 1.19.6;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.18 27-Mar-2008  phx branches: 1.18.38; 1.18.42;
SmartFirmware only reports the first 256MB as available.
Also use the remaining memory by looking at the "reg" property.
 1.17 04-Mar-2008  mrg insert a .WAIT between include and include/foo subdirs, so that
include/ is created before include/foo.

fixes -j builds on ofppc for me.
 1.16 05-Aug-2006  sanjayl branches: 1.16.34; 1.16.54; 1.16.58;
1st cut of Powermac G5 support (uses bridge mode).
 1.15 11-Dec-2005  christos branches: 1.15.4; 1.15.8;
merge ktrace-lwp.
 1.14 15-Jul-2003  lukem branches: 1.14.16;
__KERNEL_RCSID()
 1.13 18-Sep-2002  chs branches: 1.13.6;
remove all vesitages of dk_establish().
 1.12 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.11 26-Aug-2001  matt branches: 1.11.2; 1.11.6; 1.11.14;
Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.10 22-Jul-2001  wiz memcpy -> memmove. Noted by Tsubai Masanari.
 1.9 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.8 10-Jun-2001  tsubai branches: 1.8.2;
Rename ofb_softc to ofbus_softc. (XXX Is this good name?)
 1.7 05-Dec-2000  mycroft branches: 1.7.2;
In mem_regions(), deal with the case of a run of consecutive holes.
Now the cube works with the memory in any order.
 1.6 24-Sep-2000  tsubai In mem_regions(), remove zero sized entry returned from OF.
Since this function uses size == 0 to delimiter, valid entries must not
contain 0 in size field.

G4 Cube should boot now. :-)
 1.5 23-May-2000  tsubai branches: 1.5.4;
Compile dk_* functions only when __BROKEN_DK_ESTABLISH is defined.
 1.4 24-Feb-1998  mycroft branches: 1.4.14;
Catch up with changes in dev/ofw. Add mainbus.
 1.3 16-Apr-1997  thorpej Fix some bogons in boot path parsing code.
 1.2 31-Jan-1997  thorpej Find the root device in a much more sane way. Also, remove all of the
code that determines the root file system type. This is now done in
machine-independent code, much differently.
 1.1 30-Sep-1996  ws branches: 1.1.2;
PowerPC port
 1.1.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.4.14.2 08-Dec-2000  bouyer Sync with HEAD.
 1.4.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.4.2 13-Dec-2000  he Pull up revision 1.7 (requested by mycroft):
Make memory probing work correctly with the DIMMs in any order.
 1.5.4.1 18-Oct-2000  tv Pullup 1.6 [tsubai]:
In mem_regions(), remove zero sized entry returned from OF.
Since this function uses size == 0 to delimiter, valid entries must not
contain 0 in size field.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.2.1 03-Aug-2001  lukem update to -current
 1.11.14.1 17-May-2002  gehenna Replace the access to devsw table and the hard-coded major with devsw API.
 1.11.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.11.6.2 17-Sep-2002  nathanw Catch up to -current.
 1.11.6.1 26-Aug-2001  nathanw file ofw_machdep.c was added on branch nathanw_sa on 2002-09-17 21:17:09 +0000
 1.11.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.16.2 17-Mar-2008  yamt sync with head.
 1.14.16.1 30-Dec-2006  yamt sync with head.
 1.15.8.1 11-Aug-2006  yamt sync with head
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.16.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.54.1 24-Mar-2008  keiichi sync with head.
 1.16.34.1 23-Mar-2008  matt sync with HEAD
 1.18.42.1 18-Feb-2012  mrg merge to -current.
 1.18.38.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.18.38.1 17-Apr-2012  yamt sync with head
 1.19.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.6.1 23-Jun-2013  tls resync from head
 1.24.2.1 18-May-2014  rmind sync with head
 1.25.42.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.4 24-Feb-1998  mycroft Catch up with changes in dev/ofw. Add mainbus.
 1.3 16-Apr-1997  thorpej Fix some bogons in boot path parsing code.
 1.2 31-Jan-1997  thorpej Find the root device in a much more sane way. Also, remove all of the
code that determines the root file system type. This is now done in
machine-independent code, much differently.
 1.1 30-Sep-1996  ws branches: 1.1.2;
PowerPC port
 1.1.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 09-Jan-2008  garbled branches: 1.3.6; 1.3.8; 1.3.10;
Change the note section for ofwboot to be what the ppc 1275 spec says it
should be, also add a section for IBM LPARs.
 1.2 09-Oct-1997  jtc branches: 1.2.64; 1.2.126; 1.2.132; 1.2.140;
Fix tipo inherited from old version of TNF copyright template.
 1.1 16-Apr-1997  thorpej branches: 1.1.4;
Special Magick note section interpreted by OpenFirmware to set various
parameters. Shared by kernel and OpenFirmware boot program.
 1.1.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.140.1 10-Jan-2008  bouyer Sync with HEAD
 1.2.132.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.126.1 23-Mar-2008  matt sync with HEAD
 1.2.64.1 21-Jan-2008  yamt sync with head
 1.3.10.1 16-May-2008  yamt sync with head.
 1.3.8.1 18-May-2008  yamt sync with head.
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.1 16-Apr-1997  thorpej branches: 1.1.4;
Special Magick note section interpreted by OpenFirmware to set various
parameters. Shared by kernel and OpenFirmware boot program.
 1.1.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.17 24-Jun-2023  msaitoh Fix typo in comment.
 1.16 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.15 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.14 31-Dec-2018  christos use 0 instead of %r0 for dcbst and icbi otherwise binutils-2.31.1 bitch.
 1.13 05-Jun-2011  matt branches: 1.13.52; 1.13.54;
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.12 17-Jan-2011  matt branches: 1.12.4;
Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.11 17-Oct-2007  garbled branches: 1.11.42; 1.11.48;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.10 21-May-2007  simonb branches: 1.10.10;
Fix a tpyo in a comment.
 1.9 14-Jan-2007  aymeric branches: 1.9.6; 1.9.8; 1.9.14;
disable MMU in restoremmu. This generally makes sense and is required for the
Efika
 1.8 25-Sep-2006  briggs Obvious (now that Jorge Acereda pointed it out) bug in the restoremmu
section of ENTRY(ofwr_init) (a constant offset of 4 was changed to %r4).
 1.7 11-Dec-2005  christos branches: 1.7.20; 1.7.22;
merge ktrace-lwp.
 1.6 24-Oct-2003  matt branches: 1.6.16;
Fix some indentation problems. Turn off PSL_EE when calling OFW.
 1.5 31-Jul-2003  matt Switch to m[tf]sprg[0-3]
 1.4 02-Feb-2003  matt branches: 1.4.2;
Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.3 23-Oct-2001  thorpej branches: 1.3.4;
ofwr_init(): don't clobber r7 -- early startup code needs it to find
DDB symbols.
 1.2 16-Apr-1997  thorpej branches: 1.2.28;
- Symbol cleanup, a'la locore.S
- Fix a 16-bit botch when disabling MMU
- Properly align save areas and temporary stacks.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.28.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.4.2 23-Oct-2001  thorpej ofwr_init(): don't clobber r7 -- early startup code needs it to find
DDB symbols.
 1.3.4.1 23-Oct-2001  thorpej file ofwreal.S was added on branch nathanw_sa on 2001-10-23 02:59:10 +0000
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.3 03-Sep-2007  yamt sync with head.
 1.6.16.2 26-Feb-2007  yamt sync with head.
 1.6.16.1 30-Dec-2006  yamt sync with head.
 1.7.22.1 22-Oct-2006  yamt sync with head
 1.7.20.2 01-Feb-2007  ad Sync with head.
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.9.14.2 02-Aug-2007  macallan sync with HEAD
 1.9.14.1 22-May-2007  matt Update to HEAD.
 1.9.8.1 11-Jul-2007  mjf Sync with head.
 1.9.6.1 27-May-2007  ad Sync with head.
 1.10.10.1 06-Nov-2007  matt sync with HEAD
 1.11.48.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.42.2 12-Jun-2011  rmind sync with head
 1.11.42.1 05-Mar-2011  rmind sync with head
 1.12.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.54.1 10-Jun-2019  christos Sync with HEAD
 1.13.52.1 18-Jan-2019  pgoyette Synch with HEAD
 1.3 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 16-Apr-1997  thorpej - Symbol cleanup, a'la locore.S
- Fix a 16-bit botch when disabling MMU
- Properly align save areas and temporary stacks.
 1.1 30-Sep-1996  ws PowerPC port
 1.33 13-Feb-2021  thorpej - Don't change to the OFW stack in C code; instead, switch to the OFW
stack in the openfirmware() wrapper itself. Inspired by a similar
change in OpenBSD designed to appease clang.
- The OF_*() entry firmware interfaces use several global resources;
protect those global resources with a __cpu_simple_lock_t.
- Make ofbcopy() static -- it's no longer referenced outside openfirm.c
 1.32 05-Feb-2021  thorpej s/bootspec/bstr/g to avoid shadowing a global.
 1.31 06-Jul-2020  rin branches: 1.31.2;
Style and cosmetic changes. No binary changes intended.
 1.30 06-Dec-2019  mrg revert this change from early this year. it appears the
changes macallan@ commited to fix FIRMWORKSBUGS issues
in openfirmware() have fixed the hangs seen on PegasosII.

hooray!

---
Log Message:
workaround a problem with the pegasos firmware interface:
attempting to use /dev/openfirm on this machine hangs hard.

this isn't a new problem, and i've been meaning to try to
figure it out for years, but it's become a problem since
the xf86-video-radeon driver gained code to look for the
macppc model using this interface.

this is why xorg-server 1.18 and 1.20 hang recently on the
pegasosII.

this change is fairly ugly but i couldn't think of a less
ugly method to avoid /dev/openfirm working just on this
one platform. introduce new __OPENFIRMIO_OPEN_CHECK_BROKEN
macro and associated __openfirmio_open_check_broken(), and
use them in the new openfirmopen() to fail opens.

include proplib.h in macppc and ofppc autoconf.h since they
use it.
---
 1.29 16-Nov-2019  macallan fix pasto - don't limit OF_finddevice() to 32 characters
now this works again
 1.28 15-Nov-2019  macallan stuff name parameters into OF_buf before calling OF
now things like ofctl work on my TiBook with FIRMWORKSBUGS
 1.27 08-Jan-2019  mrg workaround a problem with the pegasos firmware interface:
attempting to use /dev/openfirm on this machine hangs hard.

this isn't a new problem, and i've been meaning to try to
figure it out for years, but it's become a problem since
the xf86-video-radeon driver gained code to look for the
macppc model using this interface.

this is why xorg-server 1.18 and 1.20 hang recently on the
pegasosII.


this change is fairly ugly but i couldn't think of a less
ugly method to avoid /dev/openfirm working just on this
one platform. introduce new __OPENFIRMIO_OPEN_CHECK_BROKEN
macro and associated __openfirmio_open_check_broken(), and
use them in the new openfirmopen() to fail opens.

include proplib.h in macppc and ofppc autoconf.h since they
use it.
 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 07-Aug-2014  joerg branches: 1.25.26; 1.25.28;
Panic after openfirm, it is not supposed to return.
 1.24 28-Feb-2014  matt branches: 1.24.2;
Use uintptr_t to convert pointers.
 1.23 17-Jan-2014  mrg convert a failure to call OF for a reboot call into a panic() instead
of a hard hang.
 1.22 12-May-2013  macallan branches: 1.22.2;
add OF_quiesce() to shut down OF background tasks, needed on G5
from Phileas Fogg
 1.21 17-Jul-2011  joerg branches: 1.21.2; 1.21.12;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.20 08-Apr-2008  garbled SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.19 07-Nov-2007  garbled branches: 1.19.14;
Convert ofppc to the shared ofw_autoconf.c
 1.18 28-Feb-2007  macallan branches: 1.18.2; 1.18.18; 1.18.20; 1.18.24; 1.18.26;
add OF_setprop()
 1.17 22-Jan-2006  ross branches: 1.17.24;
Work around a PIBS bug: OF_write() doesn't get a returned count.
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 02-Jun-2005  matt branches: 1.15.2;
constify and adapt for newly enabled warnings.
 1.14 27-Sep-2003  matt ANSIfy.
 1.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 02-Apr-2003  thorpej branches: 1.12.2;
Use PAGE_SIZE rather than NBPG.
 1.11 24-Sep-2001  wiz branches: 1.11.4;
va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.10 19-Jun-2001  simonb branches: 1.10.2; 1.10.4;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.9 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.8 10-Jun-2001  tsubai libkern.h is included in systm.h. Not needed here.
 1.7 08-Jun-2001  matt Fix warning about braces & if. Include libkern.h for strncpy prototype
 1.6 22-Nov-2000  wiz branches: 1.6.2;
Change OF_nextprop to match prototype change to void *
(Please don't change prototypes without changing the corresponding
functions!)
 1.5 14-Nov-2000  matt Add support for /dev/openfirm.
Add OF_nextprop support.
 1.4 10-Jan-1999  tsubai branches: 1.4.8;
Fix void * arithmetic.
 1.3 15-Nov-1998  tsubai Restrict the length of return value within buflen.
 1.2 02-Feb-1998  thorpej Implement OF_getproplen().
 1.1 30-Sep-1996  ws PowerPC port
 1.4.8.2 08-Dec-2000  bouyer Sync with HEAD.
 1.4.8.1 22-Nov-2000  bouyer Sync with HEAD.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.4.2 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.11.4.1 24-Sep-2001  wiz file openfirm.c was added on branch nathanw_sa on 2001-09-24 13:22:34 +0000
 1.12.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.2.3 15-Nov-2007  yamt sync with head.
 1.15.2.2 03-Sep-2007  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.2.1 01-Feb-2006  yamt sync with head.
 1.17.24.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.26.1 19-Nov-2007  mjf Sync with HEAD.
 1.18.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.18.20.1 08-Nov-2007  matt sync with -HEAD
 1.18.18.1 11-Nov-2007  joerg Sync with HEAD.
 1.18.2.2 03-Dec-2007  ad Sync with HEAD.
 1.18.2.1 03-Dec-2007  ad Sync with HEAD.
 1.19.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.12.1 23-Jun-2013  tls resync from head
 1.21.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.2.1 18-May-2014  rmind sync with head
 1.24.2.1 10-Aug-2014  tls Rebase.
 1.25.28.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.25.28.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.28.1 10-Jun-2019  christos Sync with HEAD
 1.25.26.2 18-Jan-2019  pgoyette Synch with HEAD
 1.25.26.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.31.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 02-Feb-1998  thorpej Implement OF_getproplen().
 1.1 30-Sep-1996  ws PowerPC port
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Sep-2003  matt ANSIfy.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 05-Feb-2001  briggs branches: 1.3.2; 1.3.26;
Tsubai has convinced me that openpic_init() should remain machine-dependant
as the details might differ between archs, and passing the various options
leads to some clutter.
 1.2 04-Feb-2001  briggs Remove dependancy on ICU_LEN m.d. define. Thanks, Tsubai.
 1.1 02-Feb-2001  briggs Split OpenPIC support into powerpc so ports only need minimal custom
configuration. openpic_init() now takes a single argument that is the
base of the OpenPIC register space.
 1.3.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.26.1 03-Aug-2004  skrll Sync with HEAD
 1.3.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.1 05-Feb-2001  bouyer file openpic.c was added on branch thorpej_scsipi on 2001-02-11 19:11:36 +0000
 1.18 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.17 20-Feb-2020  rin eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.16 29-Jul-2014  joerg branches: 1.16.28; 1.16.32; 1.16.34;
cmpl wants four operands, so use the shorter cmplw instead.
 1.15 28-Feb-2014  matt branches: 1.15.2;
Fix the 64-bit case
 1.14 01-Jul-2011  dyoung branches: 1.14.2; 1.14.12; 1.14.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.13 18-Jan-2011  matt 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.12 25-May-2008  chs branches: 1.12.20; 1.12.24; 1.12.26;
enable profiling of assembly functions.
 1.11 14-Feb-2008  garbled branches: 1.11.6; 1.11.8; 1.11.10; 1.11.12;
Some powerpc cleanup. Remove unneeded/bad usage of extern oeacpufeat.
Convert asm code to use %r register format. Done by comparison to
disassembled output, double checked with diff of dissasembled output
before and after, and test booted on my 7044.
 1.10 11-Dec-2005  christos branches: 1.10.50; 1.10.56;
merge ktrace-lwp.
 1.9 17-Jan-2005  matt branches: 1.9.8;
Fix problem with unclosed comments
 1.8 29-Mar-2004  simonb branches: 1.8.2; 1.8.6; 1.8.8;
Fix the LINTSTUB entries- the second arg to these functions is a
bus_space_handle_t, not a bus_addr_t.
 1.7 08-Jan-2004  nonaka implement bus_space_set_region_[124], bus_space_copy_region_[124].
 1.6 11-Dec-2003  scw Fix a typo in bswr2rb() which resulted in an 8-bit load instead 16-bit.
Pointed out by Derek Godfrey.
 1.5 08-Sep-2003  kleink Bring /* LINTSTUBs */ closer to reality.
 1.4 07-Sep-2003  kleink g/c byte-reversing bus_space_set_region_1() entries.
 1.3 30-Apr-2003  scw branches: 1.3.2;
Add support for bus_space_{read,write}_region_[124]()
 1.2 16-Mar-2003  matt addi is not the same as add. :)
 1.1 15-Mar-2003  matt New generic powerpc bus_space framework.
 1.3.2.4 24-Jan-2005  skrll Sync with HEAD.
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.8.1 29-Apr-2005  kent sync with -current
 1.8.6.1 16-Apr-2005  tron Pull up revision 1.9 (requested by matt in ticket #1106):
Fix problem with unclosed comments
 1.8.2.2 29-Mar-2004  simonb Fix the LINTSTUB entries- the second arg to these functions is a
bus_space_handle_t, not a bus_addr_t.
 1.8.2.1 29-Mar-2004  simonb file pio_subr.S was added on branch netbsd-2-0 on 2004-03-29 01:15:15 +0000
 1.9.8.1 27-Feb-2008  yamt sync with head.
 1.10.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.50.1 23-Mar-2008  matt sync with HEAD
 1.11.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.10.1 04-May-2009  yamt sync with head.
 1.11.8.1 04-Jun-2008  yamt sync with head
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.24.1 07-Jan-2011  matt Add booke support
 1.12.20.1 05-Mar-2011  rmind sync with head
 1.14.16.1 18-May-2014  rmind sync with head
 1.14.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.2.1 10-Aug-2014  tls Rebase.
 1.16.34.1 29-Feb-2020  ad Sync with head.
 1.16.32.1 25-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #730):

sys/arch/powerpc/conf/files.powerpc: revision 1.93
sys/arch/powerpc/include/pio.h: revision 1.8
sys/arch/powerpc/pic/intr.c: revision 1.27
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.50
sys/arch/powerpc/powerpc/pio_subr.S: revision 1.17

Add PPC_IBM440 flag as 440 is significantly different from 40x processors.
(It may be more easily supported by booke than by ibm4xx.)

-

eieio is implemented as sync on 40x. Therefore, "sync; eieio" and
"eieio; sync" can be replaced by a single sync.
 1.16.28.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.52 02-Feb-2003  matt Remove OLDPMAP support.
 1.51 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.50 10-Oct-2002  matt Move pte_spill calls from trap_subr to trap(). Count the number of
"evictions" and avoide calling pmap_pte_spill if there are no evictions
for the current pmap. Make the ISI execption use the default exception
code. Remove lots of dead stuff from trap_subr.

Make olink use TAILQ instead of LIST and be sorted with evicted entries
first and resident entries last. Make use of this knowledge to make
pmap_pte_spill do a fast exit.
 1.49 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.48 01-Dec-2001  tsutsui Implement pmap_kenter_pa() and pmap_kremove() properly.
This should fix `kernel diagnostic assertion "rv" failed' panic
and the problem was tracked down by tsubai.
Also add small optimization in pmap_enter() and pmap_remove(), from tsubai.
 1.47 13-Oct-2001  chs branches: 1.47.4;
fix pmap_changebit() to look for the bit in the page attrs
in addition to any PTEs. fixes PR 14220.
 1.46 22-Jul-2001  wiz Replace memcpy's of obviously overlapping regions with memmove.
Noted by Izumi Tsutsui.
 1.45 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.44 10-Jun-2001  tsubai branches: 1.44.2;
Make the new pmap optional. Use the old (stable!) pmap by default.
 1.43 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.42 26-May-2001  chs replace vm_page_t with struct vm_page *.
 1.41 22-Apr-2001  thorpej Remove pmap_kenter_pgs(). It was never really adopted by
anything, and the interface itself wasn't as flexible as
callers would have probably liked.
 1.40 21-Apr-2001  thorpej #define away pmap_update() in <machine/pmap.h> so that no function
call overhead is incurred as we start sprinkling pmap_update() calls
throughout the source tree (no pmaps currently defer operations, but
we are adding the infrastructure to allow them to do so).
 1.39 26-Mar-2001  briggs Ensure that my last change compiles with warnings enabled.
 1.38 26-Mar-2001  briggs Do not save/restore the kernel SR since we are no longer trying to copy
it in pmap_activate(). Pointed out by ws in a private message.
 1.37 24-Mar-2001  briggs Do not hardcode the kernel segment register, and do not load the kernel
segment register in pmap_activate().
 1.36 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.35 07-Mar-2001  tsubai Cosmetics.
 1.34 04-Feb-2001  briggs branches: 1.34.2;
Build with -Wall -Wetc.
 1.33 14-Jan-2001  thorpej splimp() -> splvm()
 1.32 24-Sep-2000  tsubai Make HTABSIZE calculation work with >1GB RAM.
 1.31 13-Sep-2000  thorpej Add an align argument to uvm_map() and some callers of that
routine. Works similarly fto pmap_prefer(), but allows callers
to specify a minimum power-of-two alignment of the region.
How we ever got along without this for so long is beyond me.
 1.30 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.29 26-Jun-2000  mrg remove/move more mach vm header files:

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

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

Originally done by Chuck Silvers, updated by myself.
 1.27 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.26 14-Sep-1999  chs branches: 1.26.2; 1.26.4; 1.26.8;
fix breakage from PMAP_NEW cleanup.
 1.25 12-Sep-1999  chs eliminate the PMAP_NEW option by making it required for all ports.
ports which previously had no support for PMAP_NEW now implement
the pmap_k* interfaces as wrappers around the non-k versions.
 1.24 30-Aug-1999  tsubai Make sure that we use only inside of available memory region
in pmap_bootstrap.
 1.23 08-Jul-1999  thorpej Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.22 17-Jun-1999  thorpej Remove pmap_pageable(); no pmap implements it, and it is not really useful,
because pmap_enter()/pmap_change_wiring() (soon to be pmap_unwire())
communicate the information in greater detail.
 1.21 17-Apr-1999  ws Modify syncicache on PowerPC from an inline to a real function.
Support different cache line sizes with the same object code in userland.
While here, move the function to implementation name space.
 1.20 11-Apr-1999  chs add a `flags' argument to uvm_pagealloc_strat().
define a flag UVM_PGA_USERESERVE to allow non-kernel object
allocations to use pages from the reserve.
use the new flag for allocations in pmap modules.
 1.19 26-Mar-1999  mycroft branches: 1.19.2;
Changes for modified pmap_enter() API:
* Map the message buffer with access_type = VM_PROT_READ|VM_PROT_WRITE `just
because'.
* Map the file system buffers with access_type = VM_PROT_READ|VM_PROT_WRITE to
avoid possible problems with pagemove().
* Do not use VM_PROT_EXEC with either of the above.
* Map pages for /dev/mem with access_type = prot. Also, DO NOT use
pmap_kenter() for this, as we DO NOT want to lose modification information.
* Map pages in dumpsys() with VM_PROT_READ.
* Map pages in m68k mappedcopyin()/mappedcopyout() and writeback() with
access_type = prot.
* For now, bus_dma*(), pmap_map(), vmapbuf(), and similar functions still use
access_type = 0. This should probably be revisited.
 1.18 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.17 05-Mar-1999  tsubai Add RSS accounting.
 1.16 26-Feb-1999  tsubai Implement pmap_procwr().
(Not tested. gdb doesn't work on powerpc yet.)
 1.15 04-Feb-1999  tsubai Make ptable really aligned to HTABSIZE.
 1.14 16-Jan-1999  chuck MNN is no longer optional, remove old code
 1.13 12-Jan-1999  tsubai Use (fast!) dcbz asm instruction in pmap_zero_page().
 1.12 12-Jan-1999  tsubai Use the last available page(s) for msgbuf.
 1.11 10-Jan-1999  tsubai Fix void * arithmetic.
 1.10 13-Oct-1998  tsubai Don't panic when pmap_remove_pv even if pa is not managed.
(i.e. I/O device. framebuffer etc.)
 1.9 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.8 08-Jul-1998  thorpej Define one page free list, and put all pages on it.
 1.7 21-Jun-1998  tsubai Bugfix of MACHINE_NEW_NONCONTIG support.
PTE_I/G bits should be determined by mem array (not avail array).
 1.6 05-Jun-1998  sakamoto Merge in MACHINE_NEW_NONCONTIG support and some fix from Tsubai-San.
UVM support.
 1.5 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.4 19-May-1998  thorpej It is no longer necessary for pmap_pinit() and pmap_release() to be
pmap interface functions, as NetBSD no longer uses statically allocated
pmaps (except for the kernel pmap, which is special-cased anyhow).
 1.3 02-Jan-1998  thorpej Implement pmap_activate().
 1.2 16-Apr-1997  thorpej - Fixed reversed arguments to an asm() (from Andrew Cagney)
- Round memory segments in a saner way (from Charles Hannum)
 1.1 30-Sep-1996  ws PowerPC port
 1.19.2.2 20-Oct-1999  he Pull up revision 1.24 (requested by tsubai):
Make sure we only use addresses inside the available memory region
in pmap_bootstrap.
 1.19.2.1 16-Apr-1999  chs branches: 1.19.2.1.2;
pull up 1.19 -> 1.20:
add a `flags' argument to uvm_pagealloc_strat().
define a flag UVM_PGA_USERESERVE to allow non-kernel object
allocations to use pages from the reserve.
use the new flag for allocations in pmap modules.
 1.19.2.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.19.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.26.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.26.4.1 15-Nov-1999  fvdl Sync with -current
 1.26.2.6 23-Apr-2001  bouyer Sync with HEAD.
 1.26.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.26.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.26.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.26.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.26.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.34.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.34.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.44.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.44.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.44.2.1 03-Aug-2001  lukem update to -current
 1.47.4.6 18-Oct-2002  nathanw Catch up to -current.
 1.47.4.5 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.47.4.4 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.47.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.47.4.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.47.4.1 13-Oct-2001  briggs file pmap.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.30 06-Jul-2020  rin Include missing opt_ppcarch.h.
 1.29 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.28 11-May-2018  macallan disable the MULTIPROCESSOR case in pmap_syncicache() because:
- __syncicache() wants a virtual address, not a pa
- this crashes on G5 SMP
- the rest of the function does the same as __syncicache() except it turns
the MMU off first so physical addresses work
with this, my PCIe G5 boots SMP
 1.27 01-Feb-2012  matt branches: 1.27.46;
Use kmem instead of malloc. Remove unneeded <sys/malloc.h> includes.
 1.26 12-Feb-2011  matt branches: 1.26.4; 1.26.8;
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.25 12-Nov-2010  uebayasi branches: 1.25.2; 1.25.4;
Put VM_PAGE_TO_MD() definition in one place. No functional changes.
 1.24 06-Nov-2010  uebayasi Machine dependent code is considered as part of UVM. Include
internal API header.
 1.23 30-Oct-2010  uebayasi Use VM_PAGE_TO_MD() to locate struct vm_page_md. No functional
changes.
 1.22 28-Jan-2010  phx branches: 1.22.2; 1.22.4;
Fixed typo: PPC_OEA64_BIRDGE -> PPC_OEA64_BRIDGE
 1.21 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.20 05-Feb-2008  garbled branches: 1.20.6; 1.20.8; 1.20.10;
Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.19 17-Oct-2007  garbled branches: 1.19.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.18 18-May-2007  rjs branches: 1.18.10;
Fix for yamt-idlelwp merge.
 1.17 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.16 22-Feb-2007  thorpej branches: 1.16.4; 1.16.6; 1.16.12;
TRUE -> true, FALSE -> false
 1.15 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.14 05-Aug-2006  sanjayl branches: 1.14.10;
1st cut of Powermac G5 support (uses bridge mode).
 1.13 24-Dec-2005  perry branches: 1.13.4; 1.13.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.12 11-Dec-2005  christos merge ktrace-lwp.
 1.11 27-Oct-2003  dyoung branches: 1.11.16;
Stop false uninitialized variable warning.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 02-Apr-2003  thorpej branches: 1.9.2;
Use PAGE_SIZE rather than NBPG.
 1.8 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.7 13-Nov-2002  matt If MULTIPROCESSOR, just accept the penalties of doing BAT flipping when
syncing the icache.
 1.6 20-Aug-2002  matt branches: 1.6.2;
Use "b" constraint for base registers (indexed addressing mode).
 1.5 18-Aug-2002  matt Add evcnt's for common pmap activities when PMAPCOUNTERS is defined
in the config file.
 1.4 14-Aug-2002  matt Re-enable PTE_EXEC. PTE_EXEC is now also cleared in pmap_zero_page,
pmap_copy_page, and pmap_clear_modify (pmap_clear_bit). Remove #ifdef
MULTIPROCESSOR since the cache instructions operate on all caches on
all processors.
 1.3 28-Jul-2002  chs branches: 1.3.2;
remove a local copy of mfmsr().
 1.2 18-Jul-2002  matt branches: 1.2.2;
Make sure that pmap_zero_page and pmap_copy_page don't make calls or
reference while relocation is disabled since the stack will be inaccessible.
Add support for using AltiVec in pmap_zero_page and pmap_copy_page on
AltiVec capable processors.
 1.1 17-Jul-2002  matt Add a common file to do pmap_zero_page/pmap_copy_page/pmap_pageidlezero and
pmap_syncicache. This file uses a ppc feature in a sick and twisted way
to avoid mapping the physical pages used by those routines. It performs
the operations with the MMU disabled but PPC exception save and retstore
the machine state and are invoked with the MMU disabled, this doesn't have
an adverse effect on the system.

Currently only enable for MPC6xx and !OLDPMAP.
 1.2.2.3 31-Aug-2002  gehenna catch up with -current.
 1.2.2.2 21-Jul-2002  gehenna catch up with -current.
 1.2.2.1 18-Jul-2002  gehenna file pmap_subr.c was added on branch gehenna-devsw on 2002-07-21 13:00:49 +0000
 1.3.2.4 11-Dec-2002  thorpej Sync with HEAD.
 1.3.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.3.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.1 28-Jul-2002  nathanw file pmap_subr.c was added on branch nathanw_sa on 2002-08-01 02:43:10 +0000
 1.6.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.2.1 20-Aug-2002  jdolecek file pmap_subr.c was added on branch kqueue on 2002-09-06 08:39:26 +0000
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.16.5 11-Feb-2008  yamt sync with head.
 1.11.16.4 03-Sep-2007  yamt sync with head.
 1.11.16.3 26-Feb-2007  yamt sync with head.
 1.11.16.2 30-Dec-2006  yamt sync with head.
 1.11.16.1 21-Jun-2006  yamt sync with head.
 1.13.8.1 11-Aug-2006  yamt sync with head
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.10.2 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.14.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.16.12.2 02-Aug-2007  macallan sync with HEAD
 1.16.12.1 22-May-2007  matt Update to HEAD.
 1.16.6.1 11-Jul-2007  mjf Sync with head.
 1.16.4.1 27-May-2007  ad Sync with head.
 1.18.10.2 23-Mar-2008  matt sync with HEAD
 1.18.10.1 06-Nov-2007  matt sync with HEAD
 1.19.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.20.10.2 11-Mar-2010  yamt sync with head
 1.20.10.1 16-May-2008  yamt sync with head.
 1.20.8.1 18-May-2008  yamt sync with head.
 1.20.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.4.1 05-Mar-2011  rmind sync with head
 1.22.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.22.2.2 27-May-2010  uebayasi Fix build.
 1.22.2.1 26-Feb-2010  uebayasi Use VM_PAGE_TO_MD(). Only compile tested.
 1.25.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.25.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.8.1 18-Feb-2012  mrg merge to -current.
 1.26.4.1 17-Apr-2012  yamt sync with head
 1.27.46.1 21-May-2018  pgoyette Sync with HEAD
 1.86 30-May-2022  rin Export CPU capability of unaligned memory access to userland
as machdep.no_unaligned sysctl(7) variable.

This will be used for ld.so.conf in order to provide strictly-
aligned versions of libc routines.
 1.85 20-May-2022  andvar s/auxillary/auxiliary/ in comments.
 1.84 03-May-2022  andvar fix various typos, mainly s/trasfering/transferring/ and s/theese/these/.
 1.83 15-Apr-2021  rin sandpoint has its own module_init_md(). So, do not compile in
that function in powerpc_machdep.c.
 1.82 06-Mar-2021  rin branches: 1.82.2;
Convert to KASSERTMSG(9) to display wrong IPL.
 1.81 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.80 15-Jul-2020  rin branches: 1.80.2;
Factor out emulation code for m[ft]msr in user mode from oea, and
adjust it for systems without FPU.

Now, it can be used from booke and ibm4xx in order to support fenv(3).
 1.79 07-Jul-2020  rin Part of PR port-powerpc/55425
openssl fails on FPU emulation for powerpc

Provide machdep.fpu_present sysctl variable like other ports.

Userland can get informed that FPU is absent and emulated in software
(and calculation results may not be correct in bit-to-bit precision).

This variable should be useful even if we could fix FPU emulation;
it is much faster to skip FPU arithmetic in general, rather than
relying upon emulation by kernel via illegal instruction handler.
 1.78 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.77 20-Feb-2020  rin Provide no-op's as pcu_ops_md_defs[PCU_FPU] even if !PPC_HAVE_FPU.

This is required by subr_pcu.c rev 1.21 and later:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_pcu.c#rev1.21

Otherwise, panic occurs when FP instruction is emulated on machines
without FPU.

Note that PowerPC UISA as well as SVR4 ABI require FP instructions,
and emulation is enabled unconditionally on machines without FPU.
 1.76 17-Feb-2020  ad cpu_ast(): no need to call userret(), as the caller does it for us. From rin@.
 1.75 05-Dec-2019  ad branches: 1.75.2;
Need to call userret() from cpu_ast().
 1.74 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.73 21-Nov-2019  ad mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.
 1.72 16-Sep-2018  skrll branches: 1.72.4;
interrupt has two 'r's

fix another typo while I'm here (flsah)
 1.71 23-Jan-2015  nonaka branches: 1.71.16; 1.71.18;
ddb MP support
 1.70 19-May-2014  rmind branches: 1.70.4;
Implement MI IPI interface with cross-call support.
 1.69 24-Mar-2014  christos branches: 1.69.2;
remove dup cpu_model sysctl; use the mi version in hw.
 1.68 06-Mar-2014  matt Fix PPC64 setregs
 1.67 28-Feb-2014  matt If execing a LP64 image, we need to read the function descriptor to get
the entry point and the TOC base. (Do we need to fixup the TOC base?)
 1.66 08-Nov-2013  nisimura use __diagused for KASSERT only variable.
 1.65 19-Jul-2013  matt cpuset_info is no longer volatile
 1.64 16-Mar-2012  matt branches: 1.64.2; 1.64.4; 1.64.10;
Add CPU_EXECPROT sysctl so that atf can enable exec permission tests for
PPC Booke.
 1.63 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.62 11-Feb-2012  martin branches: 1.62.2;
Add a posix_spawn syscall, as discussed on tech-kern.
Based on the summer of code project by Charles Zhang, heavily reworked
later by me - all bugs are likely mine.
Ok: core, releng.
 1.61 12-Dec-2011  mrg implement bdev_size(9) wrapper around d_psize() routine, so we can take
the device lock in relevant places. avoid doing so while actually dumping.

tested i386 crash dumps still work, and that all touched files compile.

fixes PR#45705.
 1.60 31-Jul-2011  kiyohara branches: 1.60.2; 1.60.6;
s/MULTIPROCESOR/MULTIPROCESSOR/.
 1.59 29-Jun-2011  matt Cleanup hatch names.
Add cpuset_info.
 1.58 24-Jun-2011  matt Fix code that's been broken for over seven years...
 1.57 21-Jun-2011  matt Add a common cpu_ast(l, ci) routine.
Add a ci_pmap_asid_cur for BOOKE debugging.
 1.56 20-Jun-2011  matt Make more module friendly (part 1).
Don't export frame.h and psl.h to all of the kernel.
add lwp_pc and clkf accessor functions.
whitespace cleanup.
 1.55 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.54 14-Jun-2011  matt Make startlwp and upcallret common instead of having 3 mostly identical copies.
 1.53 14-Jun-2011  matt Add mm_md_kernacc and now kmem tools work again.
 1.52 12-Jun-2011  matt need mm_md_direct_mapped_phys support.
 1.51 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.50 07-Jun-2011  matt Switch alpha to use PCU to manage the FPU.
Tested by mhitch and review by rmind.
 1.49 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.48 02-May-2011  matt branches: 1.48.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.47 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.46 04-Mar-2011  joerg Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.45 18-Jan-2011  matt branches: 1.45.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.44 14-Jan-2011  rmind branches: 1.44.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.43 13-Nov-2010  uebayasi Some missing sys/device.h dependencies.
 1.42 18-Jan-2010  jmmv branches: 1.42.4;
Define kobj_machdep and module_init_md empty functions so that powerpc
kernels (at least macppc) with 'options MODULAR' can be built.
 1.41 10-Dec-2009  matt Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.40 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.39 15-Oct-2008  wrstuden branches: 1.39.16;
Merge wrstuden-revivesa into HEAD.
 1.38 05-Feb-2008  garbled branches: 1.38.6; 1.38.10; 1.38.12; 1.38.16;
Replace as much of the hardcoded CACHELINESIZE with
curcpu()->ci_ci.dcache_line_size as I can. With this change, an ofppc kernel
compiled with both PPC_OEA and PPC_OEA64_BRIDGE defined, boots.
 1.37 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.36 03-Dec-2007  ad Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.35 17-Oct-2007  garbled branches: 1.35.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.34 01-Jun-2007  nisimura branches: 1.34.8; 1.34.10;
- add booted_device and booted_kernel sysctl nodes to let userland know
about runtime environment.
 1.33 09-Feb-2007  ad branches: 1.33.6; 1.33.8; 1.33.14;
Merge newlock2 to head.
 1.32 21-Oct-2006  mrg in cpu_dumpconf(), don't panic() if we can't bdevsw_lookup() the
dumpdev. this occurs when we try to set the dumpdev to a device
with no driver loaded. this fixes PR#34872.

in sys_swapctl, if bdevsw_lookup() fails, set dumpdev = NODEV
before calling cpu_dumpconf(). (this also fixes PR#34872.)

XXX: cpu_dumpconf() should probably be changed to take a dumpdev
XXX: and return an error in such cases, but that is a much more
XXX: intrusive change.

XXX2: this is only run-tested on sparc64 and compile tested on a
XXX2: couple of platforms.
 1.31 05-Aug-2006  sanjayl branches: 1.31.4; 1.31.6;
1st cut of Powermac G5 support (uses bridge mode).
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.8;
merge ktrace-lwp.
 1.29 02-Oct-2005  chs remove unnecessary extern declaration.
 1.28 09-Jul-2004  matt branches: 1.28.12;
Clear PSL_SE on a scheduler activation upcall.
 1.27 04-Apr-2004  matt Don't add PSL_FE_FDLT to srr1, but put in pcb_flags. It will be added to
the SRR1 only when the lwp owns the FPU.
 1.26 24-Mar-2004  atatat Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.25 03-Jan-2004  aymeric fix an obvious typo which prevented the machdep.cacheinfo table from being
published.
This generated the following warning message at boot time:
sysctl_createv: sysctl_create(cacheinfo) returned 17
 1.24 05-Dec-2003  hannken Make it compile without PPC_OEA.
 1.23 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.22 27-Sep-2003  matt ANSIfy.
 1.21 15-Jul-2003  lukem __KERNEL_RCSID()
 1.20 29-Jun-2003  fvdl branches: 1.20.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.19 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.18 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.17 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.16 18-Jan-2003  matt In cpu_upcall, cast to register_t, not int. (int is not LP64 friendly)
 1.15 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.14 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.13 16-Jul-2002  matt Add machdep.powerpc sysctl. Change the default value of powersave to -1
(< 0 mean no powersave available). Enable powersave by default for
750/7400/7410 but leave if off for 7450/7455.
 1.12 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.11 18-Mar-2002  briggs branches: 1.11.4;
Use p->p_psstr instead of PS_STRINGS.
Tested on boot to multi-user on sandpoint.
 1.10 13-Mar-2002  eeh Add cache_info to cpu_info which provides details about D$ and I$
sizes and line sizes. This is needed for cache flusing, clearing
memory, and several other operations. This information is accessible
from userland through a new CPU_CACHEINFO sysctl.
 1.9 06-Mar-2002  tsutsui Change type of dumpmag to u_int32_t since it is actually
a 32bit unsigned magic number.
As per discussion on tech-kern, and fixes port-sparc64/11949.
 1.8 26-Aug-2001  matt branches: 1.8.6;
Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.7 26-Jul-2001  wiz auxilliary -> auxiliary
 1.6 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.5 05-Jul-2001  toshii branches: 1.5.2;
Fix typo. s/extention/extension/
 1.4 05-Apr-2001  tsubai Regenerate this file from cvs repository in order to get back original
copyright.
 1.3 03-Apr-2001  jdolecek add standard NetBSD RCS Id on top
 1.2 24-Feb-2001  matt branches: 1.2.2; 1.2.4;
Move cpu_sysct and dump{mag,lo,siz} & cpu_dumpconf to powerpc_machdep.c.
dumpsys is still port-specific for now. XXX dumpsys is still a stub
on all powerpc ports.
 1.1 24-Feb-2001  matt Since setregs is common among all the powerpc ports,
make a common version and put it in powerpc_machdep.c
 1.2.4.3 21-Apr-2001  bouyer Sync with HEAD
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 24-Feb-2001  bouyer file powerpc_machdep.c was added on branch thorpej_scsipi on 2001-03-12 13:29:14 +0000
 1.2.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.5.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.5.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.5.2.1 03-Aug-2001  lukem update to -current
 1.8.6.17 17-Sep-2002  nathanw Catch up to -current.
 1.8.6.16 01-Aug-2002  nathanw Catch up to -current.
 1.8.6.15 19-Jul-2002  nathanw Invoke upcalls directly, instead of going through a trampoline.
(Since upcalls shouldn't return at all, even the return part of the
trampoline is unnecessary).
 1.8.6.14 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.8.6.13 01-Apr-2002  nathanw LWPify the changes in setregs().
 1.8.6.12 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.6.11 25-Mar-2002  nathanw Allocate space on the stack for struct saframe (the linkage area)
(Accidentally lost this code when switching to thr common upcall code).
 1.8.6.10 28-Dec-2001  nathanw Garbage collect cpu_stashcontext().
 1.8.6.9 17-Dec-2001  nathanw Oops, don't delete the declaration of sigcode[] and upcallcode.
 1.8.6.8 17-Dec-2001  nathanw Convert to new, smaller cpu_upcall().
 1.8.6.7 26-Nov-2001  briggs Make sure we use the proper stack pointer for signal delivery.
 1.8.6.6 21-Nov-2001  briggs Dress up upcall's callframe correctly.
 1.8.6.5 17-Nov-2001  briggs Update to Current World Order.
 1.8.6.4 13-Nov-2001  briggs Improve upcall to better work with libpthread.
 1.8.6.3 08-Nov-2001  briggs Make some callee space on the stack for the cpu_upcall.
 1.8.6.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.8.6.1 26-Aug-2001  briggs file powerpc_machdep.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.11.4.3 21-Jul-2002  gehenna catch up with -current.
 1.11.4.2 16-Jul-2002  gehenna catch up with -current.
 1.11.4.1 17-May-2002  gehenna Replace the access to devsw table and the hard-coded major with devsw API.
 1.20.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.2 03-Aug-2004  skrll Sync with HEAD
 1.20.2.1 03-Jul-2003  wrstuden LWP-ify for bebox/GENERIC
 1.28.12.6 11-Feb-2008  yamt sync with head.
 1.28.12.5 07-Dec-2007  yamt sync with head
 1.28.12.4 03-Sep-2007  yamt sync with head.
 1.28.12.3 26-Feb-2007  yamt sync with head.
 1.28.12.2 30-Dec-2006  yamt sync with head.
 1.28.12.1 21-Jun-2006  yamt sync with head.
 1.30.8.1 11-Aug-2006  yamt sync with head
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.31.6.1 22-Oct-2006  yamt sync with head
 1.31.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.31.4.1 18-Nov-2006  ad Sync with head.
 1.33.14.2 02-Aug-2007  macallan sync with HEAD
 1.33.14.1 26-Jun-2007  garbled Sync with HEAD.
 1.33.8.1 11-Jul-2007  mjf Sync with head.
 1.33.6.3 03-Dec-2007  ad Sync with HEAD.
 1.33.6.2 03-Dec-2007  ad Sync with HEAD.
 1.33.6.1 09-Jun-2007  ad Sync with head.
 1.34.10.3 23-Mar-2008  matt sync with HEAD
 1.34.10.2 09-Jan-2008  matt sync with HEAD
 1.34.10.1 06-Nov-2007  matt sync with HEAD
 1.34.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.35.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.35.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.38.16.1 19-Oct-2008  haad Sync with HEAD.
 1.38.12.2 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.38.12.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.38.10.2 11-Mar-2010  yamt sync with head
 1.38.10.1 04-May-2009  yamt sync with head.
 1.38.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.39.16.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.39.16.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.42.4.6 12-Jun-2011  rmind sync with head
 1.42.4.5 31-May-2011  rmind sync with head
 1.42.4.4 21-Apr-2011  rmind sync with head
 1.42.4.3 05-Mar-2011  rmind sync with head
 1.42.4.2 25-Apr-2010  rmind - Invent mm_md_getva() and mm_md_relva() routines, provided by MD and
indicated with __HAVE_MM_MD_PREFER_VA. It will be used to deal with
cache aliasing issues and thus fix little MIPS, ARM and friends.

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

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

Work and depression still in progress.
 1.44.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.48.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.60.6.3 05-Apr-2012  mrg sync to latest -current.
 1.60.6.2 24-Feb-2012  mrg sync to -current.
 1.60.6.1 18-Feb-2012  mrg merge to -current.
 1.60.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.60.2.1 17-Apr-2012  yamt sync with head
 1.62.2.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #251):
sys/arch/powerpc/powerpc/powerpc_machdep.c: revision 1.64
sys/arch/powerpc/include/cpu.h: revision 1.90
Add CPU_EXECPROT sysctl so that atf can enable exec permission tests for
PPC Booke.
 1.64.10.1 23-Jul-2013  riastradh sync with HEAD
 1.64.4.2 18-May-2014  rmind sync with head
 1.64.4.1 28-Aug-2013  rmind sync with head
 1.64.2.2 03-Dec-2017  jdolecek update from HEAD
 1.64.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.2.1 10-Aug-2014  tls Rebase.
 1.70.4.1 06-Apr-2015  skrll Sync with HEAD
 1.71.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.71.18.1 10-Jun-2019  christos Sync with HEAD
 1.71.16.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.72.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #733):

sys/arch/powerpc/powerpc/fpu.c: revision 1.39
sys/arch/powerpc/powerpc/powerpc_machdep.c: revision 1.77

Provide no-op's as pcu_ops_md_defs[PCU_FPU] even if !PPC_HAVE_FPU.

This is required by subr_pcu.c rev 1.21 and later:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_pcu.c#rev1.21

Otherwise, panic occurs when FP instruction is emulated on machines
without FPU.

Note that PowerPC UISA as well as SVR4 ABI require FP instructions,
and emulation is enabled unconditionally on machines without FPU.
 1.75.2.1 29-Feb-2020  ad Sync with head.
 1.80.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.82.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.43 05-Dec-2022  martin Do not bother to set PSL_SE in l_md.md_flags - it is not checked anywhere.
 1.42 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.41 15-Oct-2020  martin branches: 1.41.2;
Add missing 'error' declaration
 1.40 15-Oct-2020  mgorny Fix the machine-dependent ptrace requests to respect LWP number

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

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

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

Reviewed by kamil.
 1.39 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.38 16-Mar-2017  chs branches: 1.38.18;
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.37 09-Mar-2014  matt branches: 1.37.6; 1.37.10; 1.37.14;
Don't test for PSL_SE in tf_srr1 since will be cleared on the next exception.
Keep a copy of it in l_md.md_flags which will be preserved.
 1.36 04-Jan-2014  dsl Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
 1.35 27-Sep-2011  jym branches: 1.35.2; 1.35.12; 1.35.16;
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.34 20-Jun-2011  matt cleanup includes (include <powerpc/psl.h explicitly)
 1.33 17-Jun-2011  matt Fix curlwp check for fpreg/vecreg to acknowledge that the PCU is either
for the current lwp or that PCU is not owned on any cpu.
 1.32 12-Jun-2011  matt Change KASSERT to KASSERTMSG.
 1.31 02-May-2011  matt branches: 1.31.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.30 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.29 18-Jan-2011  matt 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.28 21-Nov-2009  rmind branches: 1.28.4; 1.28.6;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.27 21-Oct-2009  rmind Remove uarea swap-out functionality:

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

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

Discussed on <tech-kern>, reviewed by <ad>.
 1.26 17-Oct-2007  garbled branches: 1.26.20; 1.26.42;
Merge the ppcoea-renovation branch to HEAD.

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

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

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

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.24 04-Mar-2007  christos branches: 1.24.2; 1.24.4; 1.24.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 17-Feb-2007  pavel Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

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

Reviewed by Andrew Doran.
 1.22 28-Nov-2006  elad branches: 1.22.4;
Move ktrace, ptrace, systrace, and procfs to use kauth(9).

First, remove process_checkioperm() calls from MD code. Similar checks
using kauth(9) routines (on the process scope, using appropriate action)
are done in the callers.

Add secmodel back-end to handle each subsystem.
 1.21 01-Mar-2006  yamt branches: 1.21.14; 1.21.16;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.20 11-Dec-2005  christos branches: 1.20.2; 1.20.4; 1.20.6;
merge ktrace-lwp.
 1.19 01-Jun-2005  scw branches: 1.19.2;
Declare the second arg of process_write_{fp,}regs() to be const.
This permits sh5 to continue to re-use those functions in cpu_setmcontext()
with the recent change to Makefile.kern.inc (revision 1.62).
 1.18 16-Apr-2004  matt Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.17 27-Sep-2003  matt ANSIfy.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 29-Jun-2003  fvdl branches: 1.15.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.14 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.13 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.12 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.11 19-Jan-2003  matt Cast to register_t, not int, to be more LP64 friendly.
 1.10 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.9 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.8 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.7 22-Jul-2001  wiz branches: 1.7.6; 1.7.14;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.6 13-Jun-2001  simonb branches: 1.6.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.5 04-Feb-2001  briggs branches: 1.5.2;
Build with -Wall -Wetc.
 1.4 09-Jun-2000  kleink Need <sys/ptrace.h> for declarations.
 1.3 04-Jun-2000  tsubai Add PT_GETFPREGS and PT_SETFPREGS support.
 1.2 03-May-1999  tsubai branches: 1.2.2; 1.2.10;
PT_{STEP,GETREGS,SETREGS} support.
 1.1 30-Sep-1996  ws branches: 1.1.24;
PowerPC port
 1.1.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.2.1 03-Aug-2001  lukem update to -current
 1.7.14.2 31-Aug-2002  gehenna catch up with -current.
 1.7.14.1 16-Jul-2002  gehenna catch up with -current.
 1.7.6.5 01-Aug-2002  nathanw LWPify
 1.7.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.7.6.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.7.6.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.7.6.1 22-Jul-2001  briggs file process_machdep.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.15.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.5 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.15.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.2.4 03-Sep-2007  yamt sync with head.
 1.19.2.3 26-Feb-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.20.6.1 22-Apr-2006  simonb Sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.20.2.1 18-Feb-2006  yamt adapt the rest of MD code.
 1.21.16.1 10-Dec-2006  yamt sync with head.
 1.21.14.1 12-Jan-2007  ad Sync with head.
 1.22.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.22.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.24.10.2 03-Oct-2007  garbled Sync with HEAD
 1.24.10.1 02-Aug-2007  macallan sync with HEAD
 1.24.4.1 11-Jul-2007  mjf Sync with head.
 1.24.2.1 15-Jul-2007  ad Sync with head.
 1.25.10.1 06-Nov-2007  matt sync with HEAD
 1.26.42.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.26.42.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.26.20.1 11-Mar-2010  yamt sync with head
 1.28.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.4.3 31-May-2011  rmind sync with head
 1.28.4.2 21-Apr-2011  rmind sync with head
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.31.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.35.16.1 18-May-2014  rmind sync with head
 1.35.12.2 03-Dec-2017  jdolecek update from HEAD
 1.35.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.37.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.37.6.1 28-Aug-2017  skrll Sync with HEAD
 1.38.18.1 18-Oct-2020  martin Pull up following revision(s) (requested by kamil in ticket #1117):

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

Fix s87_tw reconstruction to correctly indicate register states

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

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

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

Reviewed by kamil.

Add missing 'error' declaration
 1.41.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 06-Apr-2014  martin Make it compilable
 1.8 05-Apr-2014  christos branches: 1.8.2;
adjust to new signature; return consistent stuff. 0 is ok -1 is error
 1.7 17-Oct-2007  garbled branches: 1.7.54; 1.7.64; 1.7.70;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 21-Jul-2007  ad branches: 1.6.6;
Don't depend on uvm_extern.h pulling in proc.h.
 1.5 11-Dec-2005  christos branches: 1.5.30; 1.5.38; 1.5.42; 1.5.44;
merge ktrace-lwp.
 1.4 15-Jul-2003  lukem branches: 1.4.16;
__KERNEL_RCSID()
 1.3 29-Jun-2003  fvdl branches: 1.3.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.1 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.3.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.2 03-Sep-2007  yamt sync with head.
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.5.44.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.42.1 07-Aug-2007  matt Sync with HEAD.
 1.5.38.2 03-Oct-2007  garbled Sync with HEAD
 1.5.38.1 02-Aug-2007  macallan sync with HEAD
 1.5.30.1 20-Aug-2007  ad Sync with HEAD.
 1.6.6.1 06-Nov-2007  matt sync with HEAD
 1.7.70.1 18-May-2014  rmind sync with head
 1.7.64.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.54.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.2.1 10-Aug-2014  tls Rebase.
 1.16 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

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

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.15 07-Sep-2025  thorpej Remove unnecessary NULL-initialization of TODR handle fields.
 1.14 28-Feb-2014  matt Use uintptr_t for ras_entry
 1.13 17-Jul-2011  joerg branches: 1.13.2; 1.13.12; 1.13.16;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.12 20-Jun-2011  matt cleanup includes (include <powerpc/psl.h explicitly)
 1.11 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.10 12-Jun-2011  mrg convert to device_t and CFATTACH_DECL_NEW.
now my ofppc system has none left.
 1.9 09-Nov-2010  uebayasi branches: 1.9.6;
Use VM_PAGE_TO_PHYS().
 1.8 08-Apr-2008  garbled branches: 1.8.24; 1.8.26;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.7 27-Mar-2008  phx Restrict RTAS instantiation to the first 256MB. Other memory regions may not
be mapped by OpenFirmware.
 1.6 28-Dec-2007  garbled branches: 1.6.6;
Add one more convenience function to rtas, rtas_has_func, and add a
global int machine_has_rtas that can be used to decide if a machine has
rtas functionality or not. Take a crack at power off support for the
pegasos, which doesn't work right, probably due to a firmware bug.
 1.5 28-Dec-2007  garbled Rewrite the rtas_call command, to allow ports to call rtas directly from
outside rtas.c, by simply issuing the right token. This makes using the
rtas functionality much simpler.
 1.4 27-Dec-2007  garbled Make the reboot function work when in single/multi user mode. I have no
idea why this makes it work, but apparently it needs to return status,
and if it doesn't, it won't reboot. (unless you call it at the askroot
prompt, then it worked fine). *boggle*.
 1.3 04-Nov-2007  garbled branches: 1.3.2; 1.3.8;
Get rid of the ofppc use of the ofbus completely, for the last time.

Write a complete OF boot console into ofw_consinit.c and rewire a bunch
of the ifdef logic in that file to use it when appropriate on both macppc
and ofppc. Get rid of the attempt to wire up the serial console early,
as that is extremely difficult on ofppc. Yank all the console code out
of ofppc/machdep.c. (This is a boot console only, not a full blown
console like ofcons.c)

Delete all the ofbus references out of the config files, and pull in
dev/ofw/openfirmio.c and dev/ofw/ofw_subr.c directly rather than pulling
in files.ofw. It might be worth going back and adding a files.ofw-nobus
to that directory to allow pulling in the openfirmware driver without
pulling in the whole ofbus mess.

Change rtas driver to connect directly to mainbus, like the PCI bus nodes do.
 1.2 25-Oct-2007  garbled Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.1 14-Jan-2007  aymeric branches: 1.1.2; 1.1.6; 1.1.10; 1.1.26; 1.1.28; 1.1.32;
Basic support for RTAS (CHRP's Run-Time Abstraction Services).
Tested on the Efika; now it knows what time it is.
rtas can attach to mainbus. Not added to any kernel config file yet.
 1.1.32.1 13-Nov-2007  bouyer Sync with HEAD
 1.1.28.2 09-Jan-2008  matt sync with HEAD
 1.1.28.1 06-Nov-2007  matt sync with HEAD
 1.1.26.2 04-Nov-2007  jmcneill Sync with HEAD.
 1.1.26.1 28-Oct-2007  joerg Sync with HEAD.
 1.1.10.2 03-Dec-2007  ad Sync with HEAD.
 1.1.10.1 03-Dec-2007  ad Sync with HEAD.
 1.1.6.5 21-Jan-2008  yamt sync with head
 1.1.6.4 15-Nov-2007  yamt sync with head.
 1.1.6.3 27-Oct-2007  yamt sync with head.
 1.1.6.2 26-Feb-2007  yamt sync with head.
 1.1.6.1 14-Jan-2007  yamt file rtas.c was added on branch yamt-lazymbuf on 2007-02-26 09:07:57 +0000
 1.1.2.2 01-Feb-2007  ad Sync with head.
 1.1.2.1 14-Jan-2007  ad file rtas.c was added on branch newlock2 on 2007-02-01 08:48:10 +0000
 1.3.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.6.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.26.1 05-Mar-2011  rmind sync with head
 1.8.24.1 09-Feb-2010  uebayasi Kill vm_page::phys_addr.
 1.9.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.16.1 18-May-2014  rmind sync with head
 1.13.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.9 17-Jun-2011  matt include <machine/psl.h>
 1.8 18-Jan-2011  matt branches: 1.8.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.7 17-Jan-2011  matt Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.6 20-Mar-2010  chs branches: 1.6.2;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.98; 1.5.100; 1.5.104;
merge ktrace-lwp.
 1.4 03-Aug-2003  matt Don't use stmw. Do each store individually.
 1.3 31-Jul-2003  matt Convert to the load/store pseudo-instructions.
 1.2 14-Mar-2003  matt branches: 1.2.2;
make LINTSTUB work with this.
 1.1 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.104.1 07-Jan-2011  matt Add booke support.
 1.5.100.2 05-Mar-2011  rmind sync with head
 1.5.100.1 30-May-2010  rmind sync with head
 1.5.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.78.1 11-Aug-2010  yamt sync with head.
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5 29-Apr-2025  martin PR port-powerpc/59306: kernel longjmp(9) only takes one argument,
always make setjmp(9) return 1.
Change as suggested by Taylor.
 1.4 17-Jan-2011  matt branches: 1.4.94;
Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.3 11-Dec-2005  christos branches: 1.3.100; 1.3.106;
merge ktrace-lwp.
 1.2 31-Jul-2003  matt Use register prefixes and load/store pseudo-instructions.
 1.1 27-Jan-1998  sakamoto branches: 1.1.48;
Import DDB from OpenBSD/powerpc.
 1.1.48.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.48.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.48.1 03-Aug-2004  skrll Sync with HEAD
 1.3.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.100.1 05-Mar-2011  rmind sync with head
 1.4.94.1 02-Aug-2025  perseant Sync with HEAD
 1.55 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.54 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.53 27-Oct-2021  thorpej Use the signal trampoline version constants from <sys/signal.h>.
 1.52 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.51 22-Jun-2020  rin Fix previous; hide userland ABI details for kernel as suggested by joerg:

http://mail-index.netbsd.org/source-changes-d/2020/06/21/msg012745.html

- Revive __lwp_settcb(), and call _lwp_setprivate(2) from it.

- Keep l_private opaque pointer for kernel; store raw value of %r2 in it.
In the previous commit message, I wrote,

http://mail-index.netbsd.org/source-changes/2020/06/21/msg118524.html

> - Make sure that, like other ports, l_private represents address of tcb,
> not biased one as in %r2.

but, it turned out to be wrong. mips stores a biased address, at least.
It is userland responsibility to interpret returned values from
lwp_getprivate(2).
 1.50 21-Jun-2020  rin Fix inconsistency b/w kernel and userland recognitions of TLS, as well as
inconsistency whether it is biased or not in kernel.

- Obsolete __lwp_settcb() in order to let kernel know new TLS address via
_lwp_setprivate(2). Alternatively, we can call _lwp_setprivate(2) within
__lwp_settcb() like mips, but it is just double handling; we adjust %r2
appropriately in _lwp_setprivate(2) via cpu_lwp_setprivate().

- Make sure that, like other ports, l_private represents address of tcb,
not biased one as in %r2. This guarantees that the returned values from
_lwp_getprivate(2) and __lwp_getprivate_fast() are always same. Also,
we can obsolete PTRACE_LWP_GETPRIVATE() macro.

Now, *_pl_private tests in tests/lib/libc/sys successfully pass, while
no other tests become newly falling.
 1.49 21-Jun-2020  rin Fix SS_ONSTACK, which seems like broken since switched to siginfo.

Found by tests/lib/libc/sys/t_sigaltstack, which passes now, while
no other tests are not falling newly.

XXX
Shouldn't we turn _UC_{SET,CLR}STACK into MI?
 1.48 11-Apr-2020  rin Revert previous:
http://mail-index.netbsd.org/source-changes/2020/02/20/msg114173.html

Comment turned out to be wrong, and KASSERT fires for oea.

XXX
Need to revisit shortly...
 1.47 20-Feb-2020  rin branches: 1.47.4;
libpthread sets initial value of MSR for lwp's. However, appropriate
value differs b/w oea/booke/ibm4xx, and there's no way to obtain it
from userland. Therefore, this initial value should be corrected by
cpu_setmcontext().

- Comment this in libpthread
- Add KASSERT in cpu_mcontext_validate()
 1.46 27-Nov-2018  maxv branches: 1.46.4; 1.46.6;
Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.45 05-Mar-2017  chs branches: 1.45.6; 1.45.12; 1.45.14;
in cpu_setmcontext(), do not update the TLS register (r2) as part of _UC_CPU.
if _UC_TLSBASE is set, use lwp_setprivate() to update both r2 and the
common field in struct lwp.
 1.44 14-Dec-2014  chs branches: 1.44.2; 1.44.4;
fix powerpc TLS problems by removing the hacks for PPC EABI.
the kernel no longer treats R2 specially and its use as
the TLS register is now handled entirely in userland.
 1.43 11-Sep-2012  matt branches: 1.43.2; 1.43.14; 1.43.16;
Add support for _UC_TLSBASE. Make sure to preserve backwards compat for
programs built before TLS support was added.
 1.42 21-May-2012  martin Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.

To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.

Add an exhaustive atf test case, based partly on code from Joel Sing.

Should finally fix the remaining open part of PR kern/43903.
 1.41 20-Jun-2011  matt branches: 1.41.2; 1.41.6; 1.41.8;
cleanup includes (include <powerpc/psl.h explicitly)
 1.40 16-Mar-2011  matt branches: 1.40.2;
Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.39 07-Feb-2011  matt PR port-macppc/43619
Save handler before calling sendsig_reset before it will reset to SIG_DFL
is SA_RESETHAND is set.
 1.38 18-Jan-2011  matt branches: 1.38.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.37 14-Jan-2011  rmind branches: 1.37.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.36 27-Nov-2009  rmind branches: 1.36.4;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.35 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.34 21-Nov-2008  he The sendsig_sigcontext() here should most probably be sendsig_siginfo().
Based on hints from other developers.
 1.33 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.32 24-Apr-2008  ad branches: 1.32.2; 1.32.4; 1.32.8; 1.32.10; 1.32.12; 1.32.20;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.31 17-Oct-2007  garbled branches: 1.31.16; 1.31.18;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.30 08-Jul-2007  pooka branches: 1.30.10;
Initialize the link context in a signal frame to the receiving lwp's
link context instead of NULL. Otherwise, if we got a signal while the
lwp had a link context set, the link context would be set to NULL upon
return from signal delivery.

christos@tech-kern: "I think you are right."
 1.29 04-Mar-2007  christos branches: 1.29.2; 1.29.4; 1.29.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 10-Feb-2007  ad branches: 1.28.2;
Fix a pasto (mutex_exit -> mutex_enter).
 1.27 09-Feb-2007  ad Merge newlock2 to head.
 1.26 24-Oct-2006  he The new gcc propagates const-ness from structs to members, so
make local variable const as well. Avoid writing to the now-const
variable, instead do the masking before in the trapframe register
assignment.

OK'ed by thorpej and nathanw.
 1.25 26-Mar-2006  shige branches: 1.25.8; 1.25.10;
Make cpu_setmcontext() fix up the passed-in MSR value.
 1.24 11-Dec-2005  christos branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
merge ktrace-lwp.
 1.23 16-Apr-2004  matt branches: 1.23.10; 1.23.12; 1.23.20;
Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.22 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.21 04-Apr-2004  matt In cpu_getmcontext, make sure the returned MSR has the FP exception mode
(PSL_FE0|PSL_FE1) saved in the PSL. In cpu_setmcontext, copy the FP
exception bits to the PCB where they live.
 1.20 04-Apr-2004  matt Fix the way cpu_setmcontext was restoring FPSCR. Make the opposite of the
way that cpu_getmcontext was saving it. (FPSCR was being saved incorrectly
before and thus obliterated when a signal happened).
 1.19 11-Dec-2003  matt Copy ksi->ksi_info, not all of ksi, to user stack.
 1.18 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

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

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.17 27-Sep-2003  matt Use ksi_signo instead of _signo.
 1.16 26-Sep-2003  matt Copy out the entire ksiginfo_t, not just the first word.
 1.15 25-Sep-2003  christos constify siginfo/trapsignal
 1.14 25-Sep-2003  matt Use direct entry for siginfo trampoline. Deal with missing
legacy trampolines in a cleaner manner.
 1.13 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.12 15-Jul-2003  lukem __KERNEL_RCSID()
 1.11 03-Feb-2003  matt branches: 1.11.2;
Don't use trapframe in sigcontext. Instead define a new structure
utrapframe that fixed in size (and the same size as the trapframe
in NetBSD 1.5). This preserves binary compatibility for those programs
that dealt looked at sigcontexts.
 1.10 20-Jan-2003  matt Kill all references to struct __gregs and use the _REG_xx names.
 1.9 18-Jan-2003  matt Cast to register_t, not int, to be more _LP64 friendly.
 1.8 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.6 04-Jul-2002  thorpej Eliminate two unused sigframe members.
 1.5 28-May-2001  matt branches: 1.5.2; 1.5.8; 1.5.16;
Change the bcopy's to structure assignments.
 1.4 22-Dec-2000  jdolecek branches: 1.4.2;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.3 03-Apr-2000  tsubai branches: 1.3.6;
When call a signal handler, don't pass the kernel (local) address in r5.
 1.2 22-Nov-1999  tsubai branches: 1.2.2;
Need opt_compat_netbsd.h.
 1.1 17-Nov-1999  kleink Move signal management code common to all PowerPC platforms (sendsig(),
sigreturn(), sigcode) to a single place in the shared powerpc directory.
(The struct sigcontext etc. definitions were already being shared.)
 1.2.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.6.3 05-Jan-2001  bouyer Sync with HEAD
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 03-Apr-2000  bouyer file sig_machdep.c was added on branch thorpej_scsipi on 2000-11-20 20:31:17 +0000
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.16.1 16-Jul-2002  gehenna catch up with -current.
 1.5.8.10 27-Aug-2002  nathanw Adapt to changes in FPU handling in cpu_{get,set}mcontext().
 1.5.8.9 01-Aug-2002  nathanw LWPify
 1.5.8.8 01-Aug-2002  nathanw Catch up to -current.
 1.5.8.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.5.8.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.5.8.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.5.8.4 02-Apr-2002  nathanw The memcpy(9) function takes a byte length to copy, not a number of
array elements. Therefore, when computing the size of the
floating-point register storage, don't divide by the size of a single
FP register.

cpu_setmcontext() and cpu_getmcontext() now operate on all 32 FP
registers, not just the first four.
 1.5.8.3 17-Nov-2001  briggs Update to Current World Order.
 1.5.8.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.5.8.1 28-May-2001  briggs file sig_machdep.c was added on branch nathanw_sa on 2001-11-05 19:46:18 +0000
 1.5.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.20.1 28-Mar-2006  riz Pull up following revision(s) (requested by shige in ticket #1223):
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.25
Make cpu_setmcontext() fix up the passed-in MSR value.
 1.23.12.4 03-Sep-2007  yamt sync with head.
 1.23.12.3 26-Feb-2007  yamt sync with head.
 1.23.12.2 30-Dec-2006  yamt sync with head.
 1.23.12.1 21-Jun-2006  yamt sync with head.
 1.23.10.1 28-Mar-2006  riz Pull up following revision(s) (requested by shige in ticket #1223):
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.25
Make cpu_setmcontext() fix up the passed-in MSR value.
 1.24.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.24.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.24.8.1 01-Apr-2006  yamt sync with head.
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.25.10.1 10-Dec-2006  yamt sync with head.
 1.25.8.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.25.8.2 28-Jan-2007  ad powerpc changes.
 1.25.8.1 18-Nov-2006  ad Sync with head.
 1.28.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.10.2 03-Oct-2007  garbled Sync with HEAD
 1.29.10.1 02-Aug-2007  macallan sync with HEAD
 1.29.4.1 11-Jul-2007  mjf Sync with head.
 1.29.2.1 15-Jul-2007  ad Sync with head.
 1.30.10.1 06-Nov-2007  matt sync with HEAD
 1.31.18.1 18-May-2008  yamt sync with head.
 1.31.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.31.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.20.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.32.20.1 07-Jan-2011  matt Adapt to new trapframe.
 1.32.12.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by jmmv in ticket #1551):
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.39 via patch
PR port-macppc/43619
Save handler before calling sendsig_reset before it will reset to SIG_DFL
is SA_RESETHAND is set.
 1.32.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.8.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.32.4.2 15-Oct-2008  wrstuden Remove some now-unneeded includes. Matches previous changes to i386 code.
 1.32.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.32.2.2 11-Mar-2010  yamt sync with head
 1.32.2.1 04-May-2009  yamt sync with head.
 1.36.4.2 21-Apr-2011  rmind sync with head
 1.36.4.1 05-Mar-2011  rmind sync with head
 1.37.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.40.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.41.8.1 21-May-2012  riz Pull up following revision(s) (requested by martin in ticket #274):
sys/arch/amd64/amd64/process_machdep.c: revision 1.20
sys/kern/sys_lwp.c: revision 1.54
sys/arch/sparc64/sparc64/machdep.c: revision 1.267
sys/arch/mips/mips/cpu_subr.c: revision 1.16
sys/arch/vax/vax/machdep.c: revision 1.188
sys/sys/lwp.h: revision 1.161
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.98
sys/arch/alpha/alpha/machdep.c: revision 1.339
sys/compat/sys/ucontext.h: revision 1.6
sys/arch/hppa/hppa/hppa_machdep.c: revision 1.28
distrib/sets/lists/tests/mi: revision 1.469
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.42
tests/lib/libc/sys/t_lwp_create.c: revision 1.1
tests/lib/libc/sys/Makefile: revision 1.23
sys/arch/arm/arm/sig_machdep.c: revision 1.42
sys/arch/amd64/include/mcontext.h: revision 1.15
sys/arch/amd64/amd64/machdep.c: revision 1.183
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.99
sys/arch/i386/i386/machdep.c: revision 1.727
sys/compat/netbsd32/netbsd32_lwp.c: revision 1.13
sys/arch/sparc/sparc/machdep.c: revision 1.319
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.76
sys/arch/m68k/m68k/sig_machdep.c: revision 1.49
sys/sys/ucontext.h: revision 1.16
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.9
lib/libc/sys/_lwp_create.2: revision 1.5
Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.
To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.
Add an exhaustive atf test case, based partly on code from Joel Sing.
Should finally fix the remaining open part of PR kern/43903.
 1.41.6.1 02-Jun-2012  mrg sync to latest -current.
 1.41.2.2 30-Oct-2012  yamt sync with head
 1.41.2.1 23-May-2012  yamt sync with head.
 1.43.16.2 28-Aug-2017  skrll Sync with HEAD
 1.43.16.1 06-Apr-2015  skrll Sync with HEAD
 1.43.14.2 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.43.14.1 31-Dec-2014  snj branches: 1.43.14.1.2; 1.43.14.1.6;
Pull up following revision(s) (requested by chs in ticket #364):
lib/libc/tls/tls.c: revision 1.8
libexec/ld.elf_so/tls.c: revision 1.10
sys/arch/powerpc/include/types.h: revision 1.50
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.44
fix powerpc TLS problems by removing the hacks for PPC EABI.
the kernel no longer treats R2 specially and its use as
the TLS register is now handled entirely in userland.
 1.43.14.1.6.1 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.43.14.1.2.1 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.43.2.1 03-Dec-2017  jdolecek update from HEAD
 1.44.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.44.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.45.14.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.45.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.45.14.1 10-Jun-2019  christos Sync with HEAD
 1.45.12.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.45.6.1 27-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1173):
sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/riscv/riscv/sig_machdep.c: revision 1.2
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.46.6.1 29-Feb-2020  ad Sync with head.
 1.46.4.2 12-Apr-2020  martin Pull up following revision(s) (requested by rin in ticket #826):

lib/libpthread/arch/powerpc/pthread_md.h: revision 1.9
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.48

Revert previous:
http://mail-index.netbsd.org/source-changes/2020/02/20/msg114173.html
Comment turned out to be wrong, and KASSERT fires for oea.

XXX
Need to revisit shortly...
 1.46.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #736):

lib/libpthread/arch/powerpc/pthread_md.h: revision 1.8
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.47

libpthread sets initial value of MSR for lwp's. However, appropriate
value differs b/w oea/booke/ibm4xx, and there's no way to obtain it
from userland. Therefore, this initial value should be corrected by
cpu_setmcontext().

- Comment this in libpthread
- Add KASSERT in cpu_mcontext_validate()
 1.47.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.8 28-Feb-2014  matt Remove _LP64 since it's only used on 32-bit
 1.7 17-Jan-2011  matt branches: 1.7.6; 1.7.16; 1.7.20;
Kill _NOREGNAMES. Everything should be using %rX now. If it doesn't it
soon will.
 1.6 11-Dec-2005  christos branches: 1.6.100; 1.6.106;
merge ktrace-lwp.
 1.5 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.4 19-Jan-2003  matt branches: 1.4.2;
Improve sigcode.S template so linux_sigcode.S can use it as well. Add a
netbsd32_sigcode.S.
 1.3 18-Jan-2003  matt Allow other compat use this as a template.
 1.2 04-Jul-2002  thorpej Eliminate two unused sigframe members.
 1.1 17-Nov-1999  kleink branches: 1.1.2; 1.1.8; 1.1.12; 1.1.16; 1.1.24;
Move signal management code common to all PowerPC platforms (sendsig(),
sigreturn(), sigcode) to a single place in the shared powerpc directory.
(The struct sigcontext etc. definitions were already being shared.)
 1.1.24.1 16-Jul-2002  gehenna catch up with -current.
 1.1.16.4 06-Aug-2002  nathanw Don't need the global declaration for upcallcode.
 1.1.16.3 01-Aug-2002  nathanw Catch up to -current.
 1.1.16.2 19-Jul-2002  nathanw Don't need upcall trampolines.
 1.1.16.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.1.12.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.8.1 17-Nov-1999  bouyer file sigcode.S was added on branch thorpej_scsipi on 2000-11-20 20:31:18 +0000
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.100.1 05-Mar-2011  rmind sync with head
 1.7.20.1 18-May-2014  rmind sync with head
 1.7.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3 09-Aug-2001  tsutsui This file is no longer used. (moved to ofppc/soft_spl.c)
 1.2 15-Jan-2001  thorpej branches: 1.2.4;
Make softclock a generic soft interrupt of the API is available,
adding the requisite void * argument to softclock().
 1.1 16-Apr-1997  thorpej branches: 1.1.22;
"Simulated" software-spl handling, for use on OpenFirmware systems.
These are for a generalized "machine vector" designed to hide
differences between various PowerPC systems.
From Wolfgang Solfrank <ws@tools.de>
 1.1.22.1 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.4 08-Jan-2020  ad Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
calling cpu_switchto(). It's not safe to let other actors mess with the
LWP (in particular l->l_cpu) while it's still context switching. This
removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead. Everything
is in cache anyway so it wasn't buying much by trying to avoid saving old
state. This means cpu_switchto() will never be called with prevlwp ==
NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
 1.3 27-Sep-2011  jym branches: 1.3.2; 1.3.56; 1.3.62;
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.2 21-Jun-2011  matt branches: 1.2.2;
Add an extra assert to verify we aren't trying to process softints while
interrupts are being serviced.
 1.1 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.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 21-Jun-2011  cherry file softint_machdep.c was added on branch cherry-xenmp on 2011-06-23 14:19:35 +0000
 1.3.62.1 17-Jan-2020  ad Sync with head.
 1.3.56.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.3.2.1 27-Sep-2011  matt file softint_machdep.c was added on branch matt-nb5-pq3 on 2011-10-14 17:21:26 +0000
 1.9 03-Dec-2007  ad Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.8 12-Mar-2007  ad branches: 1.8.16; 1.8.18; 1.8.24;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.7 30-Jan-2007  freza branches: 1.7.2; 1.7.6;
Document that unprotected access to softintr cookie is safe in
softintr_disestablish(), upon request from uebayasi@.
 1.6 30-Jan-2007  freza Protect softintr queues by direct manipulation of PSL_EE because PowerPC
ports have different IPL hierarchies. On macppc, IPL_VM is below IPL_AUDIO
and IPL_SERIAL so the queues got corrupted due to priority inversion.
Also fix a race condition in softintr_schedule() when testing "si_refs > 1",
it can lead to queue corruption and subsequent panic (below). As a side
effect, using PSL_EE directly is faster than going via spl*()/splx().

This is supposed to fix (XXX I don't have the hw):

Panic: kernel diagnostic assert "si->si_refs > 0" failed: file
"[...]arch/powerpc/powerpc/softintr.c" line 116

reported for example in:

http://mail-index.netbsd.org/port-macppc/2007/01/25/0001.html

Discussed with briggs@ and macallan@.
 1.5 12-Apr-2006  simonb branches: 1.5.8;
Add a NetBSD RCS id.
 1.4 24-Dec-2005  perry branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 25-Mar-2004  matt branches: 1.2.4; 1.2.18;
Move data structures to softintr.c. Remove an unneeded if. Fix a typo.
 1.1 24-Mar-2004  matt Generic soft interrupt support for PowerPC ports.
 1.2.18.4 07-Dec-2007  yamt sync with head
 1.2.18.3 03-Sep-2007  yamt sync with head.
 1.2.18.2 26-Feb-2007  yamt sync with head.
 1.2.18.1 21-Jun-2006  yamt sync with head.
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 25-Mar-2004  skrll file softintr.c was added on branch ktrace-lwp on 2004-08-03 10:39:37 +0000
 1.4.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.4.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.4.8.1 24-May-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.8.1 01-Feb-2007  ad Sync with head.
 1.7.6.1 13-Mar-2007  ad Sync with head.
 1.7.2.1 24-Mar-2007  yamt sync with head.
 1.8.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.18.1 23-Mar-2008  matt sync with HEAD
 1.8.16.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.6 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.5 11-Dec-2005  christos branches: 1.5.166;
merge ktrace-lwp.
 1.4 27-Sep-2003  matt ANSIfy.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 09-Jun-2000  kleink branches: 1.2.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.166.1 10-Jun-2019  christos Sync with HEAD
 1.6 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.5 11-Dec-2005  christos branches: 1.5.166;
merge ktrace-lwp.
 1.4 27-Sep-2003  matt ANSIfy.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 09-Jun-2000  kleink branches: 1.2.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.166.1 10-Jun-2019  christos Sync with HEAD
 1.6 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.5 11-Dec-2005  christos branches: 1.5.166;
merge ktrace-lwp.
 1.4 27-Sep-2003  matt ANSIfy.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 09-Jun-2000  kleink branches: 1.2.26;
Need <sys/systm.h> for declaration, and make argument declarations match.
 1.1 30-Sep-1996  ws branches: 1.1.28; 1.1.36;
PowerPC port
 1.1.36.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.28.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.166.1 10-Jun-2019  christos Sync with HEAD
 1.2 31-Jan-1997  thorpej This file is obsolete; this information is now generated by config(8).
 1.1 30-Sep-1996  ws PowerPC port
 1.13 07-Apr-2011  matt Get rid of cpu_lwp_setprivate since it's not needed on powerpc.
 1.12 12-Mar-2011  matt Simplify cpu_lwp_setprivate.
 1.11 18-Jan-2011  matt 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.10 07-Jul-2010  chs branches: 1.10.2;
implement cpu_lwp_setprivate() on several platforms.
 1.9 22-Dec-2007  dsl branches: 1.9.10; 1.9.12; 1.9.30; 1.9.32;
Fix the remaining sys_sysarch() stub function.
 1.8 09-Feb-2007  ad branches: 1.8.24; 1.8.32; 1.8.36;
Merge newlock2 to head.
 1.7 11-Dec-2005  christos branches: 1.7.20;
merge ktrace-lwp.
 1.6 27-Sep-2003  matt branches: 1.6.16;
ANSIfy.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 18-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 09-Jun-2000  kleink branches: 1.3.10;
Need <sys/syscallargs.h> for declaration of sys_sysarch().
 1.2 25-Feb-1998  perry branches: 1.2.14; 1.2.22;
note second parm of sysarch() is now void *, + trivial KNF, etc.
 1.1 30-Sep-1996  ws PowerPC port
 1.2.22.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.10.2 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.10.1 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.2 21-Jan-2008  yamt sync with head
 1.6.16.1 26-Feb-2007  yamt sync with head.
 1.7.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.8.36.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.32.1 26-Dec-2007  ad Sync with head.
 1.8.24.1 09-Jan-2008  matt sync with HEAD
 1.9.32.2 21-Apr-2011  rmind sync with head
 1.9.32.1 05-Mar-2011  rmind sync with head
 1.9.30.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.12.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.9.10.1 11-Aug-2010  yamt sync with head.
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.58 05-Oct-2023  ad Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
 1.57 06-Jul-2020  rin Drop unused opt_altivec.h and opt_multiprocessor.h.
 1.56 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.55 06-Apr-2019  kamil Centralized shared part of child_return() into MI part

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

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

Synchronize value passed to ktrsysret() among ports to SYS_fork. This is
a traditional value and accessing p_lflag to check for PL_PPWAIT shall
use locking against proc_lock. Returning SYS_fork vs SYS_vfork still isn't
correct enough as there are more entry points to forking code. Instead of
making it too good, just settle with plain SYS_fork for all ports.
 1.54 03-Apr-2019  kamil Rework the fork(2)/vfork(2) event signalling under ptrace(2)

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

Now all SIGTRAP TRAP_CHLD events are delivered to debugger.

This code touches MD specific logic and the child_return routine.
It's an intermediate step with a room for refactoring in future and
right now the least invasive approach. This allows to assert expected
behavior in already existing ATF tests and make the code prettier
in future keeping the same semantics. Probably there is a need for a MI
wrapper of child_return for shared functionality between ports.
 1.53 03-Nov-2013  mrg branches: 1.53.30;
- remove set but unused variables
 1.52 26-Jun-2013  matt branches: 1.52.2;
Use sy_invoke
 1.51 20-Jul-2012  matt branches: 1.51.2;
Use the new syscall approach by collapsing fancy/plain variants into just
a single routine.
 1.50 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.49 13-Dec-2011  kiyohara Remove white-spaces.
 1.48 26-Apr-2011  joerg branches: 1.48.4; 1.48.8;
Remove Darwin, MACH and Mach-O support.
 1.47 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.46 18-Jan-2011  matt 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.45 14-Jan-2011  rmind branches: 1.45.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.44 21-Nov-2009  rmind branches: 1.44.4;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.43 21-Oct-2008  ad branches: 1.43.16;
Provide a small inline wrapper for sysent::sy_call() and use it to store
the active syscall description in struct lwp. To be used at some future
point to prevent unloading of modules that provide syscalls, while the
syscalls are in use.
 1.42 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.41 24-Apr-2008  ad branches: 1.41.2; 1.41.4; 1.41.8;
- Retire SYCALL_MPSAFE. With the exceptions of darwin and irix emulations,
all system calls are now MPSAFE.
- Remove unneeded acquire/release of kernel_lock.
 1.40 07-Feb-2008  matt branches: 1.40.6; 1.40.8;
narg -> sy_narg
 1.39 06-Feb-2008  dsl Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
 1.38 05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.37 02-Jan-2008  ad Merge vmlocking2 to head.
 1.36 05-Nov-2007  ad branches: 1.36.2; 1.36.4; 1.36.8;
Don't set l_usrpri / spc_curpriority here. mi_userret() does it.
 1.35 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.34 15-Aug-2007  ad branches: 1.34.2; 1.34.6;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.33 04-Mar-2007  christos branches: 1.33.2; 1.33.10; 1.33.14; 1.33.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.32 09-Feb-2007  ad branches: 1.32.2;
Merge newlock2 to head.
 1.31 19-Jul-2006  ad branches: 1.31.4;
- Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
 1.30 07-Mar-2006  thorpej branches: 1.30.2;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.29 06-Mar-2006  he syscall_fancy is only defined if either KTRACE or SYSTRACE is set,
so enclose its use in the same set of conditionals.
 1.28 05-Mar-2006  rjs Always define syscall_fancy.
 1.27 05-Mar-2006  christos Add a proc_is_traced_p() macro and use it, instead of copying the same code
in many places. Idea from thorpej.
 1.26 05-Mar-2006  christos branches: 1.26.2;
implement PT_SYSCALL
 1.25 11-Dec-2005  christos branches: 1.25.4; 1.25.6;
merge ktrace-lwp.
 1.24 01-Jul-2005  christos branches: 1.24.2;
PR/29607: Christian Biere systrace doesn't handle interrupted syscalls properly
Instead of jumping to the default "bad" case, jump to the error handling
switch, so that we can deal with ERESTART/EJUSTRETURN properly.
 1.23 31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.22 10-Jul-2003  matt Back out rev 1.19. It's wrong. Add comments so it doesn't happen again.
 1.21 29-Jun-2003  fvdl branches: 1.21.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.20 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.19 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.18 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.17 21-Dec-2002  manu Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
 1.16 29-Nov-2002  manu The recent mach trap support caused indirect system calls (a la syscall(2))
to be incorectly recorded as 'syscall'. Fix this.
 1.15 15-Nov-2002  manu Darwin skips the next instruction after a successful system call. Strange
world.
 1.14 15-Nov-2002  manu Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
 1.13 13-Nov-2002  matt Change syscall to bound code so that systrace and ktrace won't fall off
the end of a table. XXX this is wrong since code does not indicate the
sysent table for which code was used as an index.
 1.12 04-Nov-2002  matt Get rid of nsysent. Use EMULNAMEU to use the appropriate constant.
Revamp the mach_syscall_dispatch function to be much simplier (pass in
a syscall code and return a const struct sysent * pointer).
 1.11 03-Nov-2002  manu Added support for Darwin's PowerPC-only system calls:
ppccalls, with system call numbers starting at 0x6000
fasttraps, with system call numbers starting at 0x7FF0

Because the Mach system call dispatching code has grown a bit
too much, introduce an inline function to handle it (mach_syscall_dispatch).

While we are there, remove the Mach and Linux includes from
arch/powerpc/powerpc/syscall.c and push them into
arch/powerpc/powerpc/{mach|linux}_syscall.c
 1.10 02-Nov-2002  jdolecek back previous revision 1.9 off - compat code was changed to set
struct emul e_nsysent to *SYS_NSYSENT now, and the mask is more efficient
 1.9 01-Nov-2002  matt In struct emul, e_nsysent is *not* initialized to *SYS_NSYSENT but
*SYS_MAXSYSCALL. Adjust to this and simply compare 'code' to it instead
of doing the p-o-2 dance.
 1.8 30-Oct-2002  matt Move child_return back to syscall.c
Fix syscall to use emulations SYS_syscall/SYS___syscall definitions.
Use the emulation NSYSENT to limit code.
Don't define *syscall_fancy if it will never be used.
 1.7 30-Oct-2002  manu Fixed mistakes
 1.6 30-Oct-2002  manu Add COMPAT_MACH and EXEC_MACHO support on the PowerPC
 1.5 30-Oct-2002  manu Prepare syscall.c for COMPAT_MACH support. linux_syscall_intern is
moved to a Linux specific file, child_return is moved to trap.c,
and we introduce a EMULNAME macro co that syscall.c can be included to
define the system call handler for another emulation.
 1.4 02-Aug-2002  chs branches: 1.4.2;
use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.3 28-Jul-2002  chs branches: 1.3.2;
create a syscall_plain() like on other platforms
and avoid getting the kernel lock for MPSAFE syscalls.
 1.2 11-Jul-2002  matt branches: 1.2.2;
Add a linux_syscall_intern entry (appropriately ifdef'ed COMPAT_LINUX).
When/if PPC ever supports LKMs, this should be moved to a separate file.
 1.1 28-Jun-2002  matt Add common syscall dispatcher. Also put child_return in here.
 1.2.2.3 31-Aug-2002  gehenna catch up with -current.
 1.2.2.2 16-Jul-2002  gehenna catch up with -current.
 1.2.2.1 11-Jul-2002  gehenna file syscall.c was added on branch gehenna-devsw on 2002-07-16 13:10:00 +0000
 1.3.2.13 29-Dec-2002  thorpej Sync with HEAD.
 1.3.2.12 11-Dec-2002  thorpej Sync with HEAD.
 1.3.2.11 10-Dec-2002  thorpej Fix unused variable when KTRACE is not defined. From Bill Studenmund.
 1.3.2.10 10-Dec-2002  thorpej LWP'ify KERNEL_PROC_{,UN}LOCK() calls.
 1.3.2.9 03-Dec-2002  gmcgarry Pull in sys/sa.h and sys/savar.h for sa_upcall_userret() prototype.
 1.3.2.8 03-Dec-2002  gmcgarry LWPify
 1.3.2.7 11-Nov-2002  nathanw Catch up to -current
 1.3.2.6 27-Aug-2002  nathanw Avoid an unused-variable warning in child_return().
 1.3.2.5 06-Aug-2002  nathanw Need sa includes here.
 1.3.2.4 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.3.2.3 01-Aug-2002  nathanw LWPify
 1.3.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.1 28-Jul-2002  nathanw file syscall.c was added on branch nathanw_sa on 2002-08-01 02:43:11 +0000
 1.4.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.1 02-Aug-2002  jdolecek file syscall.c was added on branch kqueue on 2002-09-06 08:39:28 +0000
 1.21.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.2 03-Aug-2004  skrll Sync with HEAD
 1.21.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.24.2.7 11-Feb-2008  yamt sync with head.
 1.24.2.6 21-Jan-2008  yamt sync with head
 1.24.2.5 15-Nov-2007  yamt sync with head.
 1.24.2.4 03-Sep-2007  yamt sync with head.
 1.24.2.3 26-Feb-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.25.6.1 22-Apr-2006  simonb Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.2.3 11-Aug-2006  yamt sync with head
 1.26.2.2 13-Mar-2006  yamt sync with head.
 1.26.2.1 05-Mar-2006  yamt file syscall.c was added on branch yamt-pdpolicy on 2006-03-13 09:06:59 +0000
 1.30.2.2 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.30.2.1 07-Mar-2006  thorpej file syscall.c was added on branch elad-kernelauth on 2006-03-07 03:32:06 +0000
 1.31.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.31.4.1 28-Jan-2007  ad powerpc changes.
 1.32.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.33.18.2 06-Nov-2007  joerg Sync with HEAD.
 1.33.18.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.33.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.33.10.2 03-Oct-2007  garbled Sync with HEAD
 1.33.10.1 18-Aug-2007  macallan sync with HEAD
 1.33.2.2 03-Dec-2007  ad Sync with HEAD.
 1.33.2.1 20-Aug-2007  ad Sync with HEAD.
 1.34.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.34.2.3 23-Mar-2008  matt sync with HEAD
 1.34.2.2 09-Jan-2008  matt sync with HEAD
 1.34.2.1 06-Nov-2007  matt sync with HEAD
 1.36.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.36.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.36.4.1 27-Dec-2007  ad locking changes for macppc. Please test.
 1.36.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.40.8.1 18-May-2008  yamt sync with head.
 1.40.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.40.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.41.8.1 19-Oct-2008  haad Sync with HEAD.
 1.41.4.2 14-Oct-2008  wrstuden Add a new vp-private flag, SAVP_FLAG_DELIVERING. This flag indicates
that the vp is in the process of delivering a new-thread upcall.
This is a BLOCKED or NEWPROC upcall. Do NOT generate any BLOCKED
upcalls while this is set. Set it at the end of sa_switchcall()
and clear it at syscall entry. Sadly, I have found no other
way to handle this. The old SA interface has no way for
userland to acknowledge that it got the upcall, so use syscall
entry as the indicator that libpthread got it.

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

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

Also, while here, add sa_system_disabled. This is an integer
that we examine when starting SA for a proc. If it's non-zero,
we error out. Once this is hooked into sysctl, you'll be able to
disable SA w/o recompiling.
 1.41.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.41.2.2 11-Mar-2010  yamt sync with head
 1.41.2.1 04-May-2009  yamt sync with head.
 1.43.16.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.43.16.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.44.4.3 31-May-2011  rmind sync with head
 1.44.4.2 21-Apr-2011  rmind sync with head
 1.44.4.1 05-Mar-2011  rmind sync with head
 1.45.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.48.8.2 24-Feb-2012  mrg sync to -current.
 1.48.8.1 18-Feb-2012  mrg merge to -current.
 1.48.4.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.48.4.2 30-Oct-2012  yamt sync with head
 1.48.4.1 17-Apr-2012  yamt sync with head
 1.51.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.2.1 18-May-2014  rmind sync with head
 1.53.30.1 10-Jun-2019  christos Sync with HEAD
 1.165 15-Dec-2023  rin powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.

Part of PR kern/57621
 1.164 05-Oct-2023  ad Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
 1.163 15-Jul-2020  rin branches: 1.163.20;
Factor out emulation code for m[ft]msr in user mode from oea, and
adjust it for systems without FPU.

Now, it can be used from booke and ibm4xx in order to support fenv(3).
 1.162 15-Jul-2020  rin Rename emulated_opcode() to emulate_privileged() for clarity.
No functional changes.
 1.161 06-Jul-2020  rin Stop using DDBX which is defined nowhere.
 1.160 06-Jul-2020  rin This file is not used for ibm4xx.
 1.159 06-Jul-2020  rin - Drop unused opt_multiprocessor.h.
- Include missing opt_ppcarch.h.
 1.158 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.157 25-Feb-2020  rin Comment out do_ucas_32(), only user of which, _ucas_32(), is commented out
since powerpc/trap.c rev 1.156:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.156
 1.156 07-Apr-2019  thorpej branches: 1.156.4; 1.156.6;
Detangle some of the PowerPC CPU configuration spaghetti.
 1.155 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

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

Welcome to NetBSD 8.99.37.
 1.154 15-Jun-2018  uwe branches: 1.154.2;
In mtmsr emulation ignore PSL_VEC we set in mfmsr emulation just
above, as it freaks out PSL_USEROK_P(). This is also congruent with
how we handle PSL_FP.

PR port-macppc/53360
 1.153 16-Mar-2017  chs branches: 1.153.6; 1.153.12;
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.152 09-Mar-2017  chs set signo and code correctly for signals triggered by uvm_fault() errors.
 1.151 27-Feb-2017  chs have fpsetmask() change the FE0/FE1 MSR bits to precise mode if any
FP exceptions are enabled. fix the kernel emulation of mfmsr and mtmsr
to use the correct opcodes for these instructions. ignore PSL_FE
(the FP enable bit) in the MSR that a user program tries to set,
since it will naturally be set for FP-using processes but
we can't let the user process manage that bit.
 1.150 12-Aug-2014  joerg branches: 1.150.2; 1.150.4; 1.150.6;
Avoid unncessary use of double in the kernel. With this change,
a LLVM build kernel fully works on TWRP1025.
 1.149 03-Mar-2014  macallan support ppc601
from scole_mail, ok matt@
 1.148 02-Aug-2012  matt branches: 1.148.2; 1.148.4;
Also supprese printing fatal traps is the process is being debugged.
 1.147 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.146 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.145 27-Sep-2011  jym branches: 1.145.2; 1.145.6; 1.145.8; 1.145.10;
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.144 21-Jun-2011  matt Switch to use new common cpu_ast routine.
 1.143 20-Jun-2011  matt cleanup includes (explicit inclusion of <powerpc/psl.h> or <powerpc/userret.h>)
 1.142 14-Jun-2011  matt Make startlwp and upcallret common instead of having 3 mostly identical copies.
 1.141 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.140 02-May-2011  matt branches: 1.140.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.139 16-Mar-2011  matt Use l->l_md.md_utf in preference to trapframe(l). This shrink the kernel
just a bit in size.
 1.138 18-Jan-2011  matt 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.137 20-Dec-2010  matt branches: 1.137.2;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.136 07-Jul-2010  chs implement ucas_* for powerpc/oea.
 1.135 23-Apr-2010  rmind Remove lwp_uc_pool, replace it with kmem(9), plus add some consistency.
As discussed, a while ago, with ad@.
 1.134 21-Mar-2010  chs assert that pcb_onfault is NULL in places where it should be.
 1.133 25-Feb-2010  matt branches: 1.133.2;
Adapt to spr.h breakup.
 1.132 05-Jan-2010  mbalmer branches: 1.132.2;
One semicolon only (;; -> ;)
 1.131 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.130 29-Jul-2009  rmind Fix few more l_pflag and LP_OWEUPC confusions.
 1.129 19-Dec-2008  njoly Fix remaining archs (arm, luna68k, powerpc and sh3) that were still
using a proc argument instead of an expected lwp for ADDUPROF macro.

ok by christos.
 1.128 25-Oct-2008  mrg branches: 1.128.2; 1.128.4; 1.128.8; 1.128.10;
make this build again after revivesa. ok'd by gimpy.

XXX: i think this will work but i haven't actually run any SA apps.
it does compile and link and the kernel boots just fine.
 1.127 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.126 21-May-2008  ad branches: 1.126.4;
Remove unneeded playing about with kernel_lock.
 1.125 05-Feb-2008  garbled branches: 1.125.6; 1.125.8; 1.125.10; 1.125.12;
Replace as much of the hardcoded CACHELINESIZE with
curcpu()->ci_ci.dcache_line_size as I can. With this change, an ofppc kernel
compiled with both PPC_OEA and PPC_OEA64_BRIDGE defined, boots.
 1.124 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.123 02-Jan-2008  ad Merge vmlocking2 to head.
 1.122 24-Oct-2007  ad branches: 1.122.2; 1.122.4; 1.122.8;
Make ras_lookup() lockless.
 1.121 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.120 18-May-2007  rjs branches: 1.120.8; 1.120.10; 1.120.14;
Fix for yamt-idlelwp merge.
 1.119 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.118 04-Mar-2007  christos branches: 1.118.2; 1.118.4; 1.118.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.117 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.116 09-Feb-2007  ad branches: 1.116.2;
Merge newlock2 to head.
 1.115 05-Aug-2006  sanjayl branches: 1.115.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.114 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.113 19-Jul-2006  ad - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
 1.112 15-May-2006  yamt include kauth.h for kauth_cred_geteuid.
 1.111 14-May-2006  elad integrate kauth.
 1.110 15-Mar-2006  drochner branches: 1.110.2;
adapt to uvm_fault() interface cleanup: kill the useless 3rd argument
 1.109 24-Dec-2005  perry branches: 1.109.4; 1.109.6; 1.109.8; 1.109.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.108 11-Dec-2005  christos merge ktrace-lwp.
 1.107 02-Jun-2005  he branches: 1.107.2;
Adapt to const additions.
 1.106 03-Jan-2005  chs drop the big lock in upcallret() like all the other platforms do.
 1.105 18-Nov-2004  matt If setfault() returns nonzero (ie, we trapped), make sure to unsetusr.
 1.104 18-Nov-2004  matt Make sure to do setenv/unsetenv in pairs. This prevents panics in
DIAGNOSTIC kernel when crossing segment boundaries.
 1.103 16-Aug-2004  aymeric add a missing break in the EXC_MCHK|EXC_USER case in trap()
 1.102 16-Apr-2004  matt Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.101 15-Apr-2004  matt Revamp how user MSR/SRR1 are dealt with.
Add a PSL_USEROK_P(psl) macro which valids the bits (replaces the use of
PSL_USERSTATIC).
Add a PSL_USERSRR1 mask which is used to mask out status bits in the upper
half of SRR1.
Make sure PSL_VEC is set appropriately in userret(). PSL_VEC is in the same
region as SSR1 status bits so it's not preserved on exceptions. Thus we
need to make to set it.
When returning a MSR/SRR1 to userland, always clear the status bits.
Add emulation of the mfpvr, mtmsr, and mfmsr instructions.
 1.100 04-Apr-2004  matt Add SIGFPE handling code. Report the proper SIGINFO ksi_code when a SIGFPE
happens. When a SIGFPE occurs, disable the exception enables in the FPSCR.
 1.99 25-Mar-2004  matt branches: 1.99.2; 1.99.4;
Add diagnostic to skip calling uvm_fault when the lwp's USERSR is unset.
 1.98 14-Mar-2004  cl add kernel part of concurrency support for SA on MP systems
- move per VP data into struct sadata_vp referenced from l->l_savp
* VP id
* lock on VP data
* LWP on VP
* recently blocked LWP on VP
* queue of LWPs woken which ran on this VP before sleep
* faultaddr
* LWP cache for upcalls
* upcall queue
- add current concurrency and requested concurrency variables
- make process exit run LWP on all VPs
- make signal delivery consider all VPs
- make timer events consider all VPs
- add sa_newsavp to allocate new sadata_vp structure
- add sa_increaseconcurrency to prepare new VP
- make sys_sa_setconcurrency request new VP or wakeup idle VP
- make sa_yield lower current concurrency
- set sa_cpu = VP id in upcalls
- maintain cached LWPs per VP
 1.97 24-Feb-2004  drochner deliver SIGSEGV/SEGV_ACCERR if code execution on stack is attempted,
tested by Chuck Silvers
 1.96 21-Nov-2003  matt More PPC64 changes. (latent for now).
 1.95 06-Nov-2003  he Replace an overlooked instance of p->p_nras with LIST_EMPTY(&p->p_raslist).
 1.94 04-Nov-2003  dsl Remove p_nras from struct proc - use LIST_EMPTY(&p->p_raslist) instead.
Remove p_raslock and rename p_lwplock p_lock (one lock is enough).
Simplify window test when adding a ras and correct test on VM_MAXUSER_ADDRESS.
Avoid unpredictable branch in i386 locore.S
(pad fields left in struct proc to avoid kernel bump)
 1.93 25-Oct-2003  chs clear pcb_onfault before calling uvm_fault() and restore it afterward.
if the fault handler generates a pagefault, we'd like to panic rather
than invoking the onfault handler.
 1.92 22-Oct-2003  matt s/SSR/SRR
 1.91 17-Oct-2003  matt Add a KASSERT() to verify the pcb is not NULL.
 1.90 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

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

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.89 27-Sep-2003  matt ANSIfy.
 1.88 25-Sep-2003  matt Fill in ksi_code.
 1.87 25-Sep-2003  matt Add siginfo support for PowerPC.
 1.86 19-Sep-2003  cl add MD part of SA/pthread pagefault handling on powerpc
 1.85 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.84 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.83 08-Aug-2003  matt Don't try to spill entries from the kernel's pmap. As of now, they can no
longer be evicted, only user-mappings can be evicted.
 1.82 04-Aug-2003  matt Make that OEA based kernels can properly deal with kernel ISI faults. Now
that LKMs are supported, it is possible for a LKM page to be "outspilled"
resulting in a possible ISI fault. Try to spill the page back in.
 1.81 15-Jul-2003  lukem __KERNEL_RCSID()
 1.80 14-Mar-2003  matt branches: 1.80.2;
Print more useful messages on kernel ALI or PGM traps.
 1.79 25-Feb-2003  matt Add some RAS support. Don't print out a message when we encounter
trap instructions.
 1.78 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.77 19-Jan-2003  matt Cast to register_t instead of int to be nicer for LP64.
Simplify copyin/copyout/copyinstr/copyoutstr. Fix bug
where the user virtual address was not updated so that
if the user's buffer crossed a segment boundary, the
wrong data could be copied. Localize USER_SR to the
ILP32 version of setusr/unsetusr.
 1.76 18-Jan-2003  matt Make register_t. Change the printfs in trap.c to match.
 1.75 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.74 25-Nov-2002  thorpej branches: 1.74.2;
Remove redundant (and incorrect) extern decl.
 1.73 13-Nov-2002  matt Do kernel non-USER_SR pte spilling regardless of interrupt count. Only do
kernel USER_SR spillage if interrupt depth is 0.
 1.72 30-Oct-2002  matt Move child_return back to syscall.c
Fix syscall to use emulations SYS_syscall/SYS___syscall definitions.
Use the emulation NSYSENT to limit code.
Don't define *syscall_fancy if it will never be used.
 1.71 30-Oct-2002  manu Fixed mistakes
 1.70 30-Oct-2002  manu Prepare syscall.c for COMPAT_MACH support. linux_syscall_intern is
moved to a Linux specific file, child_return is moved to trap.c,
and we introduce a EMULNAME macro co that syscall.c can be included to
define the system call handler for another emulation.
 1.69 10-Oct-2002  matt Move pte_spill calls from trap_subr to trap(). Count the number of
"evictions" and avoide calling pmap_pte_spill if there are no evictions
for the current pmap. Make the ISI execption use the default exception
code. Remove lots of dead stuff from trap_subr.

Make olink use TAILQ instead of LIST and be sorted with evicted entries
first and resident entries last. Make use of this knowledge to make
pmap_pte_spill do a fast exit.
 1.68 12-Aug-2002  matt Print DAR and DSISR on user ALIgnment traps (e.g. treat them as being
similar to DSI tracks).
 1.67 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.66 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.65 25-Jul-2002  matt Cleanup AltiVec data stream issues with context switching. Don't stop
data streams on execptions/interrupts since the processor will suspend
them for us. Only stop them on 1) process exit, 2) another process gets
its address space loaded, and 3) (for completeness only) we save a process's
AltiVec context.
 1.64 24-Jul-2002  chs reimplement copy{in,out}str() similarly to copy{in,out}()
(instead of the old way of calling [fs]ubyte() in a loop).
 1.63 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.62 27-Jun-2002  matt If ALTIVEC is not defined, treat EXC_VEC|EXC_USER exceptions as PGM
exceptions. [Note that we still can't trap these due to issues in
trap_subr.S which are (yet) fixed]
 1.61 17-Jun-2002  christos try to make this compile.
 1.60 17-Jun-2002  christos MD systrace gluons.
 1.59 19-May-2002  augustss Handle the "aligment" fault generated by DCBZ when the cache is off.
That way you can run the processor with caches off.
 1.58 04-Mar-2002  dbj branches: 1.58.6;
add cnpollc() calls around cngetc for TRAP_PANICWAIT
 1.57 22-Feb-2002  kleink Handle the 601's Run Mode/Trace Exception as well.
 1.56 14-Feb-2002  chs allow writing to write-only mappings. fixes PR 3493.
 1.55 02-Feb-2002  dbj increment uvmexp.traps on entry to trap()
 1.54 05-Dec-2001  chs fix macppc MULTIPROCESSOR compilation.
 1.53 18-Oct-2001  matt branches: 1.53.4;
Use correct SRR1 bit in EXC_PGM|EXC_USER fault to catch a trap.
 1.52 26-Aug-2001  matt Make all powerpc ports use a common Makefile.powerpc (except walnut)
Enforce -Wmissing-prototypes -Wstrict-prototypes for all ppc ports.
Split out macppc cpu support and make common to mpc6xx ports. Make
other mpc6xx ports use it. Add evcnts for mpc6xx traps.
 1.51 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.50 28-Jun-2001  matt branches: 1.50.2;
Onfault needs to be done even from interrupts so restore that. Default
to EFAULT for the error.
 1.49 28-Jun-2001  matt Update for thorepj's UVM changes. Don't even try to call uvm_fault or do
pcb_onfault recovery while in interrupt mode. Just die. Print out error
returned from uvm_fault (-1 for interrupts).
 1.48 26-Jun-2001  matt Record any stack growth. This fixes a serious problem with core dumps.
Without this change, coredumps will only contain one page of stack
regardless of how many pages of stack the process actually has.
 1.47 19-Jun-2001  simonb Move the DSISR SPR bit definitions from <powerpc/mpc6xx/pte.h> to
<powerpc/spr.h>. Remove unused ISI/SRR1 bit definitions.
 1.46 10-Jun-2001  tsubai When invoking the pcb_onfault mechanism, pass the return value of uvm_fault()
to the onfault routine.
 1.45 10-Jun-2001  tsubai Fix printf format error.
 1.44 10-Jun-2001  matt Print a more informative is a uncatchabl DSI or ISI exeception happens in
kernel mode.
 1.43 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.42 02-Jun-2001  chs replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.41 22-Mar-2001  tsubai Merge my MP tree. At this point, Daystar dual 604 card (i.e. Power Macintosh
9500/180MP and 9600/200MP) runs at least into single-user mode, possibly
multi-user mode (not stable yet).
 1.40 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.39 12-Feb-2001  manu branches: 1.39.2;
Removed a copyright for code I have removed in a previous commit
 1.38 11-Feb-2001  manu Moved the fix for negative errno returned to userland on the PowerPC to a
more machine independent fashion
 1.37 09-Feb-2001  manu Fixed a bug in the way errno return was handled in linux emulation (we returned the opposite of the expected errno)
 1.36 04-Feb-2001  briggs Build with -Wall -Wetc.
 1.35 01-Jan-2001  tsubai Make want_resched and astpending per-CPU.
Add some per-CPU variables to cpu_info.
 1.34 14-Dec-2000  mycroft Partial syscall cleanup, as per other ports.
 1.33 10-Dec-2000  jdolecek provide dymmy symbol 'syscall' to make ppc kernels
linkable after recent emul changes - it's used in emul_netbsd and friends
XXX this is probably wrong solution; should powerpc have separate
XXX syscall() as other ports do ?
 1.32 25-Nov-2000  tsubai Add KERNEL_LOCK (et al.) to run MULTIPROCESSOR kernel on a single cpu system.
 1.31 25-Nov-2000  matt Preliminary AltiVec support
 1.30 24-Nov-2000  tsubai When fatal trap occurs, enter DDB with trapframe rather than just "Debugger()".
 1.29 22-Nov-2000  tsubai Constify struct sysent.
 1.28 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.27 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.26 27-May-2000  sommerfeld branches: 1.26.4;
Reduce use of curproc in several places:

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

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

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

Also, miscellaneous cleanups in ktrace:

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

- move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

- simplify interface to ktrwrite()
 1.25 26-May-2000  thorpej First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

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

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

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

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

Tested on i386 and Alpha. Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
 1.24 24-May-2000  thorpej Use preempt(), not an open-coded equivalent (which won't be
equivalent for long).
 1.23 19-Jan-2000  danw Fill in the alignment trap handler a bit: now it can fix unaligned
floating point loads and stores (to work around a gcc bug), but will
still cause a bus error on other sorts of unaligned accesses.
 1.22 03-May-1999  tsubai branches: 1.22.2;
PT_{STEP,GETREGS,SETREGS} support.
 1.21 26-Mar-1999  tsubai branches: 1.21.2; 1.21.4;
In copyin() and copyout(), clear the pcb_onfault variable in the EFAULT
case. (pr 7243)
 1.20 26-Mar-1999  tsubai A successful kernel page fault should just return so that signal delivery
et al. should not executed. (pr7240)
 1.19 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.18 22-Mar-1999  chs fix previous, I got carried away with cut+paste.
 1.17 18-Mar-1999  chs if uvm_fault() fails with KERN_RESOURCE_SHORTAGE, send a SIGKILL
and print a message about it. this will be used to recover from
out-of-swap conditions.
 1.16 15-Mar-1999  tsubai Implement badaddr() and trap machine-check in badaddr.
 1.15 10-Jan-1999  tsubai Fix void * arithmetic.
 1.14 26-Nov-1998  thorpej copyin() and copyout() should return EFAULT if a fault occurs, not
EACCESS.
 1.13 26-Nov-1998  tsubai Save and restore pcb_onfault in kcopy().
 1.12 22-Nov-1998  ws The last fix in trap.c missed R2.
And correct the size of the fault buffer while being here.
 1.11 21-Nov-1998  tsubai When DSI occurs and pcb_onfault != 0, registers are incorrectly restored.
Fix this.
 1.10 11-Nov-1998  thorpej Changes to support fork_kthread():
- cpu_set_kpc() now takes void *arg third argument, passed to the
entry point.
- cpu_fork() allows parent to be non-curproc iff parent is proc0.
When forking non-curproc, assume its state has already been saved.
- Adjust various pieces of machine-dependent code to account of all of this.
 1.9 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.8 04-Jul-1998  jonathan defopt DDB.
 1.7 25-Jun-1998  thorpej defopt KTRACE
 1.6 05-Jun-1998  sakamoto Merge in MACHINE_NEW_NONCONTIG support and some fix from Tsubai-San.
UVM support.
 1.5 27-Jan-1998  sakamoto Import DDB from OpenBSD/powerpc.
 1.4 16-Apr-1997  thorpej - Add an option (TRAP_PANICWAIT) that causes trap() to prompt for a keypress
before calling panic().
- Add const poisioning where appropriate.
 1.3 13-Oct-1996  christos backout previous kprintf change
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 30-Sep-1996  ws PowerPC port
 1.21.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.21.2.1 20-Jan-2000  he Pull up revision 1.23 (requested by danw):
Add (the beginnings of) an unaligned access handler for the
powerpc, to get around the fact that gcc currently generates bad
floating point copies sometimes, which breaks various things,
 1.22.2.7 27-Mar-2001  bouyer Sync with HEAD.
 1.22.2.6 12-Mar-2001  bouyer Sync with HEAD.
 1.22.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.22.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.22.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.22.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.22.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.26.4.1 02-Jul-2001  jhawk Pull up revision 1.48 via patch (requested by matt):
Record any stack growth. This fixes a serious problem with core dumps.
Without this change, coredumps will only contain one page of stack
regardless of how many pages of stack the process actually has.
 1.39.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.39.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.50.2.7 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.50.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.50.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.50.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.50.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.50.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.50.2.1 03-Aug-2001  lukem update to -current
 1.53.4.19 07-Jan-2003  thorpej In the SA universe, the switch-to-this-LWP decision is made at a
different level than where preempt() calls are made, which renders
the "newlwp" argument useless. Replace it with a "more work to do"
boolean argument. Returning to userspace preempt() calls pass 0.
"Voluntary" preemptions in e.g. uiomove() pass 1. This will be used
to indicate to the SA subsystem that the LWP is not yet finished in
the kernel.

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

NOTE: THIS IS NOT A COMPLETE FIX TO THE preempt()-in-uiomove() PROBLEM
THAT CURRENTLY EXISTS FOR SA PROCESSES.
 1.53.4.18 11-Dec-2002  thorpej Sync with HEAD.
 1.53.4.17 18-Oct-2002  nathanw LWPify a little. Patches from Bill Studenmund.
macppc GENERIC.MP builds now.
 1.53.4.16 18-Oct-2002  nathanw Catch up to -current.
 1.53.4.15 27-Aug-2002  nathanw Catch up to -current.
 1.53.4.14 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.53.4.13 06-Aug-2002  nathanw Missed a LWP'ification in the non-AltiVec case.
 1.53.4.12 01-Aug-2002  nathanw LWPify and re-add functions accidentally removed.
 1.53.4.11 01-Aug-2002  nathanw Catch up to -current.
 1.53.4.10 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.53.4.9 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.53.4.8 20-Jun-2002  nathanw Catch up to -current.
 1.53.4.7 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.53.4.6 28-Feb-2002  nathanw Catch up to -current.
 1.53.4.5 08-Jan-2002  nathanw Catch up to -current.
 1.53.4.4 17-Dec-2001  nathanw cpu_upcall() -> sa_upcall_userret().
 1.53.4.3 17-Nov-2001  briggs Update to Current World Order.
 1.53.4.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.53.4.1 18-Oct-2001  briggs file trap.c was added on branch nathanw_sa on 2001-11-05 19:46:19 +0000
 1.58.6.4 31-Aug-2002  gehenna catch up with -current.
 1.58.6.3 16-Jul-2002  gehenna catch up with -current.
 1.58.6.2 15-Jul-2002  gehenna catch up with -current.
 1.58.6.1 30-May-2002  gehenna Catch up with -current.
 1.74.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.80.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.80.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.80.2.5 29-Nov-2004  skrll Sync with HEAD.
 1.80.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.80.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.80.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.80.2.1 03-Aug-2004  skrll Sync with HEAD
 1.99.4.3 13-Apr-2005  tron Pull up revision 1.106 (requested by chs in ticket #1066):
drop the big lock in upcallret() like all the other platforms do.
 1.99.4.2 14-Feb-2005  he Pull up revision 1.105 (via patch, requested by matt in ticket #987):
If setfault() returns nonzero (i.e. we trapped), make sure to
unsetusr().
 1.99.4.1 07-Jan-2005  jdc Pull up revision 1.104 (requested by matt in ticket #985).

Make sure to do setenv/unsetenv in pairs. This prevents panics in
DIAGNOSTIC kernel when crossing segment boundaries.
 1.99.2.2 13-Apr-2005  tron Pull up revision 1.106 (requested by chs in ticket #1066):
drop the big lock in upcallret() like all the other platforms do.
 1.99.2.1 07-Jan-2005  jdc Pull up revision 1.104 (requested by matt in ticket #985).

Make sure to do setenv/unsetenv in pairs. This prevents panics in
DIAGNOSTIC kernel when crossing segment boundaries.
 1.107.2.7 11-Feb-2008  yamt sync with head.
 1.107.2.6 21-Jan-2008  yamt sync with head
 1.107.2.5 27-Oct-2007  yamt sync with head.
 1.107.2.4 03-Sep-2007  yamt sync with head.
 1.107.2.3 26-Feb-2007  yamt sync with head.
 1.107.2.2 30-Dec-2006  yamt sync with head.
 1.107.2.1 21-Jun-2006  yamt sync with head.
 1.109.10.2 19-Apr-2006  elad sync with head - hopefully this will work
 1.109.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.109.8.3 11-Aug-2006  yamt sync with head
 1.109.8.2 24-May-2006  yamt sync with head.
 1.109.8.1 01-Apr-2006  yamt sync with head.
 1.109.6.2 01-Jun-2006  kardel Sync with head.
 1.109.6.1 22-Apr-2006  simonb Sync with head.
 1.109.4.1 09-Sep-2006  rpaulo sync with head
 1.110.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.115.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.115.4.1 28-Jan-2007  ad powerpc changes.
 1.116.2.3 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.116.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.116.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.118.10.2 02-Aug-2007  macallan sync with HEAD
 1.118.10.1 22-May-2007  matt Update to HEAD.
 1.118.4.1 11-Jul-2007  mjf Sync with head.
 1.118.2.1 03-Dec-2007  ad Sync with HEAD.
 1.120.14.1 13-Nov-2007  bouyer Sync with HEAD
 1.120.10.3 23-Mar-2008  matt sync with HEAD
 1.120.10.2 09-Jan-2008  matt sync with HEAD
 1.120.10.1 06-Nov-2007  matt sync with HEAD
 1.120.8.1 28-Oct-2007  joerg Sync with HEAD.
 1.122.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.122.4.1 27-Dec-2007  ad locking changes for macppc. Please test.
 1.122.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.125.12.4 30-Jun-2008  wrstuden Change how we make SA threads not generate upcalls. Instead of clearing
LW_SA, use a private flag, LP_SA_NOBLOCK, that we set when we want
to not generate upcalls. This means we do NOT need to lock (l)
(ourselves) to set it.

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

Introduce code pattern to set & remember this:

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

...

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

l->l_pflag ^= f;

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

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

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

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

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

Tweak some comments.
 1.125.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.125.12.2 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.125.12.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.125.10.4 11-Aug-2010  yamt sync with head.
 1.125.10.3 11-Mar-2010  yamt sync with head
 1.125.10.2 19-Aug-2009  yamt sync with head.
 1.125.10.1 04-May-2009  yamt sync with head.
 1.125.8.1 04-Jun-2008  yamt sync with head
 1.125.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.125.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.126.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.126.4.1 19-Oct-2008  haad Sync with HEAD.
 1.128.10.1 21-Apr-2010  matt sync to netbsd-5
 1.128.8.1 14-Aug-2009  snj Pull up following revision(s) (requested by rmind in ticket #897):
sys/arch/hp300/include/cpu.h: revision 1.60
sys/arch/news68k/include/cpu.h: revision 1.34
sys/arch/powerpc/powerpc/trap.c: revision 1.130 via patch
Fix few more l_pflag and LP_OWEUPC confusions.
 1.128.4.1 14-Aug-2009  snj branches: 1.128.4.1.4;
Pull up following revision(s) (requested by rmind in ticket #897):
sys/arch/hp300/include/cpu.h: revision 1.60
sys/arch/news68k/include/cpu.h: revision 1.34
sys/arch/powerpc/powerpc/trap.c: revision 1.130 via patch
Fix few more l_pflag and LP_OWEUPC confusions.
 1.128.4.1.4.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.128.4.1.4.2 07-Jan-2011  matt Move OPC_MFMSR definitions from trap.c
Add OPC_LWSYNC for booke.
 1.128.4.1.4.1 07-Jan-2011  matt Deal with trapframe changes. Rework trap_subr.S to take advantage of the
simplier world.
 1.128.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.132.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.132.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.133.2.5 12-Jun-2011  rmind sync with head
 1.133.2.4 31-May-2011  rmind sync with head
 1.133.2.3 21-Apr-2011  rmind sync with head
 1.133.2.2 05-Mar-2011  rmind sync with head
 1.133.2.1 30-May-2010  rmind sync with head
 1.137.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.140.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.145.10.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.145.8.1 09-Oct-2012  riz sys/arch/powerpc/powerpc/trap.c patch

Silence trap printfs caused by OpenSSL.
[christos, ticket #589]
 1.145.6.1 24-Feb-2012  mrg sync to -current.
 1.145.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.145.2.2 30-Oct-2012  yamt sync with head
 1.145.2.1 17-Apr-2012  yamt sync with head
 1.148.4.1 18-May-2014  rmind sync with head
 1.148.2.2 03-Dec-2017  jdolecek update from HEAD
 1.148.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.150.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.150.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.150.2.1 28-Aug-2017  skrll Sync with HEAD
 1.153.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.153.6.1 18-Jun-2018  martin Pull up following revision(s) (requested by uwe in ticket #884):

sys/arch/powerpc/powerpc/trap.c: revision 1.154

In mtmsr emulation ignore PSL_VEC we set in mfmsr emulation just
above, as it freaks out PSL_USEROK_P(). This is also congruent with
how we handle PSL_FP.

PR port-macppc/53360
 1.154.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.154.2.1 10-Jun-2019  christos Sync with HEAD
 1.156.6.1 29-Feb-2020  ad Sync with head.
 1.156.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by rin in ticket #737):

sys/arch/powerpc/powerpc/trap.c: revision 1.157
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.60

Comment out do_ucas_32(), only user of which, _ucas_32(), is commented out
since powerpc/trap.c rev 1.156:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.156
 1.163.20.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.87 29-Apr-2025  tsutsui Fix typo.

Noticed by Miod Vallat.
 1.86 18-May-2022  andvar branches: 1.86.10;
fix typos in word "access" and it derivatives, mainly in comments.
 1.85 24-Feb-2021  thorpej Add a provision for a per-cpu battable. Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.
 1.84 12-Jul-2020  rin branches: 1.84.2;
No need to work around for IBM405 Errata 77; ibm4xx does not use this file.
 1.83 06-Jul-2020  rin Include required opt_*.h for sure.
 1.82 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.81 01-Mar-2020  rin Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.
However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.

Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.80 15-Jul-2018  maxv branches: 1.80.4;
Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.79 02-May-2018  phx branches: 1.79.2;
Fixed non-critical typo in tlbdsmiss: %r8 -> 8.
 1.78 29-Jul-2014  joerg branches: 1.78.26;
cmpl wants four operands, so use the shorter cmplw instead.
 1.77 23-Aug-2013  matt branches: 1.77.2;
Avoid a few instructions since we know CURLWP is in %r13
 1.76 11-Apr-2013  macallan branches: 1.76.4;
make PPC_OEA64_BRIDGE mode work
from Phileas Fogg
 1.75 27-Jul-2012  matt branches: 1.75.2;
Use %r6 for setting PSL_RI, not %r30 since r30 needs to be preserved.
 1.74 18-Jul-2012  matt Add conditionals so this should work for the MPC8XX SoCs.
Turn on PSL_RI in interrupts.
 1.73 01-Feb-2012  matt Enable XBSEN and HIGHBAT for OEA 7455 and related CPUs.
The BAT entries now have a resolution of 8MB. (Adjacent entries are merged
up to a total of 2GB per entry).
 1.72 13-Dec-2011  kiyohara Remove white-spaces.
 1.71 21-Jun-2011  matt branches: 1.71.2; 1.71.6;
Remove #if 0 block
 1.70 17-Jun-2011  matt Let ext_intr adjust ci_idepth.
Remove some dead code.
Use the right register for SRR1
 1.69 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.68 07-Apr-2011  matt branches: 1.68.2;
Fix bogus idepth on OEA.
 1.67 18-Jan-2011  matt 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.66 28-Jan-2010  mbalmer branches: 1.66.4; 1.66.6;
Fix language.
 1.65 01-Aug-2008  matt branches: 1.65.16;
Fix bug where SRR1 (%r2) was being accidently misused and modifed
in place of segreg (%r1).

From Konrad Karpowicz <konradk at pacomp dot pl>.
 1.64 24-May-2008  phx branches: 1.64.4;
Make oea_init() support systems with high-vector configurations (i.e exception
vectors at 0xfff00000), and trap_subr.S allows the kernel to be in a memory
region which is not reachable by absolute branch instructions (ba and bla).

High-vector support can be enabled by option PPC_HIGH_VEC, and long-branches
to the kernel are enabled by the option DISTANT_KERNEL.
 1.63 07-Feb-2008  garbled branches: 1.63.6; 1.63.8; 1.63.10; 1.63.12;
Code to disable BAT use on cpu's that either don't have BAT's, or don't
gain any benefit from them. This nets a small speedup on the POWER3, and
is probably needed for POWER5, which might not emulate BATs like the 3 does.
Also, thanks to Matt Thomas, who suggested re-using alitrap rather than
writing a new dsinobattrap that would have looked remarkably identical
when finished.
 1.62 05-Feb-2008  garbled Ifdef out all the MPC601 code with PPC_OEA601. Now only arches that have the
possibility of running on an MPC601, are infected with all the extra code
and nops that it added.

Also, fix compilation that I broke with the pmap code, by adding
oeacpufeat to the locores of various ppc arches. Noted by mlelstv.
 1.61 05-Feb-2008  garbled Rewrite a big chunk of the pmap and locore code for powerpc to better
deal with the 64bit bridge mode. pmap changes by Matt Thomas, rest by myself.

Change pmap.c to work similar to exec_elf.c to allow us to compile in
multiple pmaps to a single kernel. This allows the pmap for bridge64 to
co-exist with the 32bit pmap.

Yank __HAVE_PMAP_PHYSSEG from all the oea code.

Add a new global, "oeacpufeat", which is used early in locore to determine
certain cpu features. This allows us to conditionalize code early in the boot
for certain CPUs that have special needs.

Yank most of the ifdef PPC_OEA_BRIDGE64 code from almost every file it was
found in. Some of it seemed incorrect, and my 7044 booted just fine
without it. It would appear that the bridge cpus treat BAT instructions
as nops, so they seem to be safe.

In ofppc, check the oeacpufeat, and if we are on a 64bit proc, clear
MSR[SF], and ASR[V].

With all of these changes, a kernel with both PPC_OEA and PPC_OEA_BRIDGE64
will boot on the POWERIII-2 cpu. However, it will not yet boot on a 32bit
cpu, because of CACHELINESIZE. Work remains to be done there to fix that.
 1.60 17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.59 05-Aug-2006  sanjayl branches: 1.59.8; 1.59.24; 1.59.34; 1.59.40; 1.59.48;
1st cut of Powermac G5 support (uses bridge mode).
 1.58 11-Dec-2005  christos branches: 1.58.4; 1.58.8;
merge ktrace-lwp.
 1.57 04-Mar-2005  nathanw branches: 1.57.2; 1.57.4;
Don't enable interrupts while calling trap() if the trapping frame
didn't have them enabled either.

Addresses PR port-macppc/29559.
 1.56 09-Jun-2004  kleink branches: 1.56.4; 1.56.6;
Get rid of the silly CPU601 hooks and move BAT register restoration and
obliteration to RESTORE_{KERN,USER}_SRS, respectively; have oea_init()
patch these sequences to be skipped on non-MPC601s. The code sequence
matching heuristic isn't as pretty as the one for VRSAVE and MQ but works
well enough with the current structure of the trap code, and can be easily
updated when necessary.
 1.55 08-Jun-2004  kleink Repair a comment misplaced in rev. 1.43.
 1.54 09-Dec-2003  simonb branches: 1.54.2; 1.54.4;
Make some comments line up.
 1.53 30-Nov-2003  simonb Remove unused ddbsave define.
 1.52 21-Nov-2003  matt Restore ci_curpm since it re-enables 603 to working state.
 1.51 22-Oct-2003  matt Rework ddblow so that if PSL_PR == 1, it dispatches directly to the
trap handler and bypasses the ddbtrap code.
 1.50 09-Oct-2003  matt Add code to drop into DDB if you get a DSI fault on the current stack page.
 1.49 12-Aug-2003  matt D'oh! The PCB can't be accessed with the MMU off. So get the pmap pointer
*before* disabling the MMU.
 1.48 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.47 08-Aug-2003  matt Nuke ci_spillstk/CI_SPILLSTK. No longer needed.
 1.46 08-Aug-2003  matt Add a type for trapstart so ddb will use it.
 1.45 06-Aug-2003  matt Don't overwrite the value of DAR in r30. Use r31 instead.
 1.44 04-Aug-2003  matt Change bc x,y,z to their simplified mnemonics. During a kernel DSI fault,
if the exception address is < 1 page away from the KSP, switch to the that
CPU's spill stack to handle the trap. Otherwise you can get in a infinite
DSI fault loop.
 1.43 04-Aug-2003  matt Eliminate stmw/lmw substituting the individual load/store instructions.
Use more symbolic constants. These are now safe for use on PPC64.
 1.42 31-Jul-2003  matt Use symbolic register names (%rN and %crN) throughout. Change a few more
numeric constants to their symbolic counterparts.
 1.41 31-Jul-2003  matt Convert most numeric constants to their symbolic equivalents. (step 2 of
cleaning up this file).
 1.40 31-Jul-2003  matt Replace 'm[tf]sprg x,y' with the appropriate 'm[tf]sprg[0-3] r' (this makes the
SPRG used unambiguous). This causes no change in the generated object.
 1.39 09-Jul-2003  matt Enhance db_trace to understand syscalls and print the syscall number
that the user requested. For example:

0xd5c56f40: SC trap #240 by 0x15668c60: srr1=0xd032
r1=0xffffe470 cr=0x44000045 xer=0 ctr=0xeff27ab8
 1.38 29-Apr-2003  scw branches: 1.38.2;
Put an isync at the end of the RESTORE_SRS() macro. This is the
recommended workaround for a mtsr/mtsrin errata with PPC750 cpus.
 1.37 15-Mar-2003  matt Add LINTSTUBs and make oea_init() agree with them.
 1.36 04-Mar-2003  matt Pass the address of the intrframe to the ext_intr routine.
 1.35 21-Feb-2003  matt witch from xor r,r,r to li r,0 to set a register to 0. It's clearer (and
better for G4 processors).
 1.34 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.33 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.32 22-Jan-2003  kleink Whitespace nit in previous.
 1.31 22-Jan-2003  kleink MPC601 support bits:
* install 601-specific DSI and RUNMODETRC trap handlers
* save/restore MQ in trapframe, add MQ hooks to DDB
* extend battable to 512 entries to hold the 601's 8M translations
* instead of adding I/O to BAT starvation, set up segment registers
for Memory-Forced I/O Controller Interface Access
* sync after tlbie
 1.30 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.29 10-Oct-2002  matt Move pte_spill calls from trap_subr to trap(). Count the number of
"evictions" and avoide calling pmap_pte_spill if there are no evictions
for the current pmap. Make the ISI execption use the default exception
code. Remove lots of dead stuff from trap_subr.

Make olink use TAILQ instead of LIST and be sorted with evicted entries
first and resident entries last. Make use of this knowledge to make
pmap_pte_spill do a fast exit.
 1.28 06-Aug-2002  chs be sure to re-enable interrupts before calling trap() a second time
due to an AST. the rule is that we must always have interrupts
enabled when acquiring kernel_lock, so that we can process blocking IPIs
from another CPU which is already holding kernel_lock.
reduce differences between the MP and non-MP versions of this file.
 1.27 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.26 28-Jul-2002  chs resync the MP and non-MP trap_subr's.
 1.25 25-Jul-2002  matt Cleanup AltiVec data stream issues with context switching. Don't stop
data streams on execptions/interrupts since the processor will suspend
them for us. Only stop them on 1) process exit, 2) another process gets
its address space loaded, and 3) (for completeness only) we save a process's
AltiVec context.
 1.24 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.23 26-Jun-2002  matt Make traps even smaller by noticing the checking of privilege mode and
use of curpcb/USPACE is common and move that into the common trap processing.
 1.22 26-Jun-2002  matt Revamp how SR(s) are loaded on the user/kernel boundary. We now load all
16 SR registers when transitioning between kernel and user. Also, don't
reload the kernel SR(s) on every trap but only on traps from user space.
Instead of loading magic SRs for the kernel, load the kernel SRs from the
kernel_pmap_. This makes trap_subr.S completely ignorant of SR uses and
so they can change with having to change trap_subr.S. Also note that
since the user and kernel get complete SR sets, user VA space can now be
increased to 4GB if desired.
 1.21 02-May-2002  kleink branches: 1.21.2; 1.21.4;
* On the 601, obliterate all BAT entries when returning from kernel to
userlevel; this is necessary due to the 601, unlike other 6xx, having
no concept of separated Valid_user vs. Valid_supervisor for BATs.
* When crossing the kernel/userlevel boundary, have platform-provided
hooks set up the two fixed BAT entries, and possibly additional
segment registers to redeem the 601's BAT limitations.

Both of the above are only built if the $MACHINE provides these hooks,
sparing others the pain.
 1.20 22-Apr-2002  kleink Express tempsave and disisave addresses using the symbolic names of the
exception handlers which they are `borrowed' from.
 1.19 22-Apr-2002  kleink Fix a swapped register pasto(?) introduced in rev. 1.17.
 1.18 21-Apr-2002  kleink Convert the spill stack frame to use symbolic offset names; inspired by
a conversation with Matt Thomas.
 1.17 18-Apr-2002  matt Use a common genassym.cf for all the PPC_MPC6XX ports. Add a makeoptions to
std.foo to indicate the directory to get genassym.cf from. Add an intrframe
to <powerpc/frame.h> and make trap_subr.S use symbolic offsets into it.
 1.16 18-Apr-2002  kleink Don't do random replacement in isitrap601; just like isitrap.
 1.15 27-Mar-2002  kleink Add separate 601 versions of DSI/ISI trap entries, considering the
different battable entry format and the combined BAT implementation.
 1.14 02-Mar-2002  kleink Also reset segment register 0 on kernel entry: there may not always be
a fixed BAT entry covering segment 0, or not completely covering it,
and we do restore it on return to user level already.
 1.13 27-Feb-2002  matt Add a comment to where we increment intr_depth to show that intstk+INTSTK
== intr_depth. (gag)
 1.12 06-Jan-2002  dbj add support for kgdb over zs
 1.11 30-Aug-2001  matt branches: 1.11.6;
Make sure to restore SR 0 since returning from a syscall is actually
one way of doing a process context switch.
 1.10 30-Jun-2001  matt branches: 1.10.2;
Reset segment registers 1-7 upon entry to kernel (via trap or interrupts)
so that the bat spill code won't run into spurious valid user pages and
treat them as kernel pages. Restore segment registers 1-7 upon return to
user mode from either a trap or interrupt. XXX eventually do all 16 SRs
 1.9 23-Jun-2001  matt Use SPR_xxx for the *MISS HASH CMP, etc.
 1.8 17-Jun-2001  simonb Use _C_LABEL() for externally referenced symbols.
 1.7 15-Jun-2001  matt Globalize trapexit. Improve db_trace.c so that you can trace thru traps!
Rework the output so that is also prints the frame address by default.
 1.6 08-Jun-2001  matt Rename pte_spill to pmap_pte_spill. Fix pmap_clear_{referenced,modify}
to return the previous state of the bit. Make it compile under
-Wmissing-prototypes -Wall. Change around some debug stuff.
 1.5 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.4 07-Mar-2001  tsubai Remove MULTIPROCESSOR part. (moved to separate file)
 1.3 01-Jan-2001  tsubai branches: 1.3.2;
Make want_resched and astpending per-CPU.
Add some per-CPU variables to cpu_info.
 1.2 04-Dec-2000  tsubai Move INTSTK and SPILLSTK definitions to locore.[Ss] to allow allocation of
them in early startup.
 1.1 16-Nov-2000  thorpej branches: 1.1.2;
Trap routines from the macppc port, to be used by other PowerPC
ports (only amigappc's differs).
 1.1.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 16-Nov-2000  bouyer file trap_subr.S was added on branch thorpej_scsipi on 2000-11-22 16:01:30 +0000
 1.3.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.10.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.10.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.10.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.11.6.8 18-Oct-2002  nathanw Catch up to -current.
 1.11.6.7 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.11.6.6 01-Aug-2002  nathanw Catch up to -current.
 1.11.6.5 20-Jun-2002  nathanw Catch up to -current.
 1.11.6.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.11.6.3 28-Feb-2002  nathanw Catch up to -current.
 1.11.6.2 11-Jan-2002  nathanw More catchup.
 1.11.6.1 30-Aug-2001  nathanw file trap_subr.S was added on branch nathanw_sa on 2002-01-11 23:38:43 +0000
 1.21.4.2 06-Nov-2002  tron Remove superflous "#endif" invented by last pullup which causes build
failures on PPC architectures. (requested by jdolecek in ticket #970)
 1.21.4.1 01-Nov-2002  tron Pull up revision 1.22 (requested by matt in ticket #373):
Revamp how SR(s) are loaded on the user/kernel boundary. We now load all
16 SR registers when transitioning between kernel and user. Also, don't
reload the kernel SR(s) on every trap but only on traps from user space.
Instead of loading magic SRs for the kernel, load the kernel SRs from the
kernel_pmap_. This makes trap_subr.S completely ignorant of SR uses and
so they can change with having to change trap_subr.S. Also note that
since the user and kernel get complete SR sets, user VA space can now be
increased to 4GB if desired.
 1.21.2.2 31-Aug-2002  gehenna catch up with -current.
 1.21.2.1 16-Jul-2002  gehenna catch up with -current.
 1.38.2.4 08-Mar-2005  skrll Sync with HEAD.
 1.38.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.38.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.38.2.1 03-Aug-2004  skrll Sync with HEAD
 1.54.4.1 07-May-2005  snj Pull up revision 1.57 (requested by matt in ticket #1286):
Don't enable interrupts while calling trap() if the trapping frame
didn't have them enabled either.
Addresses PR port-macppc/29559.
 1.54.2.1 07-May-2005  snj Pull up revision 1.57 (requested by matt in ticket #1286):
Don't enable interrupts while calling trap() if the trapping frame
didn't have them enabled either.
Addresses PR port-macppc/29559.
 1.56.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.56.4.1 29-Apr-2005  kent sync with -current
 1.57.4.3 11-Feb-2008  yamt sync with head.
 1.57.4.2 21-Jan-2008  yamt sync with head
 1.57.4.1 30-Dec-2006  yamt sync with head.
 1.57.2.1 20-Aug-2008  bouyer Pull up following revision(s) (requested by matt in ticket #1950):
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.65
Fix bug where SRR1 (%r2) was being accidently misused and modifed
in place of segreg (%r1).
> From Konrad Karpowicz <konradk at pacomp dot pl>.
 1.58.8.1 11-Aug-2006  yamt sync with head
 1.58.4.1 09-Sep-2006  rpaulo sync with head
 1.59.48.1 19-Jan-2008  bouyer Sync with HEAD
 1.59.40.1 18-Feb-2008  mjf Sync with HEAD.
 1.59.34.1 23-Mar-2008  matt sync with HEAD
 1.59.24.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.59.8.1 20-Aug-2008  bouyer Pull up following revision(s) (requested by matt in ticket #1174):
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.65
Fix bug where SRR1 (%r2) was being accidently misused and modifed
in place of segreg (%r1).
> From Konrad Karpowicz <konradk at pacomp dot pl>.
 1.63.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.63.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.63.10.2 11-Mar-2010  yamt sync with head
 1.63.10.1 04-May-2009  yamt sync with head.
 1.63.8.1 04-Jun-2008  yamt sync with head
 1.63.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.63.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.64.4.1 19-Oct-2008  haad Sync with HEAD.
 1.65.16.5 27-Mar-2011  matt Don't store the new idepth into the trapframe, use the idepth at the start
of the interrupt.
 1.65.16.4 28-Jan-2011  matt If a CPU has HIGHBAT, then use them. We dynamically change dsitrap to
select between bats 4-7 when HIGHBAT is detected.
 1.65.16.3 26-Jan-2011  matt Change battable to have a granularity of 8MB.
 1.65.16.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.65.16.1 07-Jan-2011  matt Deal with trapframe changes. Rework trap_subr.S to take advantage of the
simplier world.
 1.66.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.66.4.3 12-Jun-2011  rmind sync with head
 1.66.4.2 21-Apr-2011  rmind sync with head
 1.66.4.1 05-Mar-2011  rmind sync with head
 1.68.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.71.6.1 18-Feb-2012  mrg merge to -current.
 1.71.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.71.2.2 30-Oct-2012  yamt sync with head
 1.71.2.1 17-Apr-2012  yamt sync with head
 1.75.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.75.2.1 23-Jun-2013  tls resync from head
 1.76.4.1 28-Aug-2013  rmind sync with head
 1.77.2.1 10-Aug-2014  tls Rebase.
 1.78.26.2 28-Jul-2018  pgoyette Sync with HEAD
 1.78.26.1 21-May-2018  pgoyette Sync with HEAD
 1.79.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.79.2.1 10-Jun-2019  christos Sync with HEAD
 1.80.4.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #755):

sys/arch/evbppc/conf/std.virtex: revision 1.4
sys/arch/powerpc/powerpc/trap_subr.S: revision 1.81
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S: revision 1.8
sys/arch/evbppc/conf/std.walnut: revision 1.9
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h: revision 1.7
sys/arch/powerpc/include/asm.h: revision 1.49
common/lib/libc/arch/powerpc/atomic/atomic_cas.S: revision 1.9
sys/arch/powerpc/ibm4xx/trap_subr.S: revision 1.28
sys/arch/powerpc/include/lock.h: revision 1.15
sys/arch/evbppc/conf/std.obs266: revision 1.3
common/lib/libc/arch/powerpc/atomic/atomic_swap.S: revision 1.8
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.61
sys/arch/powerpc/powerpc/lock_stubs.S: revision 1.12
sys/arch/evbppc/conf/std.obs200: revision 1.5

Implement workaround for IBM405 Errata 77 (aka CPU_210), where
interrupted stwcx. may errantly write data to memory:

https://elinux.org/images/1/1d/Ppc405gp-errata.pdf

This is because stwcx. is split into two pieces in the pipeline.

We need to
(1) insert dcbt before every stwcx. instruction, as well as
(2) insert sync before every rfi/rfci instruction.

It is unclear which processors are affected, but according to Linux,
all 405-based cores up until 405GPR and 405EP are affected:

https://github.com/torvalds/linux/blob/master/arch/powerpc/platforms/40x/Kconfig#L140

For kernel, this workaround can be restricted to affected processors.

However, for kernel modules and userland, we have to enable it for all
32bit powerpc archs in order to share common binaries as before.
Proposed on port-powerpc:

http://mail-index.netbsd.org/port-powerpc/2020/02/21/msg003583.html
 1.84.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.86.10.1 02-Aug-2025  perseant Sync with HEAD
 1.12 02-Feb-2003  matt This file is no longer needed.
 1.11 02-Feb-2003  matt Perform a rototill of the powerpc code. Mandate use of SPRG0 to store
a pointer to current cpu's cpu_info structure. Use cpu_info for
intstk,intr_depth,still_stk,idle_pcb,curpcb,curlwp,etal even on
non-MULTIPROCESSOR machines. Add common macros GET_CPUINFO and
INIT_CPUINFO to get and initialize the cpu_info struct on startup. Make
ibm4xx use the standard <powerpc/frame.h>. Use IFRAME_xx in ibm4xx
trap_subr.S instead of explicit magic offsets. Move INTSTK and SPILLSTK
to std.<platform>. Change faultbuf to a struct instead of an array.

On MPC6XX cpus, stop using the vector page for temporary space and use
reserved space in cpu_info.
 1.10 22-Jan-2003  kleink Sync MPC601 support bits with UP version.
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 10-Oct-2002  matt Remove pmap_pte_spill calls.
 1.7 06-Aug-2002  chs be sure to re-enable interrupts before calling trap() a second time
due to an AST. the rule is that we must always have interrupts
enabled when acquiring kernel_lock, so that we can process blocking IPIs
from another CPU which is already holding kernel_lock.
reduce differences between the MP and non-MP versions of this file.
 1.6 02-Aug-2002  chs use a completely separate trap handler for syscall traps.
this reduces syscall overhead by 10% to 20% depending on cpu type.
 1.5 28-Jul-2002  chs resync the MP and non-MP trap_subr's.
 1.4 23-Jun-2001  matt branches: 1.4.2; 1.4.8; 1.4.16;
Use SPR_xxx for the *MISS HASH CMP, etc.
 1.3 15-Jun-2001  matt Globalize trapexit. Improve db_trace.c so that you can trace thru traps!
Rework the output so that is also prints the frame address by default.
 1.2 10-Jun-2001  tsubai pte_spill -> pmap_pte_spill.
 1.1 07-Mar-2001  tsubai branches: 1.1.2; 1.1.4;
MP version of trap routines.
 1.1.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.1 07-Mar-2001  bouyer file trap_subr_mp.S was added on branch thorpej_scsipi on 2001-03-12 13:29:15 +0000
 1.4.16.1 31-Aug-2002  gehenna catch up with -current.
 1.4.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.4.8.3 06-Aug-2002  nathanw Catch up with powerpc rototilling.
 1.4.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.4.8.1 23-Jun-2001  nathanw file trap_subr_mp.S was added on branch nathanw_sa on 2002-08-01 02:43:12 +0000
 1.4.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.106 15-Dec-2023  rin powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.

Part of PR kern/57621
 1.105 05-Dec-2022  martin branches: 1.105.2;
Do not copy l_md to the new lwp in cpu_lwp_fork - as discussed on
tech-kern we do not want the child to inherit any of the flags in there.
 1.104 06-Jul-2020  rin Drop unused opt_multiprocessor.h includes.
 1.103 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.102 24-Feb-2020  rin Oops, revert previous; fix build for PPC_OEA64 || PPC_OEA64_BRIDGE.
oea and booke seem to work without direct-mapped and physically
contiguous u-area.
 1.101 21-Feb-2020  rin When UPAGES > 1, both __HAVE_CPU_UAREA_ROUTINES and PMAP_MAP_POOLPAGE
must be defined in order to allocate physically contiguous memory for
u-area.
 1.100 06-Jul-2015  matt branches: 1.100.24;
Back out last change. Clearing PSL_FP/PSL_VEC is handled by child_return.
 1.99 06-Jul-2015  matt Clear PSL_FP/PSL_VEC so the lwp won't think it owns them.
 1.98 20-Oct-2012  kiyohara branches: 1.98.14;
Support Cache Protocol 'MEI' with MULTIPROCESSOR.
 1.97 28-Jun-2012  matt branches: 1.97.2;
Don't panic if you can't allocate a contiguous stack for system threads.
Just use a mapped a stack.
 1.96 24-Mar-2012  matt When a stack is specified, make sure the stack has enough for a previous
callframe in which the LR can be stored. (atf test t_clone:clone_basic
now passes).
 1.95 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.94 13-Feb-2012  phx branches: 1.94.2;
Allow all physical addresses from 0 to 0xffffffff in cpu_uarea_alloc().
This fixes a panic with amigappc, which has RAM starting at 0x08000000.
Ok by releng@.
 1.93 28-Jan-2012  skrll Typo in comment.
 1.92 02-Jul-2011  matt branches: 1.92.2; 1.92.6;
Allow the MD code to decide to panic if cpu_uarea_alloc would return NULL.
If NULL is returned, just allocate the standard way.
 1.91 02-Jul-2011  matt Default to normal uvm_uarea_alloc if we can't allocate one ourselves.
 1.90 20-Jun-2011  matt cleanup includes (include <powerpc/psl.h explicitly)
 1.89 17-Jun-2011  matt ofppc doesn't have PMAP_MAP_POOLPAGE so make the cpu_uareas do nothing.
 1.88 15-Jun-2011  matt Use PMAP_MAP_POOLPAGE/PMAP_UNMAP_POOLPAGE because it's cleaner.
Remove #ifdef _LP64 #endif leftover from mips
 1.87 14-Jun-2011  matt Include <uvm/uvm.h> instead of <uvm/uvm_extern.h> since we are using more
uvm functions.
 1.86 13-Jun-2011  matt Add __HAVE_CPU_UAREA_ROUTINES support so that uareas will be direct-mapped.
(This avoids the nasty tlb recursion problem on ibm4xx as well on mpc85xx).
 1.85 06-Jun-2011  matt Add some more MI hook points for PCU. Discard the PCU state at lwp_exit and
at exec time. Before forking, save the PCU state so that cpu_lwp_fork
doesn't have. Remove MD code which did that before.
 1.84 02-May-2011  matt branches: 1.84.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.83 10-Feb-2011  pooka Make vmapbuf() return success/error and make physio deal with a
failure.
 1.82 02-Feb-2011  matt Always call cpu_lwp_bootstrap even in cpu_setfunc. Let cpu_lwp_fork use
cpu_setfunc instead of duplicating code. Simplify stack setup.
PR 44500
 1.81 18-Jan-2011  matt branches: 1.81.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.80 21-Nov-2009  rmind branches: 1.80.4; 1.80.6;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.79 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.78 24-Oct-2009  rmind Provide cpu_lwp_free* stubs in vax and powerpc.
Reported by <he>.
 1.77 07-Jun-2009  martin Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.76 19-Nov-2008  cegger build fix: include <sys/buf.h>
 1.75 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.74 25-Oct-2008  mrg branches: 1.74.2; 1.74.4; 1.74.6;
make this build again after revivesa. ok'd by gimpy.

XXX: i think this will work but i haven't actually run any SA apps.
it does compile and link and the kernel boots just fine.
 1.73 17-Oct-2007  garbled branches: 1.73.16; 1.73.20; 1.73.26;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.72 17-Aug-2007  ad branches: 1.72.2;
cpu_lwp_fork: don't rely on struct mdlwp being zeroed in advance.
 1.71 17-May-2007  yamt branches: 1.71.4; 1.71.8;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.70 04-Mar-2007  macallan branches: 1.70.2; 1.70.4; 1.70.10;
make this compile again
 1.69 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.68 09-Feb-2007  ad branches: 1.68.2;
Merge newlock2 to head.
 1.67 31-Aug-2006  matt branches: 1.67.2;
Make cpu_coredump dependent on COREDUMP
 1.66 05-Aug-2006  sanjayl 1st cut of Powermac G5 support (uses bridge mode).
 1.65 11-Dec-2005  christos branches: 1.65.4; 1.65.8;
merge ktrace-lwp.
 1.64 10-Jun-2005  matt branches: 1.64.2;
Rework the coredump code to have no explicit knownledge of how coredump
i/o is done. Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o. This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
 1.63 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.62 17-Sep-2004  skrll branches: 1.62.4; 1.62.6;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.61 28-Aug-2004  thorpej Garbage-collect pagemove(); nothing use it anymore (YAY!!!)
 1.60 16-Apr-2004  matt Add a SAVE/DISCARD flag to save_{fpu,vec}_lwp. Use it appropriately.
Nuke struct fpu and use struct fpreg instead (except for the names, they
were identical). On MP machines, this will avoid an unneeded IPI to save
the register contents that are about to discarded.
 1.59 04-Apr-2004  matt On FPU'ed systems, initialize the default FP exception mode.
 1.58 04-Jan-2004  jdolecek Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
as FPU state), and is the last potentially blocking operation;
all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
 1.57 27-Sep-2003  matt ANSIfy.
 1.56 27-Aug-2003  matt Move SFRAMELEN to frame.h and use it in vm_machdep.c. In setfunc, setup
callframe linkages correctly. Restore use of ldptr to locore_subr.S
[pthreads and gdb no longer crash/hang the system]
 1.55 12-Aug-2003  matt Cleanup/rework cpu_switch*, switch_exit, Idle routine. Remove pcb_psl
since it was write-only. When setting up a process, make sure the fake
callframes are properly linked together.

Only lower SPL when in Idle loop. Raise spl to previous level (which would
be IPL_SCHED) when exiting Idle loop. Never lower SPL anyplace else.
 1.54 12-Aug-2003  matt Nuke ci_curpm and curpm. Nuke pcb_pmreal. Those were use for spill stacks
and those no longer exist. for few uses that need CURPM, use CURPCB/PCB_PM
 1.53 15-Jul-2003  lukem __KERNEL_RCSID()
 1.52 29-Jun-2003  fvdl branches: 1.52.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.51 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.50 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.49 14-Mar-2003  matt Quiet lint warning.
 1.48 05-Mar-2003  matt Make AltiVec registers available via ptrace/procfs. Simplify AltiVec
processing. Add a "common" procfs_machdep.c for PowerPC platforms.
Even though it is supposed to be port specific, most (if not all)
PowerPC ports can just use the common one.
 1.47 03-Feb-2003  matt Rename PPC_MPC6XX to PPC_OEA (and any mpc6xx reference to oea).
 1.46 03-Feb-2003  matt More cleanup for OLDPMAP.
 1.45 19-Jan-2003  matt Cast to register_t instead of int to be nicer for LP64.
Simplify copyin/copyout/copyinstr/copyoutstr. Fix bug
where the user virtual address was not updated so that
if the user's buffer crossed a segment boundary, the
wrong data could be copied. Localize USER_SR to the
ILP32 version of setusr/unsetusr.
 1.44 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.43 11-Aug-2002  matt Switch back to kenter_pa/kremove
 1.42 10-Aug-2002  matt More refinement, only map B_READ buf with VM_PROT_WRITE (all pages always
have VM_PROT_READ). Also, pass PMAP_WIRED to pmap_enter (for non-mpc6xx
pmaps). This will give pmap clues about flushing any "icache ok state".
 1.41 10-Aug-2002  matt Switch vmap*buf back to using pmap_enter/pmap_remove. This is so that
accesses to the buffer will cause the reference and modified bits for
the pages to be udpated appropriately.
 1.40 28-Jul-2002  chs restructure the FPU and AltiVEC code so that it works for MP.
 1.39 25-Jul-2002  matt Cleanup AltiVec data stream issues with context switching. Don't stop
data streams on execptions/interrupts since the processor will suspend
them for us. Only stop them on 1) process exit, 2) another process gets
its address space loaded, and 3) (for completeness only) we save a process's
AltiVec context.
 1.38 05-Jul-2002  matt Peform a rototill over the powerpc-based ports.

Move the trap/vector initialization for MPC6xx ports to mpc6xx_machdep.c
Also move softnet, install_extintr, mapiodev, kvtop. Add common BAT
initialization code.

Add user Altivec support.

Fix calls to OF_call_method in macppc/macppc/machdep.c.

Use ci_fpuproc in cpu_info instead of separate fpuproc.

Add separate syscall.c and defined __HAVE_SYSCALL_INTERN.
 1.37 09-Mar-2002  chs branches: 1.37.6;
switch all mpc6xx powerpc ports to NEWPMAP by default.
the old pmap is still available with the OLDPMAP option.
 1.36 10-Sep-2001  chris branches: 1.36.4;
Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.35 19-Aug-2001  chs branches: 1.35.2;
add missing pmap_update().
 1.34 04-Aug-2001  chs use pmap_k* in pagemove(), ie. for buffer cache pages.
in vunmapbuf(), call pmap_kremove() explicitly since uvm_km_free_wakeup()
will soon no longer do it for us.
 1.33 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.32 28-Jun-2001  matt branches: 1.32.2;
Change a bcopy to a structure copy.
 1.31 23-Jun-2001  matt Use pmap_kenter_pa instead of pmap_enter for phys_map
 1.30 15-Jun-2001  matt phys_map should use kenter/kremove
 1.29 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.28 10-Jun-2001  tsubai Make the new pmap optional. Use the old (stable!) pmap by default.
 1.27 06-Jun-2001  matt Introduce a new & faster pmap for the MPC6xx (60x, 7xx, 7xxx) PPC CPUs.
Move MPC6xx dependent header files to powerpc/include/mpc6xx/
 1.26 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.25 31-Mar-2001  tsubai Fix an uninitialized variable reference in cpu_fork().
Reported by Tad Hunt <tad@entrisphere.com>.
 1.24 22-Mar-2001  tsubai Merge my MP tree. At this point, Daystar dual 604 card (i.e. Power Macintosh
9500/180MP and 9600/200MP) runs at least into single-user mode, possibly
multi-user mode (not stable yet).
 1.23 04-Feb-2001  briggs branches: 1.23.2;
Build with -Wall -Wetc.
 1.22 25-Nov-2000  matt Some preliminary ALTIVEC support.
 1.21 21-Aug-2000  tsubai Scheduler locking changes.
 1.20 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.19 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.18 04-Jun-2000  tsubai Dump fp regs into core file.
 1.17 28-May-2000  thorpej Rather than starting init and creating kthreads by forking and then
doing a cpu_set_kpc(), just pass the entry point and argument all
the way down the fork path starting with fork1(). In order to
avoid special-casing the normal fork in every cpu_fork(), MI code
passes down child_return() and the child process pointer explicitly.

This fixes a race condition on multiprocessor systems; a CPU could
grab the newly created processes (which has been placed on a run queue)
before cpu_set_kpc() would be performed.
 1.16 26-Mar-2000  kleink branches: 1.16.2;
Merge parts of chs-ubc2 into the trunk:
* Remove the casts to vaddr_t from the round_page() and trunc_page() macros to
make them type-generic, which is necessary i.e. to operate on file offsets
without truncating them.
* In due course, cast pointer arguments to these macros to an appropriate
integral type (paddr_t, vaddr_t).

Originally done by Chuck Silvers, updated by myself.
 1.15 20-Jan-2000  sommerfeld Fix PR9240: comment above cpu_fork() out of synch with reality on most ports.
(comment change only, but was wrong for more than just i386).
 1.14 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.13 08-Jul-1999  thorpej branches: 1.13.2; 1.13.4; 1.13.8;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.12 26-May-1999  thorpej Generally update the comment above vunmapbuf().
 1.11 26-May-1999  thorpej Generally update the comment above the vmapbuf() implementations.
 1.10 13-May-1999  thorpej Allow the caller to specify a stack for the child process. If NULL,
the child inherits the stack pointer from the parent (traditional
behavior). Like the signal stack, the stack area is secified as
a low address and a size; machine-dependent code accounts for stack
direction.

This is required for clone(2).
 1.9 26-Mar-1999  mycroft branches: 1.9.4;
Changes for modified pmap_enter() API:
* Map the message buffer with access_type = VM_PROT_READ|VM_PROT_WRITE `just
because'.
* Map the file system buffers with access_type = VM_PROT_READ|VM_PROT_WRITE to
avoid possible problems with pagemove().
* Do not use VM_PROT_EXEC with either of the above.
* Map pages for /dev/mem with access_type = prot. Also, DO NOT use
pmap_kenter() for this, as we DO NOT want to lose modification information.
* Map pages in dumpsys() with VM_PROT_READ.
* Map pages in m68k mappedcopyin()/mappedcopyout() and writeback() with
access_type = prot.
* For now, bus_dma*(), pmap_map(), vmapbuf(), and similar functions still use
access_type = 0. This should probably be revisited.
 1.8 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.7 11-Nov-1998  thorpej Changes to support fork_kthread():
- cpu_set_kpc() now takes void *arg third argument, passed to the
entry point.
- cpu_fork() allows parent to be non-curproc iff parent is proc0.
When forking non-curproc, assume its state has already been saved.
- Adjust various pieces of machine-dependent code to account of all of this.
 1.6 09-Sep-1998  thorpej In cpu_coredump(), use MID_MACHINE rather than MID_* (whatever it expands
to).
 1.5 09-Sep-1998  thorpej Adjust for the new "reaper" kernel thread: do not free the vmspace and
u-area in machine-dependent code. Instead, call exit2() to schedule
the reaper to free them for us, once it is safe to do so (i.e. we are
no longer running on the dead proc's vmspace and stack).
 1.4 31-Aug-1998  tsubai vm_offset_t --> [pv]addr_t
 1.3 05-Jun-1998  sakamoto Merge in MACHINE_NEW_NONCONTIG support and some fix from Tsubai-San.
UVM support.
 1.2 06-Jan-1998  thorpej Don't use vm_pmap; use vm_map.pmap instead.
 1.1 30-Sep-1996  ws PowerPC port
 1.9.4.2 02-Aug-1999  thorpej Update from trunk.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.13.4.1 15-Nov-1999  fvdl Sync with -current
 1.13.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.13.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.13.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.13.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.16.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.23.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.23.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.32.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.32.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.32.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.32.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.32.2.1 03-Aug-2001  lukem update to -current
 1.35.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.36.4.11 05-Jan-2003  thorpej * Merge switch_exit() and switch_lwp_exit().
* Keep the stack 16-byte aligned; adjust by USPACE-16, not USPACE-20.
 1.36.4.10 13-Aug-2002  nathanw Catch up to -current.
 1.36.4.9 01-Aug-2002  nathanw LWPify
 1.36.4.8 01-Aug-2002  nathanw Catch up to -current.
 1.36.4.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.36.4.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.36.4.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.36.4.4 08-Dec-2001  thorpej cpu_fork() -> cpu_lwp_fork(). This logically forks an LWP, not a
complete process. As noted by Gregory McGarry on tech-kern.
 1.36.4.3 21-Nov-2001  briggs Document stack alignment in cpu_fork. Provide stack alignment in cpu_setfunc.
 1.36.4.2 05-Nov-2001  briggs Initial SA support for ppc. Test-booted on sandpoint, macppc, & walnut.
mcontext and cpu_getmcontext()/cpu_setmcontext() from Klaus Klein
<kleink@netbsd.org>.
 1.36.4.1 10-Sep-2001  briggs file vm_machdep.c was added on branch nathanw_sa on 2001-11-05 19:46:19 +0000
 1.37.6.2 31-Aug-2002  gehenna catch up with -current.
 1.37.6.1 16-Jul-2002  gehenna catch up with -current.
 1.52.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.52.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.52.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.52.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.52.2.3 03-Sep-2004  skrll Sync with HEAD
 1.52.2.2 03-Aug-2004  skrll Sync with HEAD
 1.52.2.1 03-Jul-2003  wrstuden LWP-ify for bebox/GENERIC
 1.62.6.2 11-Feb-2005  yamt use new apis.
 1.62.6.1 28-Jan-2005  yamt convert arch/powerpc to new apis.
 1.62.4.1 29-Apr-2005  kent sync with -current
 1.64.2.3 03-Sep-2007  yamt sync with head.
 1.64.2.2 26-Feb-2007  yamt sync with head.
 1.64.2.1 30-Dec-2006  yamt sync with head.
 1.65.8.2 03-Sep-2006  yamt sync with head.
 1.65.8.1 11-Aug-2006  yamt sync with head
 1.65.4.1 09-Sep-2006  rpaulo sync with head
 1.67.2.1 28-Jan-2007  ad powerpc changes.
 1.68.2.2 03-Apr-2007  matt Adapt powerpc to yamt-idlelwp. Nuke cpu_setfunc.
Don't define _HAVE_BITENDIAN_BITOPS. Misc cleanups.
 1.68.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.70.10.3 03-Oct-2007  garbled Sync with HEAD
 1.70.10.2 02-Aug-2007  macallan sync with HEAD
 1.70.10.1 22-May-2007  matt Update to HEAD.
 1.70.4.1 11-Jul-2007  mjf Sync with head.
 1.70.2.2 20-Aug-2007  ad Sync with HEAD.
 1.70.2.1 27-May-2007  ad Sync with head.
 1.71.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.71.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.72.2.1 06-Nov-2007  matt sync with HEAD
 1.73.26.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.73.20.3 11-Mar-2010  yamt sync with head
 1.73.20.2 20-Jun-2009  yamt sync with head
 1.73.20.1 04-May-2009  yamt sync with head.
 1.73.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.74.6.1 09-Jun-2009  snj branches: 1.74.6.1.2;
Pull up following revision(s) (requested by martin in ticket #801):
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.38
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.77
Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.74.6.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.74.4.1 09-Jun-2009  snj branches: 1.74.4.1.4;
Pull up following revision(s) (requested by martin in ticket #801):
sys/arch/powerpc/powerpc/locore_subr.S: revision 1.38
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.77
Do not use the same trampoline for cpu_setfunc and cpu_lwp_fork, the
latter does a lot more work.
 1.74.4.1.4.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.74.4.1.4.1 07-Jan-2011  matt Deal with trapframe changes and booke changes.
 1.74.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.80.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.80.4.3 12-Jun-2011  rmind sync with head
 1.80.4.2 31-May-2011  rmind sync with head
 1.80.4.1 05-Mar-2011  rmind sync with head
 1.81.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.81.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.84.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.92.6.3 05-Apr-2012  mrg sync to latest -current.
 1.92.6.2 24-Feb-2012  mrg sync to -current.
 1.92.6.1 18-Feb-2012  mrg merge to -current.
 1.92.2.2 30-Oct-2012  yamt sync with head
 1.92.2.1 17-Apr-2012  yamt sync with head
 1.94.2.2 04-Jul-2012  jdc Pull up revision 1.97 (requested by matt in ticket #388).

Don't panic if you can't allocate a contiguous stack for system threads.
Just use a mapped a stack.
 1.94.2.1 09-May-2012  riz Pull up following revision(s) (requested by matt in ticket #239):
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.96
When a stack is specified, make sure the stack has enough for a previous
callframe in which the LR can be stored. (atf test t_clone:clone_basic
now passes).
 1.97.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.98.14.1 22-Sep-2015  skrll Sync with HEAD
 1.100.24.1 29-Feb-2020  ad Sync with head.
 1.105.2.1 29-Dec-2023  martin Additionally pull up following revision(s) (requested by rin in ticket #400):

sys/arch/powerpc/include/oea/pmap.h: revision 1.39
sys/arch/powerpc/include/pmap.h: revision 1.43
sys/arch/powerpc/oea/pmap_kernel.c: revision 1.14
sys/arch/powerpc/oea/pmap.c: revision 1.117
sys/arch/powerpc/oea/pmap.c: revision 1.118
sys/arch/powerpc/oea/pmap.c: revision 1.119
sys/arch/powerpc/include/vmparam.h: revision 1.27
sys/arch/powerpc/powerpc/trap.c: revision 1.165
sys/arch/powerpc/oea/pmap.c: revision 1.120
sys/arch/powerpc/oea/pmap.c: revision 1.121
sys/arch/powerpc/powerpc/vm_machdep.c: revision 1.106
sys/arch/powerpc/powerpc/bus_dma.c: revision 1.56

powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.
Part of PR kern/57621

powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC
Part of PR kern/57621

powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.
Part of PR kern/57621

powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool
(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.
(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.
(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.
Part of PR kern/57621

powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC
Part of PR kern/57621

powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory
As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.
PR kern/57621

powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.
Part of PR kern/57621
 1.1 19-Aug-2010  uebayasi branches: 1.1.2;
file xmd_machdep.c was initially added on branch uebayasi-xip.
 1.1.2.3 30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.1.2.2 25-Aug-2010  uebayasi RCS id. Minor clean up.
 1.1.2.1 19-Aug-2010  uebayasi Initial addition of xmd(4), XIP memory disk.
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.5 24-May-2008  kiyohara Fix some bugs for bebox.
 1.4 01-May-2008  garbled branches: 1.4.2;
Add a missing Makefile that I forgot to commit in the mkbootimage
switch. Caught by Juergen Hannken-Illjes.
 1.3 28-May-1998  sakamoto branches: 1.3.78; 1.3.80; 1.3.82;
Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.3.82.2 04-May-2009  yamt sync with head.
 1.3.82.1 16-May-2008  yamt sync with head.
 1.3.80.2 04-Jun-2008  yamt sync with head
 1.3.80.1 18-May-2008  yamt sync with head.
 1.3.78.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.3 22-May-1998  drochner STANDALONE->_STANDALONE (cpp definition)
closes PR kern/5481 (Erik Bertelsen <erik@q610.ebe.uni-c.dk>)
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.3 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.2 07-Oct-1996  cgd don't include <machine/exec.h> explicitly. No other changes needed, since
<sys/exec.h> was already being included.
 1.1 30-Sep-1996  ws PowerPC port
 1.3 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.2 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1 30-Sep-1996  ws branches: 1.1.6;
PowerPC port
 1.1.6.1 07-Mar-1997  is Use libsa copy of oldstyle if_ether.h for now
 1.3 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.2 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1 30-Sep-1996  ws branches: 1.1.6;
PowerPC port
 1.1.6.1 07-Mar-1997  is Use libsa copy of oldstyle if_ether.h for now
 1.2 28-May-1998  sakamoto Rename NetBSD/powerpc to NetBSD/ofppc.
New sys/arch/powerpc with PowerPC-generic stuff.
 1.1 17-Apr-1997  thorpej oops, forgot to commit this yesterday - newvers.sh script for boot
program.
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.2 16-Apr-1997  thorpej New OpenFirmware boot code for NetBSD/powerpc, based on Wolfgang's original
NetBSD/powerpc boot program. Highligts:
- Rearrange a bit so that we can sanely add boot programs for
non-OpenFirmware systems.
- Add support for loading compressed kernels (for booting from
1.44M floppies).
- Add support for loading Elf kernels (Elf is the new standard format
for NetBSD/powerpc). (XXX Don't load symbols right now - the code
to do it is there, but I don't particularly like how space for the
symbol table is allocated; I will revisit this soon'ish).
 1.1 30-Sep-1996  ws PowerPC port
 1.5 09-Jul-2013  joerg Don't depend on libz.a for the tools build, /usr/lib/libz.a might not
exist.
 1.4 26-Jan-2011  joerg branches: 1.4.4; 1.4.14; 1.4.18;
Fix tools build on !NetBSD. Fix printfs to use correct types.
 1.3 07-Nov-2009  skrll branches: 1.3.4; 1.3.6; 1.3.8;
Use elf/external.h from new binutils.

XXX do we need a src/tools/compat/elf.h?
 1.2 30-Apr-2008  garbled Convert prep to use the new unified mkbootimage rather than it's own. This
mkbootimage can be shared by prep, rs6000, and bebox.

TODO: Convert bebox to use this. Needs someone to test.
 1.1 18-Dec-2007  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18;
Copy prep/stand/mkbootimage over to powerpc/stand/mkbootimage. The
makefile still needs work, and I still need to do some additional
fiddling here, but this is to be the unified rs6000/prep/bebox
mkbootimage eventually.
 1.1.18.2 11-Mar-2010  yamt sync with head
 1.1.18.1 16-May-2008  yamt sync with head.
 1.1.16.1 18-May-2008  yamt sync with head.
 1.1.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 21-Jan-2008  yamt sync with head
 1.1.8.1 18-Dec-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2008-01-21 09:38:30 +0000
 1.1.6.2 09-Jan-2008  matt sync with HEAD
 1.1.6.1 18-Dec-2007  matt file Makefile was added on branch matt-armv6 on 2008-01-09 01:47:57 +0000
 1.1.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.4.1 18-Dec-2007  bouyer file Makefile was added on branch bouyer-xeni386 on 2008-01-02 21:49:13 +0000
 1.1.2.2 18-Dec-2007  garbled Copy prep/stand/mkbootimage over to powerpc/stand/mkbootimage. The
makefile still needs work, and I still need to do some additional
fiddling here, but this is to be the unified rs6000/prep/bebox
mkbootimage eventually.
 1.1.2.1 18-Dec-2007  garbled file Makefile was added on branch mjf-devfs on 2007-12-18 18:19:08 +0000
 1.3.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 05-Mar-2011  rmind sync with head
 1.4.18.1 28-Aug-2013  rmind sync with head
 1.4.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4 22-Apr-2014  phx Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.3 24-Dec-2012  kiyohara branches: 1.3.2; 1.3.10;
Change name of boot image(mount point?) to 'NetBSD' from 'fd'.
 1.2 24-May-2008  kiyohara branches: 1.2.32; 1.2.38; 1.2.42;
Fix some bugs for bebox.
 1.1 20-Dec-2007  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18; 1.1.20;
Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.1.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.1.18.1 04-May-2009  yamt sync with head.
 1.1.16.1 04-Jun-2008  yamt sync with head
 1.1.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 21-Jan-2008  yamt sync with head
 1.1.8.1 20-Dec-2007  yamt file bebox_bootrec.h was added on branch yamt-lazymbuf on 2008-01-21 09:38:30 +0000
 1.1.6.2 09-Jan-2008  matt sync with HEAD
 1.1.6.1 20-Dec-2007  matt file bebox_bootrec.h was added on branch matt-armv6 on 2008-01-09 01:47:58 +0000
 1.1.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.4.1 20-Dec-2007  bouyer file bebox_bootrec.h was added on branch bouyer-xeni386 on 2008-01-02 21:49:13 +0000
 1.1.2.2 20-Dec-2007  garbled Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.1.2.1 20-Dec-2007  garbled file bebox_bootrec.h was added on branch mjf-devfs on 2007-12-20 23:00:00 +0000
 1.2.42.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.42.1 25-Feb-2013  tls resync with head
 1.2.38.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by phx in ticket #1074):
sys/arch/powerpc/stand/mkbootimage/mkbootimage.c: revision 1.18
sys/arch/powerpc/stand/mkbootimage/pef.h: revision 1.3
sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h: revision 1.4
Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.2.32.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.32.1 23-Jan-2013  yamt sync with head
 1.3.10.1 10-Aug-2014  tls Rebase.
 1.3.2.1 18-May-2014  rmind sync with head
 1.4 24-May-2008  kiyohara Fix some bugs for bebox.
 1.3 20-Dec-2007  garbled branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8; 1.3.14; 1.3.16; 1.3.18; 1.3.20;
Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.2 19-Dec-2007  garbled Add rs6000 stuff in here now.
 1.1 19-Dec-2007  garbled Changed my mind on naming this prep_magic.h. Change it back to magic.h.
Sorry for the churn.
 1.3.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.18.1 04-May-2009  yamt sync with head.
 1.3.16.1 04-Jun-2008  yamt sync with head
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.8.2 21-Jan-2008  yamt sync with head
 1.3.8.1 20-Dec-2007  yamt file magic.h was added on branch yamt-lazymbuf on 2008-01-21 09:38:30 +0000
 1.3.6.2 09-Jan-2008  matt sync with HEAD
 1.3.6.1 20-Dec-2007  matt file magic.h was added on branch matt-armv6 on 2008-01-09 01:47:58 +0000
 1.3.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.4.1 20-Dec-2007  bouyer file magic.h was added on branch bouyer-xeni386 on 2008-01-02 21:49:14 +0000
 1.3.2.2 20-Dec-2007  garbled Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.3.2.1 20-Dec-2007  garbled file magic.h was added on branch mjf-devfs on 2007-12-20 23:00:01 +0000
 1.21 03-Nov-2024  gutteridge mkbootimage.c: consistently use sa_htobe32(2)

There were 38 calls to sa_htobe32(2) and two to htonl(3), mixed even
within the same function, with arpa/inet.h not included. (It's unclear
why this varied, as the original version of this file first checked in
included this discrepancy.)

Addresses build failure issue on current Linux distros that have a GCC
with implicit-function-declaration baked in as an error. Build tested
on Fedora 40.

Issue reported by Jan-Benedict Glaw. Also relevant to PR lib/58674.
 1.20 08-Feb-2024  christos branches: 1.20.2;
PR/57906: Jan-Benedict Glaw: Extend`mkbootimage` to allow for
$MKREPRO_TIMESTAMP usage
 1.19 21-Jan-2016  christos branches: 1.19.48;
PR/50685: David Binderman: fix memory leak
 1.18 22-Apr-2014  phx branches: 1.18.4;
Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.17 09-Jul-2013  joerg branches: 1.17.4;
Fix format string.
 1.16 19-Dec-2012  kiyohara branches: 1.16.2;
Obsolete options '-s'(standalone) on bebox. bebox can boot no-standalone image
from FD or HDD.
 1.15 19-May-2012  kiyohara branches: 1.15.2;
prep's boot supports to load kernel from HDD. We can specify option -I
(no in-kernel).
 1.14 26-Jan-2011  joerg branches: 1.14.4; 1.14.8; 1.14.10;
Fix tools build on !NetBSD. Fix printfs to use correct types.
 1.13 16-Oct-2010  kiyohara branches: 1.13.2; 1.13.4;
Add option -I (no-inkernel). bebox loads kernel from HDD.
 1.12 16-Oct-2010  kiyohara Remove unnecessary white-spaces and Tabs.
Replace white-spaces to Tab.
 1.11 01-Sep-2008  martin branches: 1.11.14; 1.11.16;
Fix machine_arch vs. machine confusion, PR 39436.
OK: garbled
 1.10 24-May-2008  kiyohara branches: 1.10.4;
Fix some bugs for bebox.
 1.9 30-Apr-2008  garbled branches: 1.9.2;
Convert prep to use the new unified mkbootimage rather than it's own. This
mkbootimage can be shared by prep, rs6000, and bebox.

TODO: Convert bebox to use this. Needs someone to test.
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 24-Dec-2007  garbled branches: 1.7.2; 1.7.4; 1.7.6; 1.7.12; 1.7.14; 1.7.16;
Fix a segv if you forget to set the -m option.
 1.6 20-Dec-2007  garbled branches: 1.6.2;
Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.5 20-Dec-2007  garbled add verbose flag to usage statement.
 1.4 20-Dec-2007  garbled Port over the code from rs6000/stand/mkbootimage. Now the unified
mkbootimage can build both prep and rs6000 images.
 1.3 19-Dec-2007  garbled Changed my mind on naming this prep_magic.h. Change it back to magic.h.
Sorry for the churn.
 1.2 18-Dec-2007  garbled First crack at a new unified mkbootimage for powerpc. Still some work
left to do here, so the build isn't enabled yet.
 1.1 18-Dec-2007  garbled Copy prep/stand/mkbootimage over to powerpc/stand/mkbootimage. The
makefile still needs work, and I still need to do some additional
fiddling here, but this is to be the unified rs6000/prep/bebox
mkbootimage eventually.
 1.6.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.6.2.1 20-Dec-2007  mjf file mkbootimage.c was added on branch mjf-devfs on 2008-02-18 21:04:59 +0000
 1.7.16.2 04-May-2009  yamt sync with head.
 1.7.16.1 16-May-2008  yamt sync with head.
 1.7.14.2 04-Jun-2008  yamt sync with head
 1.7.14.1 18-May-2008  yamt sync with head.
 1.7.12.2 28-Sep-2008  mjf Sync with HEAD.
 1.7.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.6.2 21-Jan-2008  yamt sync with head
 1.7.6.1 24-Dec-2007  yamt file mkbootimage.c was added on branch yamt-lazymbuf on 2008-01-21 09:38:31 +0000
 1.7.4.2 09-Jan-2008  matt sync with HEAD
 1.7.4.1 24-Dec-2007  matt file mkbootimage.c was added on branch matt-armv6 on 2008-01-09 01:47:58 +0000
 1.7.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.7.2.1 24-Dec-2007  bouyer file mkbootimage.c was added on branch bouyer-xeni386 on 2008-01-02 21:49:15 +0000
 1.9.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.4.1 19-Oct-2008  haad Sync with HEAD.
 1.11.16.1 05-Mar-2011  rmind sync with head
 1.11.14.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.13.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.13.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.10.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by phx in ticket #1074):
sys/arch/powerpc/stand/mkbootimage/mkbootimage.c: revision 1.18
sys/arch/powerpc/stand/mkbootimage/pef.h: revision 1.3
sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h: revision 1.4
Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.14.8.1 02-Jun-2012  mrg sync to latest -current.
 1.14.4.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.14.4.2 23-Jan-2013  yamt sync with head
 1.14.4.1 23-May-2012  yamt sync with head.
 1.15.2.3 03-Dec-2017  jdolecek update from HEAD
 1.15.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.1 25-Feb-2013  tls resync with head
 1.16.2.2 18-May-2014  rmind sync with head
 1.16.2.1 28-Aug-2013  rmind sync with head
 1.17.4.1 10-Aug-2014  tls Rebase.
 1.18.4.1 19-Mar-2016  skrll Sync with HEAD
 1.19.48.1 15-Dec-2024  martin Pull up following revision(s) (requested by gutteridge in ticket #1019):

sys/arch/hppa/stand/mkboot/mkboot.c: revision 1.5
sys/arch/powerpc/stand/mkbootimage/mkbootimage.c: revision 1.21
usr.bin/elf2aout/elf2aout.c: revision 1.25

mkboot.c: ensure all functions are declared

Addresses build failure issue on current Linux distros that have a GCC
with implicit-function-declaration baked in as an error. Use be32toh(3)
instead of ntohl(3), seems to make more sense stylistically. Build
tested on Fedora 40.

Issue reported by Jan-Benedict Glaw. Also relevant to PR lib/58674.


elf2aout.c: switch to use htobe32(3)

As discussed on tech-toolchain. Tested with virt68k tools build on
Fedora 40. (Relevant to PR lib/58674.)


mkbootimage.c: consistently use sa_htobe32(2)

There were 38 calls to sa_htobe32(2) and two to htonl(3), mixed even
within the same function, with arpa/inet.h not included. (It's unclear
why this varied, as the original version of this file first checked in
included this discrepancy.)

Addresses build failure issue on current Linux distros that have a GCC
with implicit-function-declaration baked in as an error. Build tested
on Fedora 40.

Issue reported by Jan-Benedict Glaw. Also relevant to PR lib/58674.
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 22-Apr-2014  phx Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.2 16-Oct-2010  kiyohara branches: 1.2.8; 1.2.14; 1.2.18; 1.2.22; 1.2.32;
Remove unnecessary white-spaces and Tabs.
Replace white-spaces to Tab.
 1.1 20-Dec-2007  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.38; 1.1.40;
Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.1.40.1 05-Mar-2011  rmind sync with head
 1.1.38.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.8.2 21-Jan-2008  yamt sync with head
 1.1.8.1 20-Dec-2007  yamt file pef.h was added on branch yamt-lazymbuf on 2008-01-21 09:38:31 +0000
 1.1.6.2 09-Jan-2008  matt sync with HEAD
 1.1.6.1 20-Dec-2007  matt file pef.h was added on branch matt-armv6 on 2008-01-09 01:47:59 +0000
 1.1.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.4.1 20-Dec-2007  bouyer file pef.h was added on branch bouyer-xeni386 on 2008-01-02 21:49:16 +0000
 1.1.2.2 20-Dec-2007  garbled Add bebox mkbootimage stuff to the unified mkbootimage. It should work
in theory, assuming:

a) I didn't mess up
b) The original code in bebox/stand actually works
 1.1.2.1 20-Dec-2007  garbled file pef.h was added on branch mjf-devfs on 2007-12-20 23:00:01 +0000
 1.2.32.1 10-Aug-2014  tls Rebase.
 1.2.22.1 18-May-2014  rmind sync with head
 1.2.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.14.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by phx in ticket #1074):
sys/arch/powerpc/stand/mkbootimage/mkbootimage.c: revision 1.18
sys/arch/powerpc/stand/mkbootimage/pef.h: revision 1.3
sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h: revision 1.4
Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.
 1.2.8.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3 19-Dec-2007  garbled branches: 1.3.2;
Changed my mind on naming this prep_magic.h. Change it back to magic.h.
Sorry for the churn.
 1.2 18-Dec-2007  garbled First crack at a new unified mkbootimage for powerpc. Still some work
left to do here, so the build isn't enabled yet.
 1.1 18-Dec-2007  garbled Copy prep/stand/mkbootimage over to powerpc/stand/mkbootimage. The
makefile still needs work, and I still need to do some additional
fiddling here, but this is to be the unified rs6000/prep/bebox
mkbootimage eventually.
 1.3.2.2 19-Dec-2007  garbled Changed my mind on naming this prep_magic.h. Change it back to magic.h.
Sorry for the churn.
 1.3.2.1 19-Dec-2007  garbled file prep_magic.h was added on branch mjf-devfs on 2007-12-19 19:45:35 +0000
 1.2 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.1 19-Dec-2007  garbled branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.122;
bring over bootrec.h from rs6000/stand/mkbootimage
 1.1.122.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1.8.2 21-Jan-2008  yamt sync with head
 1.1.8.1 19-Dec-2007  yamt file rs6000_bootrec.h was added on branch yamt-lazymbuf on 2008-01-21 09:38:31 +0000
 1.1.6.2 09-Jan-2008  matt sync with HEAD
 1.1.6.1 19-Dec-2007  matt file rs6000_bootrec.h was added on branch matt-armv6 on 2008-01-09 01:47:59 +0000
 1.1.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.4.1 19-Dec-2007  bouyer file rs6000_bootrec.h was added on branch bouyer-xeni386 on 2008-01-02 21:49:16 +0000
 1.1.2.2 19-Dec-2007  garbled bring over bootrec.h from rs6000/stand/mkbootimage
 1.1.2.1 19-Dec-2007  garbled file rs6000_bootrec.h was added on branch mjf-devfs on 2007-12-19 19:50:15 +0000
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file Makefile was added on branch thorpej_scsipi on 2000-11-20 20:31:20 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file README was added on branch thorpej_scsipi on 2000-11-20 20:31:20 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.134; 1.1.1.1.136; 1.1.1.1.138;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.138.1 16-May-2008  yamt sync with head.
 1.1.1.1.136.1 18-May-2008  yamt sync with head.
 1.1.1.1.134.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file chrpicon.h was added on branch thorpej_scsipi on 2000-11-20 20:31:21 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.12; 1.1.1.1.16;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.16.1 08-Jan-2002  nathanw Catch up to -current.
 1.1.1.1.12.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file Makefile was added on branch thorpej_scsipi on 2000-11-20 20:31:22 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.76; 1.3.78;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.32;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.32.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.32.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.32.1 03-Aug-2004  skrll Sync with HEAD
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file chrpicontoppm.c was added on branch thorpej_scsipi on 2000-11-20 20:31:22 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.78.1 16-May-2008  yamt sync with head.
 1.3.76.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 23-Jan-2008  garbled Make this output the icon in 16 byte rows, which seems to be what IBM wants.
Change the makefile to make it compile on modern pkgsrc versions of netpbm.
 1.2 12-Dec-2001  tv branches: 1.2.32; 1.2.94; 1.2.100;
MKfoo=no -> NOfoo
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.12; 1.1.1.1.16;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.16.1 08-Jan-2002  nathanw Catch up to -current.
 1.1.1.1.12.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file Makefile was added on branch thorpej_scsipi on 2000-11-20 20:31:22 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.100.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.94.1 23-Mar-2008  matt sync with HEAD
 1.2.32.1 04-Feb-2008  yamt sync with head.
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 23-Jan-2008  garbled branches: 1.5.6; 1.5.8; 1.5.10;
Make this output the icon in 16 byte rows, which seems to be what IBM wants.
Change the makefile to make it compile on modern pkgsrc versions of netpbm.
 1.4 11-Dec-2005  christos branches: 1.4.50; 1.4.56;
merge ktrace-lwp.
 1.3 15-Jul-2003  lukem branches: 1.3.16;
__KERNEL_RCSID()
 1.2 20-Aug-2001  wiz branches: 1.2.6; 1.2.22;
"wierd" is weird.
 1.1 19-Nov-1999  lonhyn branches: 1.1.1;
Initial revision
 1.1.1.1 19-Nov-1999  lonhyn branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.12;
Program to convert back and forth between PPM and CHRP boot icon images.
 1.1.1.1.12.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.1.1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.8.1 19-Nov-1999  bouyer file ppmtochrpicon.c was added on branch thorpej_scsipi on 2000-11-20 20:31:23 +0000
 1.1.1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.22.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.22.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.22.1 03-Aug-2004  skrll Sync with HEAD
 1.2.6.2 20-Aug-2001  wiz "wierd" is weird.
 1.2.6.1 20-Aug-2001  wiz file ppmtochrpicon.c was added on branch nathanw_sa on 2001-08-20 12:20:07 +0000
 1.3.16.1 04-Feb-2008  yamt sync with head.
 1.4.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.50.1 23-Mar-2008  matt sync with HEAD
 1.5.10.1 16-May-2008  yamt sync with head.
 1.5.8.1 18-May-2008  yamt sync with head.
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.

RSS XML Feed