Home | History | Annotate | only in /src/sys/arch/or1k/include
History log of /src/sys/arch/or1k/include
RevisionDateAuthorComments
 1.5 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.4 04-Nov-2024  christos Undo previous lwp.h change.
 1.3 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.2 12-Jul-2018  maxv branches: 1.2.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.1 03-Sep-2014  matt branches: 1.1.18; 1.1.20; 1.1.22;
New files for OR1K support
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2.36.1 02-Aug-2025  perseant Sync with HEAD
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file ansi.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file aout_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.4 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.3 05-Jan-2025  martin 58960: or1k/asm.h: Respect NETBSD_REVISIONID.
 1.2 17-Apr-2020  joerg branches: 1.2.26;
Mark the .ident section as mergable string section to avoid redundant
entries.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.22; 1.1.32;
New files for OR1K support
 1.1.32.1 20-Apr-2020  bouyer Sync with HEAD
 1.1.22.1 21-Apr-2020  martin Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file asm.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2.26.1 02-Aug-2025  perseant Sync with HEAD
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file bswap.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 23-Sep-2019  skrll Provide PRIxBUSADDR, PRIxBUSSIZE, PRIuBUSSIZE, and PRIxBSH for all arches
to follow arm and (generic) mips.

Reviewed by christos.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.22;
New files for OR1K support
 1.1.22.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file bus_defs.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file bus_funcs.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 29-Oct-2014  dennis branches: 1.2.18;
Correct 32 and 64 bit byte swap inlines
 1.1 03-Sep-2014  matt New files for OR1K support
 1.2.18.2 03-Dec-2017  jdolecek update from HEAD
 1.2.18.1 29-Oct-2014  jdolecek file byte_swap.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file cdefs.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.5 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.4 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.3 21-Nov-2019  ad mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.
 1.2 19-Apr-2018  christos branches: 1.2.2;
s/static inline/static __inline/g for consistency.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.20;
New files for OR1K support
 1.1.20.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file cpu.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file cpu_counter.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.20;
New files for OR1K support
 1.1.20.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file db_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 24-May-2022  andvar s/dosen't/doesn't/ in copy pasted comment.
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file disklabel.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 06-Nov-2017  christos branches: 1.2.2;
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.1 03-Sep-2014  matt New files for OR1K support
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 06-Nov-2017  jdolecek file elf_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file endian.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file endian_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file fenv.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 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.1 03-Sep-2014  matt branches: 1.1.18; 1.1.58;
New files for OR1K support
 1.1.58.1 02-Aug-2025  perseant Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file float.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 29-Jan-2016  christos branches: 1.2.16;
use __register.
 1.1 03-Sep-2014  matt branches: 1.1.2;
New files for OR1K support
 1.1.2.1 19-Mar-2016  skrll Sync with HEAD
 1.2.16.2 03-Dec-2017  jdolecek update from HEAD
 1.2.16.1 29-Jan-2016  jdolecek file frame.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file ieee.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file ieeefp.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 12-Jan-2025  skrll or1k: Fix UINT32_C
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.58;
New files for OR1K support
 1.1.58.1 02-Aug-2025  perseant Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file int_const.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file int_fmtio.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file int_limits.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file int_mwgwtypes.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file int_types.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.20;
New files for OR1K support
 1.1.20.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file intr.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file kcore.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file limits.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.3 13-Feb-2022  riastradh or1k: __cpu_simple_lock membar audit.
 1.2 17-Sep-2017  christos branches: 1.2.2;
more const.
 1.1 03-Sep-2014  matt New files for OR1K support
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 17-Sep-2017  jdolecek file lock.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 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:55:59 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file math.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.5 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.4 04-Nov-2024  christos Undo previous lwp.h change.
 1.3 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.2 15-Feb-2018  kamil branches: 1.2.40;
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.1 03-Sep-2014  matt branches: 1.1.12; 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file mcontext.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1.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.1.12.2 26-Feb-2018  snj revert ticket 552, which broke the build
 1.1.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.2.40.1 02-Aug-2025  perseant Sync with HEAD
 1.5 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.4 09-Jul-2023  riastradh machine/mutex.h: Sprinkle includes so this can be used by crash(8).

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

Per thread:
https://mail-index.netbsd.org/tech-kern/2021/07/25/msg027562.html
 1.2 29-Nov-2019  riastradh Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.
 1.1 03-Sep-2014  matt branches: 1.1.18; 1.1.22;
New files for OR1K support
 1.1.22.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file mutex.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.3.4.1 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

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

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

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

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

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

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

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

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

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

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

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

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

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

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

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

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

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

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

ddb: Cast pointer to uintptr_t first before db_expr_t.

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

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

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

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

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

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

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

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

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

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

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

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

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

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

fix hppa and vax builds.

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

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

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

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

re-fix hppa builds.

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

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

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

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

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

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

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

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

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

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

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

Note that fls32 is 1-based and returns 0 for x=0.
 1.3 14-Oct-2022  skrll NKMEMPAGES_{MIN,MAX}_DEFAULT should be in pages.
 1.2 07-Jan-2019  jdolecek 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.1 03-Sep-2014  matt branches: 1.1.18; 1.1.20; 1.1.22;
New files for OR1K support
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 18-Jan-2019  pgoyette Synch with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file param.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file pcb.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file pmap.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 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 03-Sep-2014  matt branches: 1.1.18; 1.1.20; 1.1.22;
New files for OR1K support
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file pmc.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file proc.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file profile.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file psl.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file pte.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.3 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.2 15-Sep-2015  christos branches: 1.2.16; 1.2.20;
Provide access to pc/sp/syscall-return registers like we have for mcontext
 1.1 03-Sep-2014  matt branches: 1.1.2;
New files for OR1K support
 1.1.2.1 22-Sep-2015  skrll Sync with HEAD
 1.2.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.16.2 03-Dec-2017  jdolecek update from HEAD
 1.2.16.1 15-Sep-2015  jdolecek file ptrace.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file reg.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.2 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.1 03-Sep-2014  matt branches: 1.1.18; 1.1.22;
New files for OR1K support
 1.1.22.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file rwlock.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file setjmp.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file signal.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file spr.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file sysarch.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file trap.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.7 01-Apr-2021  simonb Whitespace: #define<tab>
 1.6 23-Jan-2021  christos branches: 1.6.2;
Document via __HAVE_BUS_SPACE_8 platforms that implement bus_space_*_8
 1.5 12-Jul-2018  maxv branches: 1.5.12;
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.4 23-Jan-2016  christos branches: 1.4.16; 1.4.18; 1.4.20;
expose the kernel types for standalone code.
 1.3 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.2 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.1 03-Sep-2014  matt branches: 1.1.2;
New files for OR1K support
 1.1.2.2 19-Mar-2016  skrll Sync with HEAD
 1.1.2.1 22-Sep-2015  skrll Sync with HEAD
 1.4.20.1 10-Jun-2019  christos Sync with HEAD
 1.4.18.1 28-Jul-2018  pgoyette Sync with HEAD
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 23-Jan-2016  jdolecek file types.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.5.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file vmparam.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000
 1.1 03-Sep-2014  matt branches: 1.1.18;
New files for OR1K support
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Sep-2014  jdolecek file wchar_limits.h was added on branch tls-maxphys on 2017-12-03 11:36:34 +0000

RSS XML Feed