Home | History | Annotate | only in /src/sys/arch/usermode
History log of /src/sys/arch/usermode
RevisionDateAuthorComments
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Import work-in-progress NetBSD/usermode port.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file Makefile was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2008-01-21 09:39:42 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file Makefile was added on branch matt-armv6 on 2008-01-09 01:49:17 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file Makefile was added on branch bouyer-xeni386 on 2008-01-02 21:50:39 +0000
 1.25 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.24 15-Dec-2011  jmcneill USERCONF works but it isn't very useful, so remove it
 1.23 15-Dec-2011  jmcneill add ptyfs/pty
 1.22 13-Dec-2011  reinoud Bump KVM size and add inet6 to surpress warnings from say postfix
 1.21 13-Dec-2011  reinoud Diable DEBUG_EXEC to remove the spam :)
 1.20 27-Nov-2011  reinoud branches: 1.20.2;
Add some config settings as default and make a note that DDB is far from
working yet :-/
 1.19 16-Sep-2011  reinoud branches: 1.19.2;
Reduce the size of the memory base of the testmachine even more!
 1.18 16-Sep-2011  reinoud Reduce the amount of memory needed to run by default
 1.17 15-Sep-2011  reinoud Adjust default parameters
 1.16 14-Sep-2011  reinoud Implement in-place execution for binaries! No more MKPIE/MKPIC for userland
anymore!
 1.15 31-Aug-2011  reinoud Completely redo R/M emulation and fault handling taking UVM as authorative
answer and not relying on UVM's pmap directions since UVM has its own schemes
for COW etc.
 1.14 27-Aug-2011  jmcneill add options DEBUG_EXEC and LOCKDEBUG
 1.13 24-Aug-2011  jmcneill add procfs support
 1.12 23-Aug-2011  jmcneill pull in GENERIC.local if it exists
 1.11 22-Aug-2011  reinoud Change standard settings in sys/arch/usermode/conf/GENERIC so to get a better
debugging environment.
 1.10 21-Aug-2011  reinoud Move NKMEMPAGES from GENERIC to std.usermode and clarify the meaning of
MEMSIZE in the GENERIC kernel.
 1.9 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.8 11-Aug-2011  jmcneill initialize lwp0 l_addr so we can switch back to it
 1.7 11-Aug-2011  jmcneill get this linking and running (sorta) again:

soundwave$ ./netbsd
NetBSD/usermode startup
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

NetBSD 5.99.55 (GENERIC) #10: Thu Aug 11 14:24:03 EDT 2011
jmcneill@soundwave:/home/jmcneill/branches/HEAD/src/sys/arch/usermode/compile/GENERIC
total memory = 128 MB
avail memory = 124 MB
mainbus0 (root)
cpu0 at mainbus0
clock0 at mainbus0
ttycons0 at mainbus0: console
panic: setcontext failed: 14
rebooting...
Abort (core dumped)
 1.6 10-Aug-2011  jmcneill fix build
 1.5 23-Nov-2010  hannken Remove unused count from pseudo-device md.
 1.4 06-Feb-2009  jym branches: 1.4.6;
Changes to MEMORY_RBFLAGS option:
- renamed to MEMORY_DISK_RBFLAGS to better fit the rest of the
MEMORY_DISK options(4)
- change default value to RB_AUTOBOOT instead of RB_SINGLE, and adapt
the config(5) files accordingly
- document this option inside options(4)

See also http://mail-index.netbsd.org/tech-kern/2008/12/25/msg003924.html

Reviewed by abs@ in private mail.
 1.3 10-Aug-2008  tls branches: 1.3.2;
Add accept filters to GENERIC kernels where they exist.
 1.2 25-May-2008  agc branches: 1.2.4;
Re-enable INCLUDE_CONFIG_FILE in the GENERIC kernel config files for
i386, amd64 and usermode - it is necessary for retrieving information
on kernel configuration for running kernels - cf config -x.
 1.1 29-Dec-2007  jmcneill 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;
Import work-in-progress NetBSD/usermode port.
 1.1.20.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.20.1 24-Jun-2008  wrstuden Hand-merge files that didn't merge right in recent sync w/ current.
 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.2 28-Sep-2008  mjf 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 29-Dec-2007  mjf file GENERIC was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file GENERIC was added on branch yamt-lazymbuf on 2008-01-21 09:39:43 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file GENERIC was added on branch matt-armv6 on 2008-01-09 01:49:18 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file GENERIC was added on branch bouyer-xeni386 on 2008-01-02 21:50:39 +0000
 1.2.4.1 19-Oct-2008  haad Sync with HEAD.
 1.3.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.4.6.1 05-Mar-2011  rmind sync with head
 1.19.2.1 17-Apr-2012  yamt sync with head
 1.20.2.1 18-Feb-2012  mrg merge to -current.
 1.4 30-Jun-2012  reinoud Move i386 and amd64 usermode configurations to their respective directories
and make the usermode kernels buildalbe under build.sh.

The resulting kernels are build and packaged correctly as are the associated
modules.
 1.3 15-Jan-2012  jmcneill branches: 1.3.4; 1.3.6;
Add options INSECURE, as sysinst requires it. Now I can boot an x86 install
CD image.
 1.2 07-Jan-2012  reinoud Move target/${USERMODE_CPU} to target/${MACHINE_CPU} to more clearly
distinguish between CPU specific ones and machine specific ones.
 1.1 06-Jan-2012  reinoud Split machdep.c into a MI part and a MD part.
 1.3.6.3 30-Oct-2012  yamt sync with head
 1.3.6.2 17-Apr-2012  yamt sync with head
 1.3.6.1 15-Jan-2012  yamt file GENERIC.amd64 was added on branch yamt-pagecache on 2012-04-17 00:06:58 +0000
 1.3.4.2 18-Feb-2012  mrg merge to -current.
 1.3.4.1 15-Jan-2012  mrg file GENERIC.amd64 was added on branch jmcneill-usbmp on 2012-02-18 07:33:22 +0000
 1.30 09-Feb-2023  abs Adjust _all_ cinclude of *.local files

- Ensure always at end
- Use tab rather than spaces
- Add consistent comment
"Pull in optional local configuration - always at end"

The only functional change is that a local file which tried to
override an existing setting (eg with "no foo") would have failed
in some cases before, but now will work
 1.29 20-Jan-2021  nia remove compat_ossaudio from kernel modules

this is only useful with compat_linux and gets autoloaded when
compat_linux is loaded, so there's no reason to bake it into kernels
any more.
 1.28 05-Jun-2018  reinoud branches: 1.28.14;
Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.27 13-Jan-2018  reinoud branches: 1.27.2;
Make NetBSD/usermode link again!
 1.26 14-Sep-2017  mrg clean up COMPAT_* options for native netbsd code:
- new series of files that are useful for saying "i want everything
since netbsd 1.4", etc.
- use the fact COMPAT_* options have future dependancies to remove
many redundant options.

removes about 3000 lines total across kernel configuration files.
tested about 30 random kernels in the changed list.
 1.25 19-Feb-2017  rin PR kern/51208
Add DISKLABEL_EI option (and also FFS_EI if missing), commented out except for
ALL on amd64 and i386.
 1.24 13-Dec-2016  christos branches: 1.24.2;
wildcard speaker attachments, now that we can handle many of them.
 1.23 10-Dec-2016  christos remove VAUDIOSPEAKER for now, will be done differently.
 1.22 08-Dec-2016  nat Add a synthesized pc beeper and keyboard bell for platforms with an audio
device.
 1.21 17-Aug-2014  joerg branches: 1.21.2; 1.21.4;
Reorganize symbol table embedding. The existing option SYMTAB_SPACE is
replaced by the make option COPY_SYMTAB set to any value. The copy of
the symbol table is no longer put into a buffer in kern_ksyms.o, but a
small helper object. This object is build first with a dummy size, then
the kernel is linked to compute the real dimension of the symbol table
buffer. After that, the helper object is rebuild and the kernel linked
again.
 1.20 16-Aug-2014  apb Add "options COMPAT_70" to all kernel configuration files that
already had "options COMPAT_60".
 1.19 17-Oct-2012  apb Add "options COMPAT_60" to all kernel configuration files
that already had "options COMPAT_50".
 1.18 17-Aug-2012  abs branches: 1.18.2;
Ensure all WSDISPLAY_COMPAT_USL entries have same comment
 1.17 23-Jan-2012  reinoud branches: 1.17.4; 1.17.6;
No need to explicitly use thunkbus at this place. thunkbus == mainbus on
NetBSD/usermode
 1.16 15-Jan-2012  jmcneill add cd9660
 1.15 09-Jan-2012  agc also add union file system
 1.14 08-Jan-2012  agc enable nullfs in usermode configs
 1.13 07-Jan-2012  reinoud Boost symtab space for amd64
 1.12 07-Jan-2012  jmcneill support multiple disk images (pass multiple disk=<path> parameters on the
command-line). while changing command-line params, rename tap= option to
net=
 1.11 04-Jan-2012  jmcneill add options NTP & pseudo-device clockctl
 1.10 02-Jan-2012  reinoud Add UDF, NILFS and NFS to the standard file systems and boost the symbol table
size to accomodate for this.
 1.9 30-Dec-2011  jmcneill add wsmouse support
 1.8 30-Dec-2011  jmcneill add WSDISPLAY_COMPAT_USL to make 'wsconscfg -s' work
 1.7 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.6 27-Dec-2011  jmcneill add ksyms support
 1.5 27-Dec-2011  jmcneill add COMPAT_OSSAUDIO
 1.4 26-Dec-2011  jmcneill add drvctl
 1.3 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.2 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.1 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.17.6.3 30-Oct-2012  yamt sync with head
 1.17.6.2 17-Apr-2012  yamt sync with head
 1.17.6.1 23-Jan-2012  yamt file GENERIC.common was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.17.4.2 18-Feb-2012  mrg merge to -current.
 1.17.4.1 23-Jan-2012  mrg file GENERIC.common was added on branch jmcneill-usbmp on 2012-02-18 07:33:22 +0000
 1.18.2.2 03-Dec-2017  jdolecek update from HEAD
 1.18.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.21.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.21.2.2 28-Aug-2017  skrll Sync with HEAD
 1.21.2.1 05-Feb-2017  skrll Sync with HEAD
 1.24.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.27.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.28.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 30-Jun-2012  reinoud Move i386 and amd64 usermode configurations to their respective directories
and make the usermode kernels buildalbe under build.sh.

The resulting kernels are build and packaged correctly as are the associated
modules.
 1.5 15-Jan-2012  jmcneill branches: 1.5.4; 1.5.6;
Add options INSECURE, as sysinst requires it. Now I can boot an x86 install
CD image.
 1.4 07-Jan-2012  reinoud Move target/${USERMODE_CPU} to target/${MACHINE_CPU} to more clearly
distinguish between CPU specific ones and machine specific ones.
 1.3 06-Jan-2012  reinoud Split machdep.c into a MI part and a MD part.
 1.2 03-Jan-2012  reinoud Rework NetBSD/usermode pmap fixing some oddities that were left over from
earlier times when we were forced to run PIE executables and were forced to
use a KVM above the kernel.
 1.1 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.5.6.3 30-Oct-2012  yamt sync with head
 1.5.6.2 17-Apr-2012  yamt sync with head
 1.5.6.1 15-Jan-2012  yamt file GENERIC.i386 was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.5.4.2 18-Feb-2012  mrg merge to -current.
 1.5.4.1 15-Jan-2012  mrg file GENERIC.i386 was added on branch jmcneill-usbmp on 2012-02-18 07:33:22 +0000
 1.3 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.2 12-Aug-2011  jmcneill branches: 1.2.2; 1.2.6;
Make GENERIC32 build on amd64
 1.1 29-Dec-2007  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add GENERIC32 configuration file for 32 bit architectures. This
configuration includes GENERIC but disables EXEC_ELF64.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file GENERIC32 was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file GENERIC32 was added on branch yamt-lazymbuf on 2008-01-21 09:39:43 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file GENERIC32 was added on branch matt-armv6 on 2008-01-09 01:49:18 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file GENERIC32 was added on branch bouyer-xeni386 on 2008-01-02 21:50:40 +0000
 1.2.6.1 18-Feb-2012  mrg merge to -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.44 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.43 17-Aug-2018  reinoud Start using the kernel ld script.

There are still issues with the .init placement and ./build.sh creating bad
images.
 1.42 01-Jun-2018  reinoud branches: 1.42.2;
Compile NetBSD/userland without CTF for the linker doesn't allow for a single
file compiled without CTF
 1.41 13-Jan-2018  reinoud branches: 1.41.2;
Make NetBSD/usermode link again!
 1.40 10-Dec-2017  christos - Allow multiple .BEGIN targets
- Make their protection consistent
 1.39 27-Aug-2015  uebayasi Tweak previous.
 1.38 27-Aug-2015  uebayasi Echo exact objects (swap*.o etc.) when linking kernel.
 1.37 24-Aug-2015  uebayasi Define ${LINKSCRIPT} in one place.
 1.36 18-Aug-2015  uebayasi ${KERN_LDSCRIPT} -> ${KERNLDSCRIPT}
 1.35 15-Nov-2014  uebayasi branches: 1.35.2;
Use LINKSCRIPT.
 1.34 10-Nov-2013  jmcneill use MACHINE_CPU instead of uname -p; create symlink for arm headers
 1.33 06-Mar-2013  yamt branches: 1.33.6;
fix include dir
add some dependencies
 1.32 30-Jun-2012  reinoud branches: 1.32.2;
Move i386 and amd64 usermode configurations to their respective directories
and make the usermode kernels buildalbe under build.sh.

The resulting kernels are build and packaged correctly as are the associated
modules.
 1.31 07-Jan-2012  reinoud Move target/${USERMODE_CPU} to target/${MACHINE_CPU} to more clearly
distinguish between CPU specific ones and machine specific ones.
 1.30 07-Jan-2012  reinoud Add AMD64 target for NetBSD/usermode next to i386 and reorganize source tree
to have port specific stuff in arch/usermode/target/<port>/
 1.29 06-Jan-2012  reinoud Split machdep.c into a MI part and a MD part.
 1.28 05-Jan-2012  jmcneill Get rid of MAP_NOSYSCALLS usage; now this relies on a separate kmod that
you can get here: http://www.netbsd.org/~jmcneill/syscallemu.tar
 1.27 31-Dec-2011  christos pass ${COPTS} to the build of thunk.c so that it builds on amd64.
 1.26 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.25 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.24 16-Sep-2011  jmcneill branches: 1.24.2; 1.24.6;
push TEXTADDR option into kernel makefile
 1.23 16-Sep-2011  reinoud Reduce the amount of memory needed to run by default
 1.22 15-Sep-2011  reinoud Adjust default parameters
 1.21 14-Sep-2011  reinoud Implement in-place execution for binaries! No more MKPIE/MKPIC for userland
anymore!
 1.20 08-Sep-2011  jmcneill pass debug compiler parameters to modules built with host sdk
 1.19 03-Sep-2011  jmcneill unbreak build on netbsd
 1.18 03-Sep-2011  jmcneill Let NetBSD/usermode build & link on a Linux host:
- Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar & atomic_ops
- Don't use MAP_* and PROT_* with thunk API since the kernel and host
might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
- Add thunk_posix_memalign
- allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
- Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
THUNK_MAP_SHARED
- mkstemp on Linux requires exactly 6 "X" characters at the end of the
template string, so add an X
 1.17 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.16 03-Sep-2011  jmcneill Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.15 28-Aug-2011  jmcneill override thunk.d and thunk_sdl.d targets
 1.14 25-Aug-2011  jmcneill - build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.13 22-Aug-2011  jmcneill build fixes for netbsd-5 and i386
 1.12 22-Aug-2011  reinoud Don't override -O options... we might want to build with another -O setting in
the config file.
 1.11 21-Aug-2011  reinoud Link the usermode kernel staticly to avoid libc littering the virtual space.
 1.10 13-Aug-2011  jmcneill try to use aio_read/aio_write instead of pread/pwrite
 1.9 12-Aug-2011  jmcneill Make GENERIC32 build on amd64
 1.8 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.7 11-Aug-2011  jmcneill Instead of trying to override vers.o target, set NVFLAGS=-n
 1.6 11-Aug-2011  jmcneill get this linking and running (sorta) again:

soundwave$ ./netbsd
NetBSD/usermode startup
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

NetBSD 5.99.55 (GENERIC) #10: Thu Aug 11 14:24:03 EDT 2011
jmcneill@soundwave:/home/jmcneill/branches/HEAD/src/sys/arch/usermode/compile/GENERIC
total memory = 128 MB
avail memory = 124 MB
mainbus0 (root)
cpu0 at mainbus0
clock0 at mainbus0
ttycons0 at mainbus0: console
panic: setcontext failed: 14
rebooting...
Abort (core dumped)
 1.5 10-Aug-2011  jmcneill fix build
 1.4 21-Jan-2011  joerg Switch remaining platforms to modern CPP for assembler.
 1.3 29-Dec-2007  jmcneill branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8; 1.3.40; 1.3.46; 1.3.48;
-Dfree=kernfree, to match -Dmalloc=kernmalloc
 1.2 29-Dec-2007  jmcneill Define init_main's main away to kernmain, and provide our own MD main entry
point. We do this since we don't have a proper bootloader, so we can
instead parse boot arguments here.

$ ./netbsd -h
-h: unknown flag
usage: ./netbsd [-acdqsvx]
(ex. "./netbsd -s")
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.3.48.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.46.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.40.1 05-Mar-2011  rmind sync with head
 1.3.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.3.8.1 29-Dec-2007  mjf file Makefile.usermode was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.3.6.2 21-Jan-2008  yamt sync with head
 1.3.6.1 29-Dec-2007  yamt file Makefile.usermode was added on branch yamt-lazymbuf on 2008-01-21 09:39:43 +0000
 1.3.4.2 09-Jan-2008  matt sync with HEAD
 1.3.4.1 29-Dec-2007  matt file Makefile.usermode was added on branch matt-armv6 on 2008-01-09 01:49:18 +0000
 1.3.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.2.1 29-Dec-2007  bouyer file Makefile.usermode was added on branch bouyer-xeni386 on 2008-01-02 21:50:40 +0000
 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.32.2.3 03-Dec-2017  jdolecek update from HEAD
 1.32.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.2.1 23-Jun-2013  tls resync from head
 1.33.6.1 18-May-2014  rmind sync with head
 1.35.2.1 22-Sep-2015  skrll Sync with HEAD
 1.41.2.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.41.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.41.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.42.2.1 10-Jun-2019  christos Sync with HEAD
 1.22 24-Apr-2021  thorpej 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.21 21-Oct-2020  christos branches: 1.21.4;
make process_machdep.c included always since it provides register i/o used by
sys_process_getlwpstatus.c which is always included.
 1.20 20-Oct-2020  christos harmonize process_machdep.c inclusion.
 1.19 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.18 01-Aug-2018  reinoud branches: 1.18.2;
Add preliminary KGDB support for NetBSD/usermode, currently only under amd64
 1.17 05-Jun-2018  reinoud branches: 1.17.2;
Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.16 30-Dec-2011  jmcneill branches: 1.16.46;
add wsmouse support
 1.15 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.14 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.13 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.12 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.11 16-Sep-2011  jmcneill branches: 1.11.2; 1.11.6;
push TEXTADDR option into kernel makefile
 1.10 04-Sep-2011  jmcneill implement splraise/spllower
 1.9 03-Sep-2011  jmcneill Let NetBSD/usermode build & link on a Linux host:
- Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar & atomic_ops
- Don't use MAP_* and PROT_* with thunk API since the kernel and host
might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
- Add thunk_posix_memalign
- allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
- Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
THUNK_MAP_SHARED
- mkstemp on Linux requires exactly 6 "X" characters at the end of the
template string, so add an X
 1.8 03-Sep-2011  jmcneill Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.7 27-Aug-2011  jmcneill defflag CPU_DEBUG
 1.6 25-Aug-2011  jmcneill - build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.5 24-Aug-2011  jmcneill add procfs support
 1.4 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.3 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.2 25-Jan-2008  joerg branches: 1.2.2; 1.2.34; 1.2.44;
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.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6;
Import work-in-progress NetBSD/usermode port.
 1.1.6.3 04-Feb-2008  yamt sync with head.
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file files.usermode was added on branch yamt-lazymbuf on 2008-01-21 09:39:43 +0000
 1.1.4.3 23-Mar-2008  matt sync with HEAD
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file files.usermode was added on branch matt-armv6 on 2008-01-09 01:49:19 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file files.usermode was added on branch bouyer-xeni386 on 2008-01-02 21:50:41 +0000
 1.2.44.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.34.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.2.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.2.1 25-Jan-2008  mjf file files.usermode was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.11.6.1 18-Feb-2012  mrg merge to -current.
 1.11.2.1 17-Apr-2012  yamt sync with head
 1.16.46.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.16.46.1 25-Jun-2018  pgoyette Sync with HEAD
 1.17.2.1 10-Jun-2019  christos Sync with HEAD
 1.18.2.1 05-May-2019  isaki Remove obsoleted au{,rate,vol}conv and mulaw attributes.
audio provides the equivalent of them inseparably.
 1.21.4.1 23-Mar-2021  thorpej Remove unneeded interface attributes from vatapi.
 1.2 17-Aug-2018  reinoud Start using the kernel ld script.

There are still issues with the .init placement and ./build.sh creating bad
images.
 1.1 18-May-2018  reinoud branches: 1.1.2; 1.1.4;
Where did kern.ldscript go?
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.2.2 21-May-2018  pgoyette Sync with HEAD
 1.1.2.1 18-May-2018  pgoyette file kern.ldscript was added on branch pgoyette-compat on 2018-05-21 04:36:02 +0000
 1.5 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.4 11-Dec-2011  jmcneill make ttycons a proper tty device, now it can be the console
 1.3 25-Aug-2011  jmcneill branches: 1.3.2; 1.3.6;
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.2 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Import work-in-progress NetBSD/usermode port.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file majors.usermode was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file majors.usermode was added on branch yamt-lazymbuf on 2008-01-21 09:39:44 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file majors.usermode was added on branch matt-armv6 on 2008-01-09 01:49:19 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file majors.usermode was added on branch bouyer-xeni386 on 2008-01-02 21:50:41 +0000
 1.3.6.1 18-Feb-2012  mrg merge to -current.
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.11 04-Jan-2012  reinoud Revert HZ to 100 what it was
 1.10 03-Jan-2012  reinoud Rework NetBSD/usermode pmap fixing some oddities that were left over from
earlier times when we were forced to run PIE executables and were forced to
use a KVM above the kernel.
 1.9 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.8 13-Dec-2011  reinoud Update kmempages; how does this relate to kvmspace though?
 1.7 27-Nov-2011  reinoud branches: 1.7.2;
Compile in syscall name table so urkel debugging code can print out the names
of the system calls so its more clear where it strands.`
 1.6 03-Sep-2011  jmcneill branches: 1.6.2;
Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.5 22-Aug-2011  reinoud Bump NKMEMPAGES from 512 to 2048 for NetBSD/usermode. This will be sufficient
for a 128 MB amd64 machine. Might better be parameterized one day.
 1.4 21-Aug-2011  reinoud Move NKMEMPAGES from GENERIC to std.usermode and clarify the meaning of
MEMSIZE in the GENERIC kernel.
 1.3 29-Dec-2007  reinoud branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
define opt constants away for i386
 1.2 29-Dec-2007  reinoud *** empty log message ***
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.3.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.3.8.1 29-Dec-2007  mjf file std.usermode was added on branch mjf-devfs on 2008-02-18 21:05:11 +0000
 1.3.6.2 21-Jan-2008  yamt sync with head
 1.3.6.1 29-Dec-2007  yamt file std.usermode was added on branch yamt-lazymbuf on 2008-01-21 09:39:44 +0000
 1.3.4.2 09-Jan-2008  matt sync with HEAD
 1.3.4.1 29-Dec-2007  matt file std.usermode was added on branch matt-armv6 on 2008-01-09 01:49:19 +0000
 1.3.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.2.1 29-Dec-2007  bouyer file std.usermode was added on branch bouyer-xeni386 on 2008-01-02 21:50:42 +0000
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.7.2.1 18-Feb-2012  mrg merge to -current.
 1.27 29-May-2020  rin For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.26 21-Jan-2012  reinoud Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.25 14-Jan-2012  reinoud Revert back to IPL_SOFTCLOCK so its lower than IPL_SHED
 1.24 14-Jan-2012  reinoud Cleanup clock.c removing unneeded function
 1.23 15-Dec-2011  jmcneill Improve usermode timecounter. It's unreasonable to assume that we'll get
100 "SIGALRM" per second with an ITIMER_REAL at 100Hz on a HZ=100 host as
the timer may expire before a pending signal has been delivered.

Instead of setitimer, use timer_create + timer_settime and from our
intr handler use timer_getoverrun to determine how many ticks we have
missed.
 1.22 13-Dec-2011  jmcneill fix timecounter
 1.21 09-Dec-2011  reinoud Restructure dev/clock to run from the signal stack since its safe to do now.
 1.20 17-Sep-2011  reinoud branches: 1.20.2; 1.20.6;
Transform the clock signal to a sigaction so we have the info i.e. the
context! and thus a good definition for a clockframe!
 1.19 16-Sep-2011  reinoud Like the others, let the clock signal restart calls
 1.18 13-Sep-2011  reinoud Forgot the clock
 1.17 12-Sep-2011  reinoud Move the clock device and the ld device to the new spl interrupt PIC
 1.16 08-Sep-2011  jmcneill get rid of clock softintr and move setitimer call to cpu_initclocks
 1.15 08-Sep-2011  jmcneill use HZ to calculate interval for setitimer
 1.14 05-Sep-2011  reinoud Check SIGALRM handler setup success or failure
 1.13 05-Sep-2011  jmcneill use sigaltstack
 1.12 23-Aug-2011  jmcneill call hardclock from a softint instead of signal handler
 1.11 23-Aug-2011  jmcneill more time_t fixes
 1.10 23-Aug-2011  jmcneill more host vs. userkernel time_t fixes
 1.9 23-Aug-2011  jmcneill host and userkernel timespec might differ in size (because of time_t) so
instead of thunk_clock_getres() filling in a timespec, use instead
thunk_clock_getres_monotonic() that returns the resolution as a long
 1.8 13-Aug-2011  jmcneill - replace the gettimeofday timecounter with one based on CLOCK_MONOTONIC
- use gettimeofday for TODR clock
 1.7 13-Aug-2011  jmcneill - initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.6 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.5 10-Aug-2011  jmcneill fix build
 1.4 27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.3 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.2 07-Jan-2008  joerg branches: 1.2.2; 1.2.4; 1.2.6; 1.2.16;
Use gettimeofday as timecounter.
 1.1 29-Dec-2007  jmcneill branches: 1.1.2;
Import work-in-progress NetBSD/usermode port.
 1.1.2.3 08-Jan-2008  bouyer Sync with HEAD
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file clock.c was added on branch bouyer-xeni386 on 2008-01-02 21:50:42 +0000
 1.2.16.1 11-Mar-2010  yamt sync with head
 1.2.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.6.1 07-Jan-2008  mjf file clock.c was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.2.4.2 21-Jan-2008  yamt sync with head
 1.2.4.1 07-Jan-2008  yamt file clock.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:44 +0000
 1.2.2.2 09-Jan-2008  matt sync with HEAD
 1.2.2.1 07-Jan-2008  matt file clock.c was added on branch matt-armv6 on 2008-01-09 01:49:19 +0000
 1.20.6.1 18-Feb-2012  mrg merge to -current.
 1.20.2.1 17-Apr-2012  yamt sync with head
 1.84 04-Oct-2023  ad Eliminate l->l_ncsw and l->l_nivcsw. From memory think they were added
before we had per-LWP struct rusage; the same is now tracked there.
 1.83 03-Dec-2019  riastradh Use __insn_barrier to enforce ordering in l_ncsw loops.

(Only need ordering observable by interruption, not by other CPUs.)
 1.82 01-Dec-2019  ad Make cpu_intr_p() safe to use anywhere, i.e. outside assertions:

Don't call kpreempt_disable() / kpreempt_enable() to make sure we're not
preempted while using the value of curcpu(). Instead, observe the value of
l_ncsw before and after the check to see if we have been preempted. If
we have been preempted, then we need to retry the read.
 1.81 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.80 01-Jun-2018  reinoud branches: 1.80.2;
Pass the address of the array, this fixes issues with i386 compilation
 1.79 29-May-2018  reinoud Only report the things we've passed in the mcontext and leave out flags that
are not reported in the mcontext anyway!
 1.78 29-May-2018  reinoud Implement cpu_lwp_setprivate(). This removes the need for the cpu_switch()
hack.

Programs with TLS work fine now, including gdb!
 1.77 29-May-2018  reinoud Only set requested parts of the mcontext in cpu_setmcontext()
Make the atomic switcher `atomic' by using splhigh()
 1.76 24-May-2018  reinoud First try at TLS support and getcontext/setcontext/swapcontext support.
 1.75 17-May-2018  reinoud Refactor for easier debugging and while here add some more signals
 1.74 01-Jun-2017  chs branches: 1.74.8;
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.73 24-Mar-2014  christos branches: 1.73.6;
use cpu_{g,s}etmodel
 1.72 29-Jul-2012  mlelstv branches: 1.72.2; 1.72.4;
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.71 25-Jun-2012  reinoud Implement dummy `cpu_mcontext_validate' to make it compile again. This
function needs to be implemented in the target secton one day for extra
security.
 1.70 03-Mar-2012  reinoud Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.69 21-Jan-2012  reinoud branches: 1.69.2;
Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.68 18-Jan-2012  reinoud Create an atomic switchto() that has SIGALRM and SIGIO signals blocked that
might otherwise disrupt the setting of curlwp to match the lwp context.
 1.67 15-Jan-2012  jmcneill sync disks and unmount at shutdown, and run shutdownhooks + pmf shutdown
handlers
 1.66 15-Jan-2012  jmcneill allow specifing the root device with 'root=ldN' parameter
 1.65 14-Jan-2012  reinoud Reimplement userret() to also include AST for preemption.

Note it would be nice if we could do the check "are we going to userland?" in
a less intrusive way.
 1.64 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.63 12-Jan-2012  reinoud Remove old comment about space not being freed; it is now done correctly so
remove it to avoid confusion later.
 1.62 06-Jan-2012  reinoud Cleanup stack allocation and freeing. This means the memory leak on lwp
destruction ought to be solved.
 1.61 04-Jan-2012  reinoud No reason why to have a larger pagefault stackframe for lwp0
 1.60 04-Jan-2012  reinoud Zero the memory we claim for the stacks
 1.59 03-Jan-2012  reinoud Use M_WAITOK instead of M_NOWAIT for the stack allocations
 1.58 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.57 27-Dec-2011  reinoud Implement physio() for NetBSD/usermode the right way!
 1.56 24-Dec-2011  reinoud Implement cpu_getmcontext() and cpu_setmcontext()
 1.55 15-Dec-2011  jmcneill Improve usermode timecounter. It's unreasonable to assume that we'll get
100 "SIGALRM" per second with an ITIMER_REAL at 100Hz on a HZ=100 host as
the timer may expire before a pending signal has been delivered.

Instead of setitimer, use timer_create + timer_settime and from our
intr handler use timer_getoverrun to determine how many ticks we have
missed.
 1.54 15-Dec-2011  jmcneill allocate msgbuf with kmem_zalloc instead of thunk_malloc, now dmesg works
 1.53 15-Dec-2011  jmcneill implement cpu idle via sigsuspend
 1.52 14-Dec-2011  jmcneill only need to setup altstack after fork, not in lwp tramp
 1.51 14-Dec-2011  jmcneill need to sigaltstack for each lwp
 1.50 13-Dec-2011  reinoud Just in case ease up the stack space a bit more
 1.49 12-Dec-2011  reinoud No need for such big stack spaces on lwp_fork() with the new setup.
 1.48 11-Dec-2011  reinoud Free the systemcall and pagefault stacks on lwp destroy.

XXX what about the main ucps stackspace that is used for the trampoline?
 1.47 27-Nov-2011  reinoud branches: 1.47.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.46 14-Sep-2011  reinoud branches: 1.46.2;
Make stacksize of newly spawn lwp's bigger than one page. Actually use the
variable stack_size now
 1.45 10-Sep-2011  reinoud Make cpu_lwp_trampo only jump once and make successive jumps go to the func
only
 1.44 09-Sep-2011  reinoud Make the trampoline only jump once!
All next calls are directed directly to the func specified.
 1.43 09-Sep-2011  reinoud Use the new thunk_makecontext() scheme with function and upto 3 aguments
 1.42 09-Sep-2011  reinoud Streamline makecontext() calls to really only specify the number of arguments
to prevent side-effects
 1.41 09-Sep-2011  reinoud Clean up cpu_trampoline and link the context so we dont have to manually do
that.
 1.40 08-Sep-2011  reinoud Use the machdep.h and now use the md_check_syscall_opcode()
 1.39 08-Sep-2011  reinoud Link syscall to userland so on exit is automatically goes to userland.
 1.38 08-Sep-2011  reinoud Cleanup syscall context creation
 1.37 08-Sep-2011  jmcneill get rid of clock softintr and move setitimer call to cpu_initclocks
 1.36 08-Sep-2011  reinoud White space
 1.35 08-Sep-2011  reinoud Create a ucontext for the system call to work in; its cloned from the new
pcb's call `userland' ucontext.
 1.34 06-Sep-2011  jmcneill cpu_lwp_inkernel approach won't work, back to the drawing board
 1.33 05-Sep-2011  jmcneill Have the urkel maintain a 'cpu_lwp_inkernel' variable and read it from the
urkelvisor to determine the origin of a syscall.
 1.32 05-Sep-2011  reinoud Restore errno just before switching to the new context and NOT after it got
back again
 1.31 05-Sep-2011  reinoud Move kpreempt_enable/disable to splsched()
 1.30 05-Sep-2011  reinoud Disable kernel preemption in the critical section of cpu_switchto()
 1.29 04-Sep-2011  reinoud pcb->errno to pcb->pcb_errno
 1.28 04-Sep-2011  reinoud Try to preserve errno over traps and on context switches
 1.27 03-Sep-2011  jmcneill unbreak build on netbsd
 1.26 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.25 03-Sep-2011  reinoud Oops forgot to commit this one
 1.24 02-Sep-2011  reinoud Update trapframe and add system call switchframe
 1.23 29-Aug-2011  reinoud Dirty commit of machdep.c and cpu.c
 1.22 28-Aug-2011  jmcneill cpu_reboot: only call thunk_abort if RB_DUMP is set
 1.21 28-Aug-2011  reinoud Jump to `userland' or the other function specified in the pcb's ucontext
 1.20 28-Aug-2011  jmcneill cpu_lwp_trampoline isn't supposed to return, so drop the atexit handler
and drop a panic() at the end of the function
 1.19 27-Aug-2011  jmcneill defflag CPU_DEBUG
 1.18 27-Aug-2011  reinoud Print when the cpu_trampoline is called()
 1.17 27-Aug-2011  jmcneill CPU_DEBUG: remove printf in cpu_signotify, and print pid/lid in cpu_switchto
 1.16 24-Aug-2011  jmcneill make room for a small msgbuf
 1.15 13-Aug-2011  jmcneill lwp0pcb should be struct pcb not ucontext_t, and initialize it in cpu_startup
instead of cpu_attach
 1.14 13-Aug-2011  jmcneill no need to print copyright/version/memory info, just call banner()
 1.13 13-Aug-2011  jmcneill - initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.12 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.11 12-Aug-2011  jmcneill implement reboot using execv
 1.10 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.9 11-Aug-2011  jmcneill initialize lwp0 l_addr so we can switch back to it
 1.8 10-Aug-2011  jmcneill fix build
 1.7 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.6 27-Nov-2009  rmind branches: 1.6.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.5 21-Nov-2009  rmind Catch-up Xen and usermode with lwp_getpcb() and unbreak Xen build.
 1.4 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.3 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.2 12-Feb-2008  joerg branches: 1.2.2; 1.2.12;
Introduce device_find_by_xname and device_find_by_driver_unit to replace
alldevs iterations all over src.

Patch discussed with and improved on suggestioned from cube@.
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6;
Import work-in-progress NetBSD/usermode port.
 1.1.6.3 27-Feb-2008  yamt sync with head.
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file cpu.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:44 +0000
 1.1.4.3 23-Mar-2008  matt sync with HEAD
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file cpu.c was added on branch matt-armv6 on 2008-01-09 01:49:20 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file cpu.c was added on branch bouyer-xeni386 on 2008-01-02 21:50:43 +0000
 1.2.12.2 11-Mar-2010  yamt sync with head
 1.2.12.1 19-Aug-2009  yamt sync with head.
 1.2.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.2.1 12-Feb-2008  mjf file cpu.c was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 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.47.2.4 06-Mar-2012  mrg sync to -current
 1.47.2.3 06-Mar-2012  mrg sync to -current
 1.47.2.2 04-Mar-2012  mrg sync to latest -current.
 1.47.2.1 18-Feb-2012  mrg merge to -current.
 1.69.2.3 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.69.2.2 02-Jul-2012  jdc Pull up revision 1.71 (requested by reinoud in ticket #377).

Implement dummy `cpu_mcontext_validate' to make it compile again. This
function needs to be implemented in the target secton one day for extra
security.
 1.69.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.72.4.1 18-May-2014  rmind sync with head
 1.72.2.2 03-Dec-2017  jdolecek update from HEAD
 1.72.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.73.6.1 28-Aug-2017  skrll Sync with HEAD
 1.74.8.2 25-Jun-2018  pgoyette Sync with HEAD
 1.74.8.1 21-May-2018  pgoyette Sync with HEAD
 1.80.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.1 25-Aug-2011  jmcneill branches: 1.1.2; 1.1.6;
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.1.6.1 18-Feb-2012  mrg merge to -current.
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.16 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.15 16-Jun-2021  riastradh 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.14 05-Feb-2020  skrll branches: 1.14.10;
Adopt <net/if_stat.h>
 1.13 29-May-2019  msaitoh branches: 1.13.4;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.12 29-May-2019  msaitoh KNF. No functional change.
 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 26-Jun-2018  msaitoh branches: 1.10.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.9 23-Oct-2017  msaitoh branches: 1.9.2;
If if_initialize() failed in the attach function, free resources and return.
 1.8 15-Dec-2016  ozaki-r branches: 1.8.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.7 10-Jun-2016  ozaki-r branches: 1.7.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.6 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.5 21-Jan-2012  reinoud branches: 1.5.4; 1.5.6; 1.5.10; 1.5.28;
Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.4 15-Jan-2012  jmcneill close file descriptors at shutdown
 1.3 09-Jan-2012  reinoud Don't directly call softint_shedule() when we might be in an SPL level too
high.
 1.2 26-Dec-2011  jmcneill veth_start: copy data from mbuf into a buffer and pass that to thunk_write(),
now this driver works as expected
 1.1 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.5.28.3 05-Feb-2017  skrll Sync with HEAD
 1.5.28.2 09-Jul-2016  skrll Sync with HEAD
 1.5.28.1 19-Mar-2016  skrll Sync with HEAD
 1.5.10.1 03-Dec-2017  jdolecek update from HEAD
 1.5.6.2 17-Apr-2012  yamt sync with head
 1.5.6.1 21-Jan-2012  yamt file if_veth.c was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.5.4.2 18-Feb-2012  mrg merge to -current.
 1.5.4.1 21-Jan-2012  mrg file if_veth.c was added on branch jmcneill-usbmp on 2012-02-18 07:33:23 +0000
 1.7.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.8.1 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.9.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.9.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.10.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.2.1 10-Jun-2019  christos Sync with HEAD
 1.13.4.1 29-Feb-2020  ad Sync with head.
 1.14.10.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.34 13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.33 04-Jun-2018  reinoud branches: 1.33.38;
Its a hack, but make sure the pages are paged in
 1.32 13-Jan-2018  reinoud branches: 1.32.2;
Keep up with changes in ld(4): adding ioctl handling on the ld(4) instead of
using the old dedicated ldflush() function.
 1.31 13-Jan-2018  reinoud Add the missing strategy argument of ldattach()
 1.30 21-Jan-2012  reinoud Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.29 09-Jan-2012  reinoud Re-implement aio for ld_thunkbus. It seems to work fine though its not set by
default; define LD_USE_AIO or uncomment its setting at the top of the
sourcefile to enable it.
 1.28 09-Jan-2012  reinoud sizeof_t is allways >=0 and the check for >=0 thus allways is true and amd64
complains about this. This might explain the odd write errors that could
sometimes be reported. Those are/were probably a side effect of this.
 1.27 06-Jan-2012  reinoud Enhance debugging printfs to also report the functionname
 1.26 06-Jan-2012  jmcneill support disk images >= 2GB
 1.25 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.24 14-Dec-2011  jmcneill set ld maxxfer to MAXPHYS
 1.23 13-Dec-2011  reinoud Remove dead code. The error variable was no longer used.
 1.22 13-Dec-2011  reinoud No need for the bounce-buffer anymore since pmap bahaves like it ought to
 1.21 13-Dec-2011  jmcneill - gc old aio implementation
- set busy before scheduling softint not after
- try not to write past end of backing file
- if B_PHYS flag is set, pread/write with bounce buffer and copyout/copyin
- use the correct offset in ld_thunkbus_dump
 1.20 09-Dec-2011  reinoud Disable aio usage in thunkbus_ld since mixing ucontext_t and threads is a NONO
according to the manpage.

Why is AIO using a pthread?
 1.19 27-Nov-2011  reinoud branches: 1.19.2;
Use AIO by default
 1.18 27-Nov-2011  reinoud Fix in-code declaration of the sigaction structure.
 1.17 27-Nov-2011  reinoud Implement the choice between using AIO or not.
 1.16 16-Sep-2011  reinoud branches: 1.16.2;
Remove the blockage of SIGALRM here too
 1.15 15-Sep-2011  reinoud Check reentry to prevent double use of the aiocb structure
 1.14 13-Sep-2011  reinoud Remove excess signal stack declarations and remove the clock and ld signals
from the signal stack since they are only issued shortly.
 1.13 12-Sep-2011  reinoud Move the clock device and the ld device to the new spl interrupt PIC
 1.12 05-Sep-2011  jmcneill use sigaltstack
 1.11 05-Sep-2011  reinoud Disable SIGALRM from interfering with this signal handler
 1.10 04-Sep-2011  reinoud Space around | (style)
 1.9 03-Sep-2011  jmcneill Now that pr45327 is fixed, remove BROKEN_SIGINFO code.
 1.8 03-Sep-2011  jmcneill add a workaround for kern/45327
 1.7 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.6 25-Aug-2011  reinoud When this debug printf is enabled, please also tell WHAT address one is using
for read/write.
 1.5 23-Aug-2011  jmcneill struct stat also has time_t in it, so we can't use that in the thunk api either
 1.4 23-Aug-2011  jmcneill don't use kmem from softint context
 1.3 13-Aug-2011  jmcneill call lddone from a softint instead of the signal handler, now reading from
disk works:

ld0 at mainbus0: /home/jmcneill/test.fs (33554432)
ld0: 32768 KB, 65 cyl, 16 head, 63 sec, 512 bytes/sect x 65536 sectors
boot device: ld0
root on ld0a dumps on ld0b
root file system type: ffs
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
 1.2 13-Aug-2011  jmcneill try to use aio_read/aio_write instead of pread/pwrite
 1.1 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.16.2.1 17-Apr-2012  yamt sync with head
 1.19.2.1 18-Feb-2012  mrg merge to -current.
 1.32.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.33.38.1 02-Aug-2025  perseant Sync with HEAD
 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 05-Jun-2018  reinoud branches: 1.10.16;
Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.9 07-Jan-2012  jmcneill branches: 1.9.46;
support multiple disk images (pass multiple disk=<path> parameters on the
command-line). while changing command-line params, rename tap= option to
net=
 1.8 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.7 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.6 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.5 25-Aug-2011  jmcneill branches: 1.5.2; 1.5.6;
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.4 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.3 27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file mainbus.c was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file mainbus.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:45 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file mainbus.c was added on branch matt-armv6 on 2008-01-09 01:49:20 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file mainbus.c was added on branch bouyer-xeni386 on 2008-01-02 21:50:44 +0000
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.9.46.1 25-Jun-2018  pgoyette Sync with HEAD
 1.10.16.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.20 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.19 03-Mar-2012  reinoud branches: 1.19.2; 1.19.12;
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.18 21-Jan-2012  reinoud branches: 1.18.2;
Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.17 27-Dec-2011  jmcneill support ^Z
 1.16 26-Dec-2011  jmcneill add sigio_intr_establish so more than one driver can register a SIGIO handler
 1.15 21-Dec-2011  jmcneill move the (now 1024 byte) printing buffer off the stack
 1.14 21-Dec-2011  reinoud Increase printing buffer of ttycons from 80 to 1024 significantly increasing
console output on large dumps.
 1.13 20-Dec-2011  jmcneill check return value of write, make sure we send the whole buffer to stdout
 1.12 15-Dec-2011  jmcneill use write instead of putchar putchar putchar putchar putchar ... for console output
 1.11 12-Dec-2011  jmcneill install a SIGINT handler and use it to emulate ^C
 1.10 12-Dec-2011  jmcneill make sure to set O_ASYNC on stdin to enable ttycons "interrupts"
 1.9 12-Dec-2011  jmcneill use spl_intr from signal handler instead of calling softint_schedule directly
 1.8 11-Dec-2011  jmcneill make ttycons a proper tty device, now it can be the console
 1.7 11-Dec-2011  jmcneill make sure to set cn_dev and cn_pri in our consdev struct
 1.6 09-Dec-2011  reinoud Remove empty lines in ttycons_consinit
 1.5 28-Aug-2011  jmcneill branches: 1.5.2; 1.5.6;
turn off input echo and buffering
 1.4 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.3 27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file ttycons.c was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file ttycons.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:45 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file ttycons.c was added on branch matt-armv6 on 2008-01-09 01:49:20 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file ttycons.c was added on branch bouyer-xeni386 on 2008-01-02 21:50:44 +0000
 1.5.6.4 06-Mar-2012  mrg sync to -current
 1.5.6.3 06-Mar-2012  mrg sync to -current
 1.5.6.2 04-Mar-2012  mrg sync to latest -current.
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.18.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.19.12.1 10-Aug-2014  tls Rebase.
 1.19.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.3 24-Apr-2021  thorpej branches: 1.3.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.2 13-Jun-2018  reinoud branches: 1.2.2; 1.2.18;
Split out error reporting and make it compile without SCSIVERBOSE
 1.1 05-Jun-2018  reinoud Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.2.18.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.2.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.2.2.1 13-Jun-2018  pgoyette file vatapi.c was added on branch pgoyette-compat on 2018-06-25 07:25:46 +0000
 1.3.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.4 26-Mar-2014  christos branches: 1.4.30; 1.4.32;
fix sprintf
 1.3 15-Jan-2012  jmcneill branches: 1.3.4; 1.3.6; 1.3.10; 1.3.14;
close file descriptors at shutdown
 1.2 26-Dec-2011  jmcneill mark vaudio callout and softint handler as mpsafe
 1.1 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.3.14.1 18-May-2014  rmind sync with head
 1.3.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.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.3.6.2 17-Apr-2012  yamt sync with head
 1.3.6.1 15-Jan-2012  yamt file vaudio.c was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.3.4.2 18-Feb-2012  mrg merge to -current.
 1.3.4.1 15-Jan-2012  mrg file vaudio.c was added on branch jmcneill-usbmp on 2012-02-18 07:33:23 +0000
 1.4.32.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.4.32.2 27-Apr-2019  isaki Adapt to audio2.
 1.4.32.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.4.30.1 10-Jun-2019  christos Sync with HEAD
 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 04-Jan-2012  jmcneill branches: 1.12.4; 1.12.6; 1.12.66;
implement cngetc and cnpollc
 1.11 02-Jan-2012  jmcneill fix range check for mmap
 1.10 30-Dec-2011  jmcneill add wsmouse support
 1.9 30-Dec-2011  jmcneill add mmap support
 1.8 30-Dec-2011  jmcneill no need to poll for pending drawing ops if no client is connected
 1.7 30-Dec-2011  jmcneill add a barrier before copyrows(), and add an RRE based fillrect functino,
use it for eraserows and erasecols
 1.6 30-Dec-2011  reinoud Implement VNC's copyrect sending and let the copyrows use the new
vncfb_copyrecs()
 1.5 30-Dec-2011  jmcneill support wskbd bell
 1.4 30-Dec-2011  jmcneill use O_ASYNC + SIGIO instead of polling for input
 1.3 30-Dec-2011  jmcneill take nrows into account when calculating the update rectangle in vncfb_copyrows
 1.2 30-Dec-2011  jmcneill send framebuffer updates for cursor changes too
 1.1 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.12.66.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.12.66.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.12.6.2 17-Apr-2012  yamt sync with head
 1.12.6.1 04-Jan-2012  yamt file vncfb.c was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.12.4.2 18-Feb-2012  mrg merge to -current.
 1.12.4.1 04-Jan-2012  mrg file vncfb.c was added on branch jmcneill-usbmp on 2012-02-18 07:33:23 +0000
 1.13.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 30-Dec-2011  jmcneill branches: 1.2.4; 1.2.6;
map Fn keys, make vt switching work
 1.1 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.2.6.2 17-Apr-2012  yamt sync with head
 1.2.6.1 30-Dec-2011  yamt file vnckbdmap.c was added on branch yamt-pagecache on 2012-04-17 00:06:59 +0000
 1.2.4.2 18-Feb-2012  mrg merge to -current.
 1.2.4.1 30-Dec-2011  mrg file vnckbdmap.c was added on branch jmcneill-usbmp on 2012-02-18 07:33:23 +0000
 1.1 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.6 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.5 17-Jun-2015  martin branches: 1.5.18;
Make clock_t unsigned int everywhere.
Ok: matt@, mrg@
 1.4 10-Nov-2013  jmcneill branches: 1.4.4; 1.4.6;
support building on arm
 1.3 22-Aug-2011  jmcneill branches: 1.3.2; 1.3.12; 1.3.16;
build fixes for netbsd-5 and i386
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file ansi.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file ansi.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:45 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file ansi.h was added on branch matt-armv6 on 2008-01-09 01:49:21 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file ansi.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:45 +0000
 1.3.16.1 18-May-2014  rmind sync with head
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.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.4.6.1 22-Sep-2015  skrll Sync with HEAD
 1.4.4.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.5.18.1 10-Jun-2019  christos Sync with HEAD
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file aout_machdep.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file aout_machdep.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:46 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file aout_machdep.h was added on branch matt-armv6 on 2008-01-09 01:49:21 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file aout_machdep.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:45 +0000
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file asm.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file asm.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:46 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file asm.h was added on branch matt-armv6 on 2008-01-09 01:49:21 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file asm.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:46 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file bswap.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file bswap.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:46 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file bswap.h was added on branch matt-armv6 on 2008-01-09 01:49:21 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file bswap.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:46 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.5 23-Sep-2019  skrll Provide PRIxBUSADDR, PRIxBUSSIZE, PRIuBUSSIZE, and PRIxBSH for all arches
to follow arm and (generic) mips.

Reviewed by christos.
 1.4 25-Aug-2011  jmcneill branches: 1.4.54;
add bus_addr_t typedef
 1.3 18-Aug-2011  reinoud Fix compilation after bus space changes. They are weak linked to the defaults.
 1.2 10-Aug-2011  jmcneill fix build
 1.1 18-Jan-2011  haad branches: 1.1.4; 1.1.8;
bus.h is required for build so add some empty file for now.
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 18-Jan-2011  jruoho file bus.h was added on branch jruoho-x86intr on 2011-06-06 09:06:58 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 18-Jan-2011  rmind file bus.h was added on branch rmind-uvmplock on 2011-03-05 20:52:14 +0000
 1.4.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file byte_swap.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file byte_swap.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:46 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file byte_swap.h was added on branch matt-armv6 on 2008-01-09 01:49:21 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file byte_swap.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:47 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.7 16-May-2018  reinoud Regen usermode headers
 1.6 10-Nov-2013  jmcneill branches: 1.6.28;
support building on arm
 1.5 05-Feb-2012  reinoud branches: 1.5.6; 1.5.10;
regen
 1.4 05-Feb-2012  reinoud regen
 1.3 02-Feb-2012  reinoud Regen
 1.2 21-Oct-2009  snj branches: 1.2.12; 1.2.16;
Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file cdefs.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file cdefs.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:47 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file cdefs.h was added on branch matt-armv6 on 2008-01-09 01:49:22 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file cdefs.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:47 +0000
 1.2.16.1 18-Feb-2012  mrg merge to -current.
 1.2.12.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.12.1 17-Apr-2012  yamt sync with head
 1.5.10.1 18-May-2014  rmind sync with head
 1.5.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.28.1 21-May-2018  pgoyette Sync with HEAD
 1.13 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.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 01-Aug-2018  reinoud Add preliminary KGDB support for NetBSD/usermode, currently only under amd64
 1.10 08-Feb-2012  reinoud branches: 1.10.46; 1.10.48;
Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are
indeed valid or correct but at least it shows them without coredumping or
coredumping the kernel.
 1.9 19-Jan-2012  reinoud My fault, forgot that cpu_need_resched() is indeed already declared as a function
 1.8 19-Jan-2012  reinoud Add macro cpu_need_resched
 1.7 14-Jan-2012  reinoud Define astpending flag and the aston() setter
 1.6 13-Aug-2011  jmcneill branches: 1.6.2; 1.6.6;
- initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.5 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.4 11-Aug-2011  jmcneill initialize lwp0 l_addr so we can switch back to it
 1.3 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.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file cpu.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file cpu.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:47 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file cpu.h was added on branch matt-armv6 on 2008-01-09 01:49:22 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file cpu.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:48 +0000
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.10.48.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.48.1 10-Jun-2019  christos Sync with HEAD
 1.10.46.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1 01-Aug-2018  reinoud branches: 1.1.2; 1.1.6;
Forgot the two header files
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 01-Aug-2018  christos file cpufunc.h was added on branch phil-wifi on 2019-06-10 22:06:50 +0000
 1.1.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.2.1 01-Aug-2018  pgoyette file cpufunc.h was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.4 05-Aug-2018  reinoud Add KGDB definitions for i386
 1.3 01-Aug-2018  reinoud Add preliminary KGDB support for NetBSD/usermode, currently only under amd64
 1.2 21-Oct-2009  snj branches: 1.2.62; 1.2.64;
Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file db_machdep.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file db_machdep.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:47 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file db_machdep.h was added on branch matt-armv6 on 2008-01-09 01:49:22 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file db_machdep.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:48 +0000
 1.2.64.1 10-Jun-2019  christos Sync with HEAD
 1.2.62.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.14 16-May-2018  reinoud Regen usermode headers
 1.13 10-Nov-2013  jmcneill branches: 1.13.28;
support building on arm
 1.12 05-Feb-2012  reinoud branches: 1.12.6; 1.12.10;
regen
 1.11 05-Feb-2012  reinoud regen
 1.10 02-Feb-2012  reinoud Regen
 1.9 14-Jan-2012  reinoud Regen
 1.8 14-Jan-2012  reinoud Update automatically generated headers
 1.7 08-Jan-2012  jmcneill regen
 1.6 08-Sep-2011  jmcneill branches: 1.6.2; 1.6.6;
regen
 1.5 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.4 31-Aug-2011  jmcneill If the host doesn't define LABELUSESMBR, set it to 1
 1.3 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.2 29-Dec-2007  reinoud branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.18;
Fix enough to get i386 more-or-less compiling. The i386 needs u_long to be
an unsigned long too or uvm will complain.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.18.1 11-Mar-2010  yamt sync with head
 1.2.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.8.1 29-Dec-2007  mjf file disklabel.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 29-Dec-2007  yamt file disklabel.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:47 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 29-Dec-2007  matt file disklabel.h was added on branch matt-armv6 on 2008-01-09 01:49:22 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file disklabel.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:49 +0000
 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.12.10.1 18-May-2014  rmind sync with head
 1.12.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file elf_machdep.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file elf_machdep.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:48 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file elf_machdep.h was added on branch matt-armv6 on 2008-01-09 01:49:22 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file elf_machdep.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:49 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file endian.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file endian.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:48 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file endian.h was added on branch matt-armv6 on 2008-01-09 01:49:23 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file endian.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:50 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file endian_machdep.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file endian_machdep.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:48 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file endian_machdep.h was added on branch matt-armv6 on 2008-01-09 01:49:23 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file endian_machdep.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:50 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.1 16-May-2018  reinoud branches: 1.1.2;
Regen usermode headers
 1.1.2.2 21-May-2018  pgoyette Sync with HEAD
 1.1.2.1 16-May-2018  pgoyette file frame_regs.h was added on branch pgoyette-compat on 2018-05-21 04:36:02 +0000
 1.11 01-Aug-2018  reinoud Add preliminary KGDB support for NetBSD/usermode, currently only under amd64
 1.10 16-May-2018  reinoud branches: 1.10.2;
Add new mcontext and depends to the usermode generated headerfiles
 1.9 10-Nov-2013  jmcneill branches: 1.9.28;
support building on arm
 1.8 05-Feb-2012  reinoud branches: 1.8.6; 1.8.10;
With the recent kmem changes, remove the `unlimited' maximum setting of
NKMEMPAGES from amd64 since it gets us into trouble.
 1.7 04-Feb-2012  reinoud Bump UPAGES effectively bumping per-process (system) stack i.e. the stack on
which traps are taken. When it was 8 it could run out of space on big NFS
stack traces in combination with timer and memory paging.
 1.6 02-Feb-2012  reinoud Add cdefs.h to usermode's genheaders.sh
 1.5 14-Jan-2012  reinoud Bump UPAGES with one more to allow for AST processing. Somehow the space was a
bit tight OR i am checking too regorously on stack space needed.
 1.4 14-Jan-2012  reinoud Update automatically generated headers
 1.3 08-Jan-2012  jmcneill disklabel.h: handle __HAVE_OLD_DISKLABEL. while here, I noticed someone changed param.h without updating genheaders.h, so catch up.
 1.2 08-Sep-2011  jmcneill branches: 1.2.2; 1.2.6;
make sure USPACE is large enough to hold our struct pcb
 1.1 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2.6.1 18-Feb-2012  mrg merge to -current.
 1.2.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.2.2.1 17-Apr-2012  yamt sync with head
 1.8.10.1 18-May-2014  rmind sync with head
 1.8.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.28.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.9.28.1 21-May-2018  pgoyette Sync with HEAD
 1.10.2.1 10-Jun-2019  christos Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file int_const.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file int_const.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:48 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file int_const.h was added on branch matt-armv6 on 2008-01-09 01:49:23 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file int_const.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:50 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file int_fmtio.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file int_fmtio.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:49 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file int_fmtio.h was added on branch matt-armv6 on 2008-01-09 01:49:23 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file int_fmtio.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:51 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file int_limits.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file int_limits.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:49 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file int_limits.h was added on branch matt-armv6 on 2008-01-09 01:49:24 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file int_limits.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:51 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file int_mwgwtypes.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file int_mwgwtypes.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:49 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file int_mwgwtypes.h was added on branch matt-armv6 on 2008-01-09 01:49:24 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file int_mwgwtypes.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:52 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file int_types.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file int_types.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:49 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file int_types.h was added on branch matt-armv6 on 2008-01-09 01:49:24 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file int_types.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:52 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.9 03-Mar-2012  reinoud Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.8 02-Feb-2012  reinoud branches: 1.8.2;
spl_intr() is not defined anymore so remove from the header file
 1.7 21-Jan-2012  reinoud Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.6 26-Dec-2011  jmcneill make sure the sigio signal handler runs on the alternate signal stack,
fixes random SIGILLs seen recently
 1.5 26-Dec-2011  jmcneill add sigio_intr_establish so more than one driver can register a SIGIO handler
 1.4 12-Sep-2011  reinoud branches: 1.4.2; 1.4.6;
Implement spl level based priority interrupt controller in software
 1.3 04-Sep-2011  jmcneill implement splraise/spllower
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file intr.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file intr.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:50 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file intr.h was added on branch matt-armv6 on 2008-01-09 01:49:24 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file intr.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:53 +0000
 1.4.6.4 06-Mar-2012  mrg sync to -current
 1.4.6.3 06-Mar-2012  mrg sync to -current
 1.4.6.2 04-Mar-2012  mrg sync to latest -current.
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.8.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file intrdefs.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file intrdefs.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:50 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file intrdefs.h was added on branch matt-armv6 on 2008-01-09 01:49:24 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file intrdefs.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:53 +0000
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file limits.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file limits.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:50 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file limits.h was added on branch matt-armv6 on 2008-01-09 01:49:25 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file limits.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:53 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.5 23-Oct-2017  msaitoh Fix compile error. Use const correctly.
 1.4 17-Sep-2017  christos more const.
 1.3 13-Aug-2011  jmcneill branches: 1.3.12;
- initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file lock.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file lock.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:51 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file lock.h was added on branch matt-armv6 on 2008-01-09 01:49:25 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file lock.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:54 +0000
 1.3.12.1 03-Dec-2017  jdolecek update from HEAD
 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:12 +0000
 1.8 14-Jan-2012  reinoud Add md_get_sp() for MI stack frame manipulation. Note that NetBSD/usermode
only works on decending stacks for now!
 1.7 03-Jan-2012  reinoud Fix logic that checks if its the kernel or a userland process that causes the
trap. Signal sending still needs to be addressed.
 1.6 14-Dec-2011  reinoud Remove the need for a siginfo structure in illegal instruction handling.
 1.5 14-Dec-2011  jmcneill need to sigaltstack for each lwp
 1.4 27-Nov-2011  reinoud branches: 1.4.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.3 09-Sep-2011  reinoud branches: 1.3.2;
machdep.c: Cleanup the machine dependent code and set the carry flag on error
out. While here also clean up register printing.

syscall.c: Add debug syscall printing code to track basic syscalls being
taken.
 1.2 08-Sep-2011  reinoud Implement a working(!) syscall! well, it can call a number of syscalls without
dying ;)
 1.1 08-Sep-2011  reinoud Add a machdep protoype header file to coder all prototypes in machdep.c
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.2.1 18-Feb-2012  mrg merge to -current.
 1.8 05-Jun-2018  reinoud Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.7 29-Dec-2011  jmcneill branches: 1.7.46;
Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.6 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.5 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.4 25-Aug-2011  jmcneill branches: 1.4.2; 1.4.6;
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.3 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file mainbus.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file mainbus.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:51 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file mainbus.h was added on branch matt-armv6 on 2008-01-09 01:49:25 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file mainbus.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:54 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.7.46.1 25-Jun-2018  pgoyette Sync with HEAD
 1.4 16-May-2018  reinoud Regen usermode headers
 1.3 13-Aug-2011  jmcneill branches: 1.3.52;
make sure mcontext is large enough to store the host mcontext; fixes
strange crashes seen in pool_init
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file mcontext.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file mcontext.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:51 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file mcontext.h was added on branch matt-armv6 on 2008-01-09 01:49:25 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file mcontext.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:55 +0000
 1.3.52.1 21-May-2018  pgoyette Sync with HEAD
 1.6 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.5 09-Jul-2023  riastradh machine/mutex.h: Sprinkle includes so this can be used by crash(8).

XXX pullup-10
 1.4 29-Nov-2019  riastradh branches: 1.4.26;
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.
 1.3 28-Apr-2008  martin branches: 1.3.88;
Remove clause 3 and 4 from TNF licenses
 1.2 29-Dec-2007  jmcneill branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.16; 1.2.18;
#ifdef _X86_foo_H -> _ARCH_USERMODE_INCLUDE_foo_H, to match the rest of
the sources.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.18.1 16-May-2008  yamt sync with head.
 1.2.16.1 18-May-2008  yamt sync with head.
 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 29-Dec-2007  mjf file mutex.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 29-Dec-2007  yamt file mutex.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:51 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 29-Dec-2007  matt file mutex.h was added on branch matt-armv6 on 2008-01-09 01:49:26 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file mutex.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:55 +0000
 1.3.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.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.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file netbsd32_machdep.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file netbsd32_machdep.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:52 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file netbsd32_machdep.h was added on branch matt-armv6 on 2008-01-09 01:49:26 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file netbsd32_machdep.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:55 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.13 16-May-2018  reinoud Regen usermode headers
 1.12 10-Nov-2013  jmcneill branches: 1.12.28;
support building on arm
 1.11 05-Feb-2012  reinoud branches: 1.11.6; 1.11.10;
regen
 1.10 05-Feb-2012  reinoud regen
 1.9 02-Feb-2012  reinoud Regen
 1.8 14-Jan-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Update automatically generated headers
 1.6 08-Jan-2012  jmcneill regen
 1.5 27-Nov-2011  reinoud branches: 1.5.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.4 08-Sep-2011  jmcneill branches: 1.4.2;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file param.h was added on branch mjf-devfs on 2008-02-18 21:05:12 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file param.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:52 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file param.h was added on branch matt-armv6 on 2008-01-09 01:49:26 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file param.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:56 +0000
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.5.2.1 18-Feb-2012  mrg merge to -current.
 1.11.10.1 18-May-2014  rmind sync with head
 1.11.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.28.1 21-May-2018  pgoyette Sync with HEAD
 1.17 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.16 06-Jan-2012  reinoud Cleanup stack allocation and freeing. This means the memory leak on lwp
destruction ought to be solved.
 1.15 03-Jan-2012  reinoud Fix logic that checks if its the kernel or a userland process that causes the
trap. Signal sending still needs to be addressed.
 1.14 12-Dec-2011  reinoud Fix typo
 1.13 27-Nov-2011  reinoud branches: 1.13.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.12 08-Sep-2011  reinoud branches: 1.12.2;
Remove not used variable from the pcb.h
 1.11 08-Sep-2011  reinoud Create a ucontext for the system call to work in; its cloned from the new
pcb's call `userland' ucontext.
 1.10 04-Sep-2011  reinoud pcb->errno to pcb->pcb_errno
 1.9 04-Sep-2011  reinoud Try to preserve errno over traps and on context switches
 1.8 02-Sep-2011  reinoud Revert
 1.7 02-Sep-2011  reinoud Update trapframe and add system call switchframe
 1.6 29-Aug-2011  reinoud Update pcb and trapframe
 1.5 28-Aug-2011  reinoud Update trapframe and pcb
 1.4 25-Aug-2011  reinoud Add trapframe and extent pcb for NetBSD/usermode; both mere dummies since
there are no traps delivered nor a process has ever been started...
 1.3 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file pcb.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file pcb.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:52 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file pcb.h was added on branch matt-armv6 on 2008-01-09 01:49:26 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file pcb.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:56 +0000
 1.12.2.1 17-Apr-2012  yamt sync with head
 1.13.2.1 18-Feb-2012  mrg merge to -current.
 1.6 01-Aug-2018  reinoud Add preliminary KGDB support for NetBSD/usermode, currently only under amd64
 1.5 24-Aug-2011  reinoud branches: 1.5.52; 1.5.54;
Remove two commented out and unused defines
 1.4 22-Aug-2011  reinoud Start NetBSD/usermode's pmap. Its using a temp file as a physical memory
backup and that should be documented in the code. A physical address is thus a
file offset(!) and a virtual address is a `normal' accesible address.

Still to do: various misc functions and pmap_extract() in special.

Credits also go to Ben Harris for his work on the Acorn26 pmap that followed
the Daemon Book recommendation for systems without real page tables on wich
this implementation is modelled after.
 1.3 18-Jan-2011  haad Bring pmap.h to new world order.
 1.2 21-Oct-2009  snj branches: 1.2.4; 1.2.6;
Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file pmap.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file pmap.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:53 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file pmap.h was added on branch matt-armv6 on 2008-01-09 01:49:27 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file pmap.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:57 +0000
 1.2.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.1 05-Mar-2011  rmind sync with head
 1.5.54.1 10-Jun-2019  christos Sync with HEAD
 1.5.52.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file proc.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file proc.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:53 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file proc.h was added on branch matt-armv6 on 2008-01-09 01:49:27 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file proc.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:58 +0000
 1.2 10-Nov-2013  jmcneill support building on arm
 1.1 13-Sep-2011  reinoud branches: 1.1.2; 1.1.12; 1.1.16;
Add missing processor status flag file i forgot to add
 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.14 16-May-2018  reinoud Regen usermode headers
 1.13 10-Nov-2013  jmcneill branches: 1.13.28;
support building on arm
 1.12 05-Feb-2012  reinoud branches: 1.12.6; 1.12.10;
regen
 1.11 05-Feb-2012  reinoud regen
 1.10 02-Feb-2012  reinoud Regen
 1.9 14-Jan-2012  reinoud Regen
 1.8 14-Jan-2012  reinoud Update automatically generated headers
 1.7 08-Jan-2012  jmcneill regen
 1.6 08-Sep-2011  jmcneill branches: 1.6.2; 1.6.6;
regen
 1.5 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.4 24-Aug-2011  jmcneill add procfs support
 1.3 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.2 29-Dec-2007  reinoud branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.18;
To make NetBSD/userland to boot on i386 choose some defaults in vmparam.h
since for i386 they are defined in page size constants wich NetBSD/userland
doesn't know yet. Also undefine ptrace's __HAVE_PTRACE_MACHDEP since i386
has that but NetBSD/userland not.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.18.1 11-Mar-2010  yamt sync with head
 1.2.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.8.1 29-Dec-2007  mjf file ptrace.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 29-Dec-2007  yamt file ptrace.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:53 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 29-Dec-2007  matt file ptrace.h was added on branch matt-armv6 on 2008-01-09 01:49:27 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file ptrace.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:58 +0000
 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.12.10.1 18-May-2014  rmind sync with head
 1.12.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.28.1 21-May-2018  pgoyette Sync with HEAD
 1.4 18-May-2018  reinoud Implement own process register capture from userland.

NetBSD/usermode now creates readable and sensible coredumps
 1.3 13-Jan-2018  reinoud branches: 1.3.2;
Add dbreg structure prototype needed for x86_64
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file reg.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file reg.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:53 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file reg.h was added on branch matt-armv6 on 2008-01-09 01:49:27 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file reg.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:59 +0000
 1.3.2.1 21-May-2018  pgoyette Sync with HEAD
 1.4 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.3 28-Apr-2008  martin branches: 1.3.88;
Remove clause 3 and 4 from TNF licenses
 1.2 29-Dec-2007  jmcneill branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.16; 1.2.18;
#ifdef _X86_foo_H -> _ARCH_USERMODE_INCLUDE_foo_H, to match the rest of
the sources.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.18.1 16-May-2008  yamt sync with head.
 1.2.16.1 18-May-2008  yamt sync with head.
 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 29-Dec-2007  mjf file rwlock.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 29-Dec-2007  yamt file rwlock.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:54 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 29-Dec-2007  matt file rwlock.h was added on branch matt-armv6 on 2008-01-09 01:49:27 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file rwlock.h was added on branch bouyer-xeni386 on 2008-01-02 21:50:59 +0000
 1.3.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file signal.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file signal.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:54 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file signal.h was added on branch matt-armv6 on 2008-01-09 01:49:28 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file signal.h was added on branch bouyer-xeni386 on 2008-01-02 21:51:00 +0000
 1.3 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.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file stdarg.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file stdarg.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:54 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file stdarg.h was added on branch matt-armv6 on 2008-01-09 01:49:28 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file stdarg.h was added on branch bouyer-xeni386 on 2008-01-02 21:51:01 +0000
 1.67 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.66 01-Aug-2018  reinoud branches: 1.66.2;
Add headers for support functions for kgdb
 1.65 04-Jun-2018  reinoud branches: 1.65.2;
Enhance the NetBSD/usermode thunk interface
 1.64 01-Jun-2018  reinoud Pretend we already included the <types.h>
 1.63 18-May-2018  reinoud Include OUR types.h and not the machine's. A small step to allow for
crosscompilation.
 1.62 06-Feb-2015  prlw1 branches: 1.62.16;
Take procfs_machdep.c rev 1.4 one step further and adjust signature of
thunk_getcpuinfo().
 1.61 03-Mar-2012  reinoud branches: 1.61.2; 1.61.16;
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.60 21-Jan-2012  reinoud branches: 1.60.2;
Add the complement to sigemptyset(), sigfillset()!
 1.59 11-Jan-2012  reinoud Add thunk_close()
 1.58 10-Jan-2012  reinoud Add thunk_madvise() for memory access hints to the host kernel.
 1.57 06-Jan-2012  jmcneill support disk images >= 2GB
 1.56 05-Jan-2012  jmcneill Get rid of MAP_NOSYSCALLS usage; now this relies on a separate kmod that
you can get here: http://www.netbsd.org/~jmcneill/syscallemu.tar
 1.55 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.54 31-Dec-2011  christos Adjust prototypes.
 1.53 30-Dec-2011  jmcneill report rfb pointer events
 1.52 30-Dec-2011  jmcneill add a barrier before copyrows(), and add an RRE based fillrect functino,
use it for eraserows and erasecols
 1.51 30-Dec-2011  jmcneill support wskbd bell
 1.50 30-Dec-2011  reinoud Use the encoding values of the VNC spec and add a copyrect (not used yet)
 1.49 30-Dec-2011  reinoud Add RFB type flag to indicate what kind of request is waiting
 1.48 30-Dec-2011  jmcneill optimize rfb updates by allowing queueing of multiple update messages,
dropping duplicates, and transmitting them in batches
 1.47 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.46 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.45 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.44 20-Dec-2011  jmcneill on second thought, set machine and machine_arch both from the host and
override module_machine
 1.43 20-Dec-2011  jmcneill set machine_arch to that of the host
 1.42 20-Dec-2011  reinoud Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.
 1.41 15-Dec-2011  jmcneill Improve usermode timecounter. It's unreasonable to assume that we'll get
100 "SIGALRM" per second with an ITIMER_REAL at 100Hz on a HZ=100 host as
the timer may expire before a pending signal has been delivered.

Instead of setitimer, use timer_create + timer_settime and from our
intr handler use timer_getoverrun to determine how many ticks we have
missed.
 1.40 15-Dec-2011  jmcneill implement /proc/cpuinfo
 1.39 15-Dec-2011  jmcneill use write instead of putchar putchar putchar putchar putchar ... for console output
 1.38 15-Dec-2011  jmcneill implement cpu idle via sigsuspend
 1.37 12-Dec-2011  jmcneill make sure to set O_ASYNC on stdin to enable ttycons "interrupts"
 1.36 11-Dec-2011  jmcneill add thunk_pollchar
 1.35 27-Nov-2011  reinoud branches: 1.35.2;
Add thunk_sigprocmask()
 1.34 15-Sep-2011  reinoud branches: 1.34.2;
Implement a dprintf_debug() analog to aprint_debug() but printing it to stderr
using vdprintf() to bypass the kernel buffer. It is currently printing only on
the -x boot flag but might get a more specific one since its quite verbose!
 1.33 14-Sep-2011  reinoud Provide thunk fuction to return the host machine's VM_MIN_ADDRESS
 1.32 09-Sep-2011  reinoud Sanitise thunk_makecontext() allowing upto 3 random arguments
 1.31 09-Sep-2011  reinoud Streamline makecontext() calls to really only specify the number of arguments
to prevent side-effects
 1.30 05-Sep-2011  reinoud Implement thunk_sigemptyset()
 1.29 05-Sep-2011  reinoud Add thunk_sigaddset()
 1.28 04-Sep-2011  jmcneill implement splraise/spllower
 1.27 04-Sep-2011  reinoud Implement thunk_seterrno()
 1.26 04-Sep-2011  reinoud -thunk_makecontext_trapframe2go(ucontext_t *ucp, void *func, void *trapframe)
+thunk_makecontext_1(ucontext_t *ucp, void *func, void *arg)
 1.25 03-Sep-2011  jmcneill Let NetBSD/usermode build & link on a Linux host:
- Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar & atomic_ops
- Don't use MAP_* and PROT_* with thunk API since the kernel and host
might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
- Add thunk_posix_memalign
- allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
- Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
THUNK_MAP_SHARED
- mkstemp on Linux requires exactly 6 "X" characters at the end of the
template string, so add an X
 1.24 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.23 02-Sep-2011  reinoud Revert
 1.22 02-Sep-2011  reinoud -thunk_makecontext_trapframe2go(ucontext_t *ucp, void *func, void *trapframe)
+thunk_makecontext_1(ucontext_t *ucp, void (*func)(void), void *arg)

Create a more general prototype for makecontext() with one variable.
 1.21 01-Sep-2011  reinoud Implement thunk_sigaltstack() so an alternative signal stack can be used
 1.20 28-Aug-2011  jmcneill add thunk_tcgetattr and thunk_tcsetattr
 1.19 28-Aug-2011  reinoud Add thunk_makecontext_trapframe2go()
 1.18 27-Aug-2011  reinoud Add a thunk_atexit() so ucontext() ends can be dealt with as they should
 1.17 25-Aug-2011  jmcneill - build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.16 24-Aug-2011  reinoud Implement thunk_malloc() and think_free()
 1.15 23-Aug-2011  jmcneill add a wrapper for signal(3)
 1.14 23-Aug-2011  jmcneill struct stat also has time_t in it, so we can't use that in the thunk api either
 1.13 23-Aug-2011  jmcneill more time_t fixes
 1.12 23-Aug-2011  jmcneill unlink pmap backing file immediately after opening it, so we don't leave
a bunch of 128MB turds sitting around in /tmp
 1.11 23-Aug-2011  jmcneill more host vs. userkernel time_t fixes
 1.10 23-Aug-2011  jmcneill host and userkernel timespec might differ in size (because of time_t) so
instead of thunk_clock_getres() filling in a timespec, use instead
thunk_clock_getres_monotonic() that returns the resolution as a long
 1.9 22-Aug-2011  reinoud Add thunk_munmap() to NetBSD/usermode's thunk
 1.8 21-Aug-2011  reinoud Fix thunk_mkstemp() prototype and add thunk_mprotect()
 1.7 21-Aug-2011  reinoud Add mmap() reachover call in thunk for NetBSD/usermode
 1.6 20-Aug-2011  reinoud Create mkstemp() and sbrk() prototypes to NetBSD/usermode's thunk
 1.5 13-Aug-2011  jmcneill - replace the gettimeofday timecounter with one based on CLOCK_MONOTONIC
- use gettimeofday for TODR clock
 1.4 13-Aug-2011  jmcneill try to use aio_read/aio_write instead of pread/pwrite
 1.3 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.2 12-Aug-2011  jmcneill implement reboot using execv
 1.1 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.34.2.1 17-Apr-2012  yamt sync with head
 1.35.2.4 06-Mar-2012  mrg sync to -current
 1.35.2.3 06-Mar-2012  mrg sync to -current
 1.35.2.2 04-Mar-2012  mrg sync to latest -current.
 1.35.2.1 18-Feb-2012  mrg merge to -current.
 1.60.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.61.16.1 06-Apr-2015  skrll Sync with HEAD
 1.61.2.1 03-Dec-2017  jdolecek update from HEAD
 1.62.16.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.62.16.2 25-Jun-2018  pgoyette Sync with HEAD
 1.62.16.1 21-May-2018  pgoyette Sync with HEAD
 1.65.2.1 10-Jun-2019  christos Sync with HEAD
 1.66.2.1 27-Apr-2019  isaki Adapt to audio2.
 1.1 28-Jul-2018  reinoud branches: 1.1.2; 1.1.6;
Provide hand-doctored redirection of trap.h in preparation for ddb/kgdb
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 28-Jul-2018  christos file trap.h was added on branch phil-wifi on 2019-06-10 22:06:50 +0000
 1.1.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.2.1 28-Jul-2018  pgoyette file trap.h was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.17 01-Apr-2021  simonb Whitespace: #define<tab>
 1.16 10-Apr-2019  thorpej branches: 1.16.12; 1.16.14;
Make the usermode kernel compile again.
 1.15 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.14 01-Jun-2018  reinoud branches: 1.14.2;
Fix compilation errors so NetBSD/usermode compiles under ./build.sh
 1.13 29-May-2018  reinoud Implement cpu_lwp_setprivate(). This removes the need for the cpu_switch()
hack.

Programs with TLS work fine now, including gdb!
 1.12 26-Jan-2017  christos branches: 1.12.12;
provide __HAVE_COMPAT_NETBSD32 and fix multiple include protection consistently.
 1.11 23-Jan-2016  christos branches: 1.11.2; 1.11.4;
expose the kernel types for standalone code.
 1.10 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.9 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.8 08-Feb-2012  reinoud branches: 1.8.6; 1.8.24;
Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are
indeed valid or correct but at least it shows them without coredumping or
coredumping the kernel.
 1.7 08-Jan-2012  jmcneill define __HAVE_OLD_DISKLABEL on i386
 1.6 11-Dec-2009  matt branches: 1.6.12; 1.6.16;
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.5 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.4 20-Jan-2008  joerg branches: 1.4.2; 1.4.4; 1.4.14;
Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.3 07-Jan-2008  joerg branches: 1.3.2;
Use gettimeofday as timecounter.
 1.2 29-Dec-2007  reinoud branches: 1.2.2;
Fix enough to get i386 more-or-less compiling. The i386 needs u_long to be
an unsigned long too or uvm will complain.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.2.4 23-Jan-2008  bouyer Sync with HEAD.
 1.2.2.3 08-Jan-2008  bouyer Sync with HEAD
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file types.h was added on branch bouyer-xeni386 on 2008-01-02 21:51:01 +0000
 1.3.2.3 23-Mar-2008  matt sync with HEAD
 1.3.2.2 09-Jan-2008  matt sync with HEAD
 1.3.2.1 07-Jan-2008  matt file types.h was added on branch matt-armv6 on 2008-01-09 01:49:28 +0000
 1.4.14.1 11-Mar-2010  yamt sync with head
 1.4.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.4.4.1 20-Jan-2008  mjf file types.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.4.2.2 21-Jan-2008  yamt sync with head
 1.4.2.1 20-Jan-2008  yamt file types.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:54 +0000
 1.6.16.1 18-Feb-2012  mrg merge to -current.
 1.6.12.1 17-Apr-2012  yamt sync with head
 1.8.24.3 05-Feb-2017  skrll Sync with HEAD
 1.8.24.2 19-Mar-2016  skrll Sync with HEAD
 1.8.24.1 22-Sep-2015  skrll Sync with HEAD
 1.8.6.1 03-Dec-2017  jdolecek update from HEAD
 1.11.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.12.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.14.2.1 10-Jun-2019  christos Sync with HEAD
 1.16.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.16.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 05-Aug-2018  reinoud branches: 1.2.2; 1.2.6;
Add KGDB definitions for i386
 1.1 01-Aug-2018  reinoud Forgot the two header files
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 05-Aug-2018  christos file ucontext.h was added on branch phil-wifi on 2019-06-10 22:06:50 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 05-Aug-2018  pgoyette file ucontext.h was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.2 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.1 03-Sep-2011  jmcneill branches: 1.1.2; 1.1.6;
Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.1.6.1 18-Feb-2012  mrg merge to -current.
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.20 03-Aug-2018  reinoud Allow for setting kernel breakpoints in our remote kgdb
 1.19 01-Aug-2018  reinoud Revert to working state
 1.18 01-Aug-2018  reinoud Max kernel address is end of kernel
 1.17 10-Nov-2013  jmcneill branches: 1.17.28; 1.17.30;
support building on arm
 1.16 08-Feb-2012  reinoud branches: 1.16.6; 1.16.10;
Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are
indeed valid or correct but at least it shows them without coredumping or
coredumping the kernel.
 1.15 10-Jan-2012  reinoud Clarify comment about PAGER_MAP_DEFAULT_SIZE
 1.14 06-Jan-2012  reinoud Bump pager map default size since KVM is not that tight anymore
 1.13 03-Jan-2012  reinoud Rework NetBSD/usermode pmap fixing some oddities that were left over from
earlier times when we were forced to run PIE executables and were forced to
use a KVM above the kernel.
 1.12 25-Dec-2011  reinoud Fix VM_MAX_ADDRESS that is NOT the max address BUT the max userland address
Fix VM_MAX_KERNEL_ADDRESS that is the absolute max address accesable by the
kernel...
 1.11 26-Aug-2011  jmcneill branches: 1.11.2; 1.11.6;
define __USE_TOPDOWN_VM
 1.10 26-Aug-2011  reinoud Revert.
 1.9 26-Aug-2011  reinoud Add checks for architectures that need a check for VM_MIN_ADDRESS
 1.8 24-Aug-2011  reinoud Swap userland code and kvm spaces so that userland lives from VM_MIN_ADDRESS
to VM_MAXUSER_ADDRESS and KVM is above that.

Note that the userspace is surrounded by a configurable amount of
non-accessible barrier space to prevent accidental out-of-boundaries access
even when reading.
 1.7 24-Aug-2011  reinoud Fix vmparam's definitions to the new style
 1.6 24-Aug-2011  reinoud kmem_data_start is no longer needed
 1.5 22-Aug-2011  jmcneill build fixes for netbsd-5 and i386
 1.4 22-Aug-2011  reinoud Start NetBSD/usermode's pmap. Its using a temp file as a physical memory
backup and that should be documented in the code. A physical address is thus a
file offset(!) and a virtual address is a `normal' accesible address.

Still to do: various misc functions and pmap_extract() in special.

Credits also go to Ben Harris for his work on the Acorn26 pmap that followed
the Daemon Book recommendation for systems without real page tables on wich
this implementation is modelled after.
 1.3 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.2 29-Dec-2007  reinoud branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.18;
To make NetBSD/userland to boot on i386 choose some defaults in vmparam.h
since for i386 they are defined in page size constants wich NetBSD/userland
doesn't know yet. Also undefine ptrace's __HAVE_PTRACE_MACHDEP since i386
has that but NetBSD/userland not.
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.2.18.1 11-Mar-2010  yamt sync with head
 1.2.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.8.1 29-Dec-2007  mjf file vmparam.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.2.6.2 21-Jan-2008  yamt sync with head
 1.2.6.1 29-Dec-2007  yamt file vmparam.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:55 +0000
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 29-Dec-2007  matt file vmparam.h was added on branch matt-armv6 on 2008-01-09 01:49:28 +0000
 1.2.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 29-Dec-2007  bouyer file vmparam.h was added on branch bouyer-xeni386 on 2008-01-02 21:51:02 +0000
 1.11.6.1 18-Feb-2012  mrg merge to -current.
 1.11.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.11.2.1 17-Apr-2012  yamt sync with head
 1.16.10.1 18-May-2014  rmind sync with head
 1.16.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.30.1 10-Jun-2019  christos Sync with HEAD
 1.17.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.12 16-May-2018  reinoud Regen usermode headers
 1.11 10-Nov-2013  jmcneill branches: 1.11.28;
support building on arm
 1.10 05-Feb-2012  reinoud branches: 1.10.6; 1.10.10;
regen
 1.9 05-Feb-2012  reinoud regen
 1.8 02-Feb-2012  reinoud Regen
 1.7 14-Jan-2012  reinoud Regen
 1.6 14-Jan-2012  reinoud Update automatically generated headers
 1.5 08-Jan-2012  jmcneill regen
 1.4 08-Sep-2011  jmcneill branches: 1.4.2; 1.4.6;
regen
 1.3 03-Sep-2011  jmcneill Instead of doing #include </usr/include/machine/..>, use the headers
that ship with the kernel sources as #include "../../$host/include/$hdr",
and auto-generate these ugly headers with a script.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file wchar_limits.h was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file wchar_limits.h was added on branch yamt-lazymbuf on 2008-01-21 09:39:55 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file wchar_limits.h was added on branch matt-armv6 on 2008-01-09 01:49:29 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file wchar_limits.h was added on branch bouyer-xeni386 on 2008-01-02 21:51:02 +0000
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.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.4.2.1 17-Apr-2012  yamt sync with head
 1.10.10.1 18-May-2014  rmind sync with head
 1.10.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.28.1 21-May-2018  pgoyette Sync with HEAD
 1.6 17-Feb-2019  rin Set WARN=3 for sing-compare.
 1.5 10-Nov-2013  jmcneill branches: 1.5.30;
use MACHINE_CPU instead of MACHINE_ARCH
 1.4 10-Nov-2013  jmcneill arm support for syscallemu, not tested
 1.3 03-Jul-2012  christos branches: 1.3.2; 1.3.4;
no home-brewed NETBSDSRCDIR please (fix the build)
 1.2 06-Jan-2012  jmcneill branches: 1.2.4;
i386 and x86_64 versions of this code are the same, rename to syscallemu_x86.c
 1.1 05-Jan-2012  jmcneill Add 'syscallemu' module, required by usermode kernel.

This module registers a syscall that takes a user_start and user_end address.
When a process calls SYS_syscallemu, the start and end address are recorded
and the syscall installs a filter on p->p_md.md_syscall. The filter then
uses the specified start and end addresses to determine where the syscall
should be routed (either host by calling the original md_syscall function,
or process by posting SIGILL).
 1.2.4.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.3 30-Oct-2012  yamt sync with head
 1.2.4.2 17-Apr-2012  yamt sync with head
 1.2.4.1 06-Jan-2012  yamt file Makefile was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.3.4.1 18-May-2014  rmind sync with head
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.30.1 10-Jun-2019  christos Sync with HEAD
 1.1 05-Jan-2012  jmcneill branches: 1.1.4;
Add 'syscallemu' module, required by usermode kernel.

This module registers a syscall that takes a user_start and user_end address.
When a process calls SYS_syscallemu, the start and end address are recorded
and the syscall installs a filter on p->p_md.md_syscall. The filter then
uses the specified start and end addresses to determine where the syscall
should be routed (either host by calling the original md_syscall function,
or process by posting SIGILL).
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 05-Jan-2012  yamt file syscallemu.c was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.1 05-Jan-2012  jmcneill branches: 1.1.4;
Add 'syscallemu' module, required by usermode kernel.

This module registers a syscall that takes a user_start and user_end address.
When a process calls SYS_syscallemu, the start and end address are recorded
and the syscall installs a filter on p->p_md.md_syscall. The filter then
uses the specified start and end addresses to determine where the syscall
should be routed (either host by calling the original md_syscall function,
or process by posting SIGILL).
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 05-Jan-2012  yamt file syscallemu.h was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.1 10-Nov-2013  jmcneill branches: 1.1.4; 1.1.6; 1.1.10;
arm support for syscallemu, not tested
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 10-Nov-2013  tls file syscallemu_arm.c was added on branch tls-maxphys on 2014-08-20 00:03:27 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 10-Nov-2013  yamt file syscallemu_arm.c was added on branch yamt-pagecache on 2014-05-22 11:40:11 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 10-Nov-2013  rmind file syscallemu_arm.c was added on branch rmind-smpnet on 2014-05-18 17:45:28 +0000
 1.2 06-Jan-2012  jmcneill i386 and x86_64 versions of this code are the same, rename to syscallemu_x86.c
 1.1 05-Jan-2012  jmcneill Add 'syscallemu' module, required by usermode kernel.

This module registers a syscall that takes a user_start and user_end address.
When a process calls SYS_syscallemu, the start and end address are recorded
and the syscall installs a filter on p->p_md.md_syscall. The filter then
uses the specified start and end addresses to determine where the syscall
should be routed (either host by calling the original md_syscall function,
or process by posting SIGILL).
 1.1 06-Jan-2012  jmcneill branches: 1.1.4;
i386 and x86_64 versions of this code are the same, rename to syscallemu_x86.c
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 06-Jan-2012  yamt file syscallemu_x86.c was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.3 01-Jan-2022  andvar fix typos in comments, mainly basicly -> basically.
 1.2 11-Nov-2013  jmcneill branches: 1.2.4; 1.2.6; 1.2.10;
implement md_get_pc and md_set_pc
 1.1 10-Nov-2013  jmcneill usermode arm md stub
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 11-Nov-2013  tls file cpu_arm.c was added on branch tls-maxphys on 2014-08-20 00:03:27 +0000
 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 11-Nov-2013  yamt file cpu_arm.c was added on branch yamt-pagecache on 2014-05-22 11:40:11 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 11-Nov-2013  rmind file cpu_arm.c was added on branch rmind-smpnet on 2014-05-18 17:45:28 +0000
 1.8 27-Nov-2018  maxv Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.7 06-Jun-2018  maya branches: 1.7.2;
Remove duplicate ;
 1.6 22-May-2018  reinoud Include <machine/mcontext.h> now its available
 1.5 18-May-2018  reinoud Use knowledge of mcontext for i386 support
 1.4 03-Mar-2012  reinoud branches: 1.4.2; 1.4.16; 1.4.20; 1.4.28; 1.4.34; 1.4.40;
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.3 21-Jan-2012  reinoud branches: 1.3.2;
Add extra kasserts to make sure we dont derive paramters from zero ucp's
 1.2 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.1 07-Jan-2012  reinoud Add AMD64 target for NetBSD/usermode next to i386 and reorganize source tree
to have port specific stuff in arch/usermode/target/<port>/
 1.3.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.4.40.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.4.40.2 25-Jun-2018  pgoyette Sync with HEAD
 1.4.40.1 21-May-2018  pgoyette Sync with HEAD
 1.4.34.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.4.28.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.4.20.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.4.16.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.4.2.2 17-Apr-2012  yamt sync with head
 1.4.2.1 03-Mar-2012  yamt file cpu_i386.c was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.7 27-Nov-2018  maxv Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

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

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.6 06-Jun-2018  maya branches: 1.6.2;
Remove duplicate ;
 1.5 22-May-2018  reinoud Include <machine/mcontext.h> now its available
 1.4 18-May-2018  reinoud Remove outdated comment
 1.3 18-May-2018  reinoud Use knowledge about the mcontext
 1.2 14-Jan-2012  reinoud branches: 1.2.4; 1.2.24; 1.2.28; 1.2.36; 1.2.42; 1.2.48;
Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.1 07-Jan-2012  reinoud Move target/${USERMODE_CPU} to target/${MACHINE_CPU} to more clearly
distinguish between CPU specific ones and machine specific ones.
 1.2.48.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.48.2 25-Jun-2018  pgoyette Sync with HEAD
 1.2.48.1 21-May-2018  pgoyette Sync with HEAD
 1.2.42.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.2.36.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.2.28.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.2.24.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.2.4.2 17-Apr-2012  yamt sync with head
 1.2.4.1 14-Jan-2012  yamt file cpu_x86_64.c was added on branch yamt-pagecache on 2012-04-17 00:07:00 +0000
 1.6.2.1 10-Jun-2019  christos Sync with HEAD
 1.12 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.11 10-Apr-2019  thorpej Make the usermode kernel compile again.
 1.10 10-Apr-2019  msaitoh Add missing semicolon.
 1.9 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.8 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.7 14-Jan-2012  reinoud branches: 1.7.46; 1.7.48;
Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.6 09-Dec-2011  reinoud Disabled copyin/copyout debugging messages since its swamping the output on
debug output.
 1.5 27-Aug-2011  reinoud branches: 1.5.2; 1.5.6;
Fix copystring routines to NOT just copy all since not all space might be
writable. This can be fixed by implementing/importing strnlen(3) in the kernel
and/or for NetBSD/usermode to have onfaults in the copyins/copyouts.
 1.4 25-Aug-2011  reinoud Cleanup debug messages in copy.c
 1.3 24-Aug-2011  reinoud Add debug statements in copyin/copyout
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file copy.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file copy.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:55 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file copy.c was added on branch matt-armv6 on 2008-01-09 01:49:29 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file copy.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:03 +0000
 1.5.6.1 18-Feb-2012  mrg merge to -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.7.48.1 10-Jun-2019  christos Sync with HEAD
 1.7.46.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2 05-Aug-2018  reinoud branches: 1.2.2; 1.2.6;
Add KGDB definitions for i386
 1.1 01-Aug-2018  reinoud Add the kgdb meat
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 05-Aug-2018  christos file cpufunc.S was added on branch phil-wifi on 2019-06-10 22:06:51 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 05-Aug-2018  pgoyette file cpufunc.S was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.6 13-Nov-2019  maxv Switch to the new PTE naming.
 1.5 09-Mar-2019  maxv branches: 1.5.4;
Start replacing the x86 PTE bits.
 1.4 05-Aug-2018  reinoud branches: 1.4.2;
Advise to explicitly set flags +agm instead of only clearing them when set
 1.3 03-Aug-2018  reinoud Allow for setting kernel breakpoints in our remote kgdb
 1.2 01-Aug-2018  reinoud Remove yet another debug printf()
 1.1 01-Aug-2018  reinoud Add the kgdb meat
 1.4.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4.2.1 05-Aug-2018  pgoyette file db_memrw.c was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.5.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.4.2 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 09-Mar-2019  christos file db_memrw.c was added on branch phil-wifi on 2019-06-10 22:06:51 +0000
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file genassym.cf was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file genassym.cf was added on branch yamt-lazymbuf on 2008-01-21 09:39:56 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file genassym.cf was added on branch matt-armv6 on 2008-01-09 01:49:29 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file genassym.cf was added on branch bouyer-xeni386 on 2008-01-02 21:51:03 +0000
 1.15 21-Jan-2012  reinoud Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.14 09-Jan-2012  reinoud If the spl list is full also notify on the ttycons since it might otherwise
not allways be possible to print the panic correctdue due to the spl level.
 1.13 07-Jan-2012  jmcneill increase the max # of sigio handlers
 1.12 30-Dec-2011  jmcneill double SIGIO_MAX_HANDLERS
 1.11 26-Dec-2011  jmcneill make sure the sigio signal handler runs on the alternate signal stack,
fixes random SIGILLs seen recently
 1.10 26-Dec-2011  jmcneill add sigio_intr_establish so more than one driver can register a SIGIO handler
 1.9 13-Dec-2011  reinoud Disable spl_intr() spamming when debug printing is enabled.
 1.8 16-Sep-2011  reinoud branches: 1.8.2; 1.8.6;
Allthough in normal practice at most two are queued, with all the debug info
spounting outi, a lot can get queued in the first phase of kernel startup.
especially the clock.
 1.7 15-Sep-2011  reinoud Move to dprintf_debug()
 1.6 13-Sep-2011  reinoud Keep processing since we *might* have missed one during execution
 1.5 12-Sep-2011  reinoud Implement spl level based priority interrupt controller in software
 1.4 08-Sep-2011  jmcneill add heavyweight sigprocmask stuff, commented out unless INTR_USE_SIGPROCMASK
is defined
 1.3 05-Sep-2011  jmcneill remove thunk_sigblock/thunk_sigunblock calls
 1.2 05-Sep-2011  jmcneill make sure splraise doesn't lower spl, and spllower doesn't raise it
 1.1 04-Sep-2011  jmcneill implement splraise/spllower
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.5 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.4 05-Aug-2018  reinoud branches: 1.4.2; 1.4.6; 1.4.40;
Add KGDB definitions for i386
 1.3 01-Aug-2018  reinoud Fix too long line
 1.2 01-Aug-2018  reinoud Remove debugging printf()
 1.1 01-Aug-2018  reinoud Add the kgdb meat
 1.4.40.1 02-Aug-2025  perseant Sync with HEAD
 1.4.6.2 10-Jun-2019  christos Sync with HEAD
 1.4.6.1 05-Aug-2018  christos file kgdb_machdep.c was added on branch phil-wifi on 2019-06-10 22:06:51 +0000
 1.4.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4.2.1 05-Aug-2018  pgoyette file kgdb_machdep.c was added on branch pgoyette-compat on 2018-09-06 06:55:43 +0000
 1.58 01-Jan-2022  andvar fix typos in comments, mainly basicly -> basically.
 1.57 01-Aug-2018  reinoud Oops, forgot a debug printf
 1.56 11-Jun-2018  reinoud branches: 1.56.2;
Now we use timestamp info, use direct console output instead of kernel
timestamped output for usage() reporting
 1.55 05-Jun-2018  reinoud Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of
an ATAPI device. All ATAPI/SCSI commands are passed trough.

Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls
will still hug the CPU until completion. Making it asynchronous is in the
pipeline
 1.54 22-Dec-2016  cherry branches: 1.54.14;
switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.53 08-Feb-2012  reinoud branches: 1.53.6; 1.53.24; 1.53.28;
Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are
indeed valid or correct but at least it shows them without coredumping or
coredumping the kernel.
 1.52 15-Jan-2012  jmcneill don't modify command-line parameters
 1.51 15-Jan-2012  jmcneill allow specifing the root device with 'root=ldN' parameter
 1.50 07-Jan-2012  jmcneill support multiple disk images (pass multiple disk=<path> parameters on the
command-line). while changing command-line params, rename tap= option to
net=
 1.49 06-Jan-2012  reinoud Split machdep.c into a MI part and a MD part.
 1.48 03-Jan-2012  reinoud Fix logic that checks if its the kernel or a userland process that causes the
trap. Signal sending still needs to be addressed.
 1.47 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.46 27-Dec-2011  reinoud Implement physio() for NetBSD/usermode the right way!
 1.45 26-Dec-2011  jmcneill update usage message:

$ ./netbsd -h
-h: unknown flag
usage: ./netbsd [-acdqsvxz] [tap=<dev>,<eaddr>] [audio=<dev>] [<fsimg>]
(ex. "./netbsd tap=tap0,00:00:be:ef:ca:fe audio=audio0 root.fs")
 1.44 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.43 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.42 24-Dec-2011  reinoud Make signals work for NetBSD/usermode[i386] !
 1.41 20-Dec-2011  jmcneill on second thought, set machine and machine_arch both from the host and
override module_machine
 1.40 20-Dec-2011  jmcneill set machine_arch to that of the host
 1.39 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.38 20-Dec-2011  reinoud Add int $80 and sysenter opcodes to the x86 SIGILL opcode detector
 1.37 14-Dec-2011  reinoud Cleanup i386 register printing and opcode extraction
 1.36 14-Dec-2011  reinoud Remove the need for a siginfo structure in illegal instruction handling.
 1.35 13-Dec-2011  reinoud Print the signal we are supposed to deliver!
 1.34 12-Dec-2011  reinoud Fix error flag (carry) setting if its a pseudo error of EJUSTRETURN etc. Just
in case.
 1.33 27-Nov-2011  reinoud branches: 1.33.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.32 16-Sep-2011  reinoud branches: 1.32.2;
Split the two debug sections
 1.31 14-Sep-2011  reinoud Implement in-place execution for binaries! No more MKPIE/MKPIC for userland
anymore!
 1.30 12-Sep-2011  reinoud Implement spl level based priority interrupt controller in software
 1.29 09-Sep-2011  reinoud Use the new thunk_makecontext() scheme with function and upto 3 aguments
 1.28 09-Sep-2011  reinoud machdep.c: Cleanup the machine dependent code and set the carry flag on error
out. While here also clean up register printing.

syscall.c: Add debug syscall printing code to track basic syscalls being
taken.
 1.27 08-Sep-2011  reinoud Implement a working(!) syscall! well, it can call a number of syscalls without
dying ;)
 1.26 08-Sep-2011  reinoud Implement md_check_syscall_opcode() to check if the instruction at the pointer
`ptr' is indeed a syscall entry.
 1.25 07-Sep-2011  reinoud Move all i386 specific stuff in a #ifdef __i386__
 1.24 05-Sep-2011  reinoud Cleanup the exec debugging printf mess in usermode's machdep.c and make them
depend on DEBUG_EXEC
 1.23 04-Sep-2011  jmcneill implement splraise/spllower
 1.22 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.21 03-Sep-2011  jmcneill move call of urkelvisor_init to main instead of pmap_bootstrap
 1.20 01-Sep-2011  reinoud Hack register setup for __i386__. This now seems to start up the code a lot
further.
 1.19 30-Aug-2011  reinoud Hack to try to help usermode/i386 by setting the EBX register
 1.18 29-Aug-2011  reinoud Dirty commit of machdep.c and cpu.c
 1.17 28-Aug-2011  reinoud Implement redementary setregs()
 1.16 27-Aug-2011  reinoud Print when retregs() is called.
 1.15 25-Aug-2011  jmcneill - build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.14 23-Aug-2011  jmcneill more time_t fixes
 1.13 13-Aug-2011  jmcneill - initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.12 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.11 12-Aug-2011  jmcneill implement reboot using execv
 1.10 10-Aug-2011  jmcneill fix build
 1.9 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.8 10-Dec-2009  matt branches: 1.8.2;
Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.7 26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.6 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.5 02-Jul-2008  ad Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@.
 1.4 07-Jan-2008  joerg branches: 1.4.2; 1.4.4; 1.4.6; 1.4.12; 1.4.16; 1.4.18; 1.4.20;
Use gettimeofday as timecounter.
 1.3 29-Dec-2007  jmcneill branches: 1.3.2;
Add -z to usage strings.
 1.2 29-Dec-2007  jmcneill Define init_main's main away to kernmain, and provide our own MD main entry
point. We do this since we don't have a proper bootloader, so we can
instead parse boot arguments here.

$ ./netbsd -h
-h: unknown flag
usage: ./netbsd [-acdqsvx]
(ex. "./netbsd -s")
 1.1 29-Dec-2007  jmcneill Import work-in-progress NetBSD/usermode port.
 1.3.2.3 08-Jan-2008  bouyer Sync with HEAD
 1.3.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.2.1 29-Dec-2007  bouyer file machdep.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:04 +0000
 1.4.20.1 03-Jul-2008  simonb Sync with head.
 1.4.18.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.16.2 11-Mar-2010  yamt sync with head
 1.4.16.1 04-May-2009  yamt sync with head.
 1.4.12.1 02-Jul-2008  mjf Sync with HEAD.
 1.4.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.4.6.1 07-Jan-2008  mjf file machdep.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.4.4.2 21-Jan-2008  yamt sync with head
 1.4.4.1 07-Jan-2008  yamt file machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:56 +0000
 1.4.2.2 09-Jan-2008  matt sync with HEAD
 1.4.2.1 07-Jan-2008  matt file machdep.c was added on branch matt-armv6 on 2008-01-09 01:49:29 +0000
 1.8.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.2.1 17-Apr-2012  yamt sync with head
 1.33.2.1 18-Feb-2012  mrg merge to -current.
 1.53.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.53.24.1 05-Feb-2017  skrll Sync with HEAD
 1.53.6.1 03-Dec-2017  jdolecek update from HEAD
 1.54.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.54.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.56.2.1 10-Jun-2019  christos Sync with HEAD
 1.2 07-Jan-2012  reinoud Add AMD64 target for NetBSD/usermode next to i386 and reorganize source tree
to have port specific stuff in arch/usermode/target/<port>/
 1.1 06-Jan-2012  reinoud Split machdep.c into a MI part and a MD part.
 1.3 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.2 21-Oct-2009  snj branches: 1.2.4; 1.2.10;
Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.14.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.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file mem.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file mem.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:56 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file mem.c was added on branch matt-armv6 on 2008-01-09 01:49:30 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file mem.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:04 +0000
 1.2.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.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.117 20-Mar-2022  andvar fix typos in debug/panic messages: isued->issued, initialiased->initialised.
 1.116 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.115 14-Mar-2020  ad branches: 1.115.8;
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.114 16-Sep-2018  skrll interrupt has two 'r's

fix another typo while I'm here (flsah)
 1.113 05-Aug-2018  reinoud To avoid possible collisions between the NetBSD/userland kernel and possible
host kernel memory allocation schemes, allocate two dedicated pages for page
copying and page zeroing.
 1.112 03-Aug-2018  reinoud Allow for setting kernel breakpoints in our remote kgdb
 1.111 03-Aug-2018  reinoud Fix physical memory size issue. It will now happily run on more than one gb.
 1.110 01-Aug-2018  reinoud Revert to working state
 1.109 01-Aug-2018  reinoud Oops, forgot a debug printf
 1.108 01-Aug-2018  reinoud Allow the usermode pmaps to also contain the kernel itself. This is needed for
the kernel pmap.
 1.107 17-May-2018  reinoud branches: 1.107.2;
Don't dynamically allocate memory we are only going to use once; so allocate
it on the stack.

While here, also include some more sanity checks.
 1.106 07-Jul-2016  msaitoh branches: 1.106.16;
KNF. Remove extra spaces. No functional change.
 1.105 28-Jul-2012  matt branches: 1.105.2; 1.105.16;
Remove declartions of physmem
 1.104 24-Jul-2012  reinoud Adding an assert that checks for struct pmap_l2 not being bigger than
PAGE_SIZE.

While here, also add possible bug allerts of temporary mmaps that might screw
up memory.
 1.103 02-Mar-2012  reinoud Move from pool(9) to kmem_zalloc(9) for L2 page tables. A pool with PAGE_SIZE
elements is accepted but seems to panic now and then claiming it can't find
the header info.

XXX should this be PR'd?
 1.102 14-Jan-2012  reinoud branches: 1.102.2;
Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.101 10-Jan-2012  reinoud Use thunk_madvise() on the memory space hinting the kernel we are using it in
a random order and hint the kernel that we we need the memory.i

No measured effect on a memory file on tmpfs /tmp though.
 1.100 10-Jan-2012  reinoud Explicitly protect the kernel image against tampering by marking it R-X
 1.99 09-Jan-2012  reinoud As ppn is a uintptr_t, it can never be negative so the check is invalid.
 1.98 07-Jan-2012  reinoud Change prototype of logical page number in pv_lookop and pv_enter and add
diagnostic checks to check for out-of-bounds.
 1.97 05-Jan-2012  jmcneill Get rid of MAP_NOSYSCALLS usage; now this relies on a separate kmod that
you can get here: http://www.netbsd.org/~jmcneill/syscallemu.tar
 1.96 04-Jan-2012  reinoud Enhance the page_deactivate() to have less side effects. While here also make
a variable local to the debug routine that uses it.
 1.95 04-Jan-2012  reinoud don't try to unmap pv entries with munmap() that are / were already unmapped
 1.94 04-Jan-2012  reinoud This uint shouldn't be there
 1.93 04-Jan-2012  reinoud mmap ppl is always < 16 so make it an uint8_t
 1.92 03-Jan-2012  reinoud Rework NetBSD/usermode pmap fixing some oddities that were left over from
earlier times when we were forced to run PIE executables and were forced to
use a KVM above the kernel.
 1.91 03-Jan-2012  reinoud Set the total memory length to be ALL the space *before* the kernel.
 1.90 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.89 02-Jan-2012  reinoud Do release all l2 pages on destroy
 1.88 01-Jan-2012  reinoud Rewrite usermodes pmap to use indirect adressing significantly reducing pmap
memory usage. Typically a decimation. This is done using L1 and L2 mappings.
 1.87 01-Jan-2012  reinoud Fix typo in comment
 1.86 01-Jan-2012  reinoud According to the pmap manpage wired pages should not track RWM, so map them RW
 1.85 30-Dec-2011  jmcneill provide pmap_phys_address
 1.84 30-Dec-2011  reinoud Change verbose kernel printing of kernel memory layout to increasing addresses
for clarity.
 1.83 27-Dec-2011  reinoud Implement physio() for NetBSD/usermode the right way!
 1.82 25-Dec-2011  reinoud Fix VM_MAX_ADDRESS that is NOT the max address BUT the max userland address
Fix VM_MAX_KERNEL_ADDRESS that is the absolute max address accesable by the
kernel...
 1.81 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.80 20-Dec-2011  reinoud Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.
 1.79 14-Dec-2011  reinoud OK, this is a temporary patch so usermode can run on 5.1 or old 5.99's. The
workaround mentioned here is not needed on newer 5.99 since it has just been
patched.
 1.78 14-Dec-2011  jmcneill only need to setup altstack after fork, not in lwp tramp
 1.77 13-Dec-2011  reinoud Don't allow unmapping of WIRED pages!

Also on unwire, call pmap_update_page() though this propably is not needed.
 1.76 13-Dec-2011  reinoud Implement a new TLB system. This fixes the TLB issues that has been plaguing
the pmap.
 1.75 13-Dec-2011  reinoud Fix typo TBL->TLB
 1.74 27-Nov-2011  reinoud branches: 1.74.2;
Create two panics that signal inconsistent states.
 1.73 19-Sep-2011  reinoud branches: 1.73.2;
Small cleanups on memory initialisation by using munmap() instead of mapping
unaccessible anon memory that we're never going to use anyway!
 1.72 16-Sep-2011  reinoud Print out the memory information on verbose booting too, its too handy to have
around without all the goo of debug printouts
 1.71 15-Sep-2011  reinoud Re-implement pmap_zero_page() and pmap_copy_page() by using
mmap + memset/memcpy + munmap.
 1.70 15-Sep-2011  reinoud Implement pmap_copy_page()! That was missing a long time!
 1.69 15-Sep-2011  reinoud Clarify pmap_copy's function as a dummy
 1.68 15-Sep-2011  reinoud Cleanup pmap_extract(); no functional change
 1.67 15-Sep-2011  reinoud Implement pmap_unwire(); not seen it called yet though
 1.66 15-Sep-2011  reinoud Remove temporary the optimalization code of pmap_remove_all() until the
suspected pmap problems are fixed/found.
 1.65 15-Sep-2011  reinoud On entering an entry to pmap, activate the entry directly if adding to an
already active pmap.
 1.64 15-Sep-2011  reinoud Only activate pages that are in active pmaps
 1.63 15-Sep-2011  reinoud Move to dprintf_debug()
 1.62 14-Sep-2011  reinoud Code audit revealed missing brackets and a silly old constant of 1024
lingering around. Fixed with the right values.
 1.61 14-Sep-2011  reinoud Implement in-place execution for binaries! No more MKPIE/MKPIC for userland
anymore!
 1.60 13-Sep-2011  reinoud Implement pmap_protect() and pmap_remove_all()
 1.59 09-Sep-2011  reinoud Make pmap.c not so chatty unless we've enabled debug and verbose
 1.58 09-Sep-2011  reinoud Implement TBL functionality by remembering if its mapped in or not before
guessing and adjusting access types.

While here, when we hit a read-access fault and reference the page, also mark
it for executable when its permissions permit it. Distinguising between the
two is neigh impossible as we need to guess/derive the access the process
tried to have to the memory: we dont know if its a read/write/exec try.

Also clean up some debug messages.
 1.57 06-Sep-2011  reinoud Implement switch to have a sparse memory file or to fill it beforehand.
 1.56 06-Sep-2011  reinoud Remove old comment that is no longer relevant
 1.55 05-Sep-2011  reinoud Install signal handlers just after pmap_bootstrap and don't defer it
 1.54 04-Sep-2011  jmcneill if pmap_page_activate fails, print the returned and expected addresses
 1.53 03-Sep-2011  jmcneill Let NetBSD/usermode build & link on a Linux host:
- Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar & atomic_ops
- Don't use MAP_* and PROT_* with thunk API since the kernel and host
might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
- Add thunk_posix_memalign
- allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
- Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
THUNK_MAP_SHARED
- mkstemp on Linux requires exactly 6 "X" characters at the end of the
template string, so add an X
 1.52 03-Sep-2011  jmcneill move call of urkelvisor_init to main instead of pmap_bootstrap
 1.51 03-Sep-2011  jmcneill Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.50 01-Sep-2011  reinoud Oops used the wrong page flag for referenced and modified check
 1.49 31-Aug-2011  reinoud Completely redo R/M emulation and fault handling taking UVM as authorative
answer and not relying on UVM's pmap directions since UVM has its own schemes
for COW etc.
 1.48 30-Aug-2011  reinoud Implement pmap_clear_reference()
 1.47 30-Aug-2011  reinoud Implement pmap_is_referenced()
 1.46 30-Aug-2011  reinoud Cleanup PV_UNMAGED handling in pmap_do_enter
 1.45 30-Aug-2011  reinoud Make still unimplemented pmap_protect() more verbose
 1.44 30-Aug-2011  reinoud Implement pmap_page_protect()
 1.43 30-Aug-2011  reinoud Implement pmap_clear_modify() and pmap_is_modified()
 1.42 30-Aug-2011  reinoud Implement pmap_destroy() following Ben Harris's template
 1.41 30-Aug-2011  reinoud Implement pmap_reference(). Note that i have no idea as to when this reference
is released...
 1.40 30-Aug-2011  reinoud Remove panic that prevented multiple mappings of a pv entry
 1.39 29-Aug-2011  reinoud Implement read and modify detection code
 1.38 27-Aug-2011  reinoud Only return the result of pmap_extract() when the return variable is not NULL.
 1.37 26-Aug-2011  jmcneill pmap_remove_all: change panic to warning
 1.36 25-Aug-2011  reinoud Implement pmap_deactivate() and most importantly, share changes! i.e. it
should map in the SAME page and not a COW clone of the origional.
 1.35 25-Aug-2011  reinoud For all virtual to logical page translations we need to substract
VM_MIN_ADDRESS first! I forgot to add this to pmap_remove().

Now we are here, mark the lines with V->L or L->V.l
 1.34 25-Aug-2011  reinoud Implement first generation of memory access handler for the kernel.
 1.33 25-Aug-2011  reinoud Indent debug aprint_debug()'s
 1.32 24-Aug-2011  reinoud cpu_cache_flush doesn't exist yet or isn't included yet so comment it out
 1.31 24-Aug-2011  reinoud Implement pmap_activate() and pmap_deactivate()
Also add some debug messages

Note that the UVM area is still unprotected (for you Jared)
 1.30 24-Aug-2011  reinoud Swap userland code and kvm spaces so that userland lives from VM_MIN_ADDRESS
to VM_MAXUSER_ADDRESS and KVM is above that.

Note that the userspace is surrounded by a configurable amount of
non-accessible barrier space to prevent accidental out-of-boundaries access
even when reading.
 1.29 24-Aug-2011  reinoud Duh... fix stupid debug print bug.
 1.28 24-Aug-2011  reinoud Cleanup comments and debug stuff
 1.27 24-Aug-2011  reinoud Use the VM_MIN_ADDRESS `constant' for the offset calculation of virtual
address to a logical page address.
 1.26 24-Aug-2011  reinoud First pass of NetBSD/usermode's pmap.c cleanup:
* use thunk_malloc() for UVM space allocation releasing sbrk()
* make pmap.c 64 bit friendly for large page numbers
 1.25 23-Aug-2011  reinoud Give malloc(3) a barrier to allocate OVER... i.e. let the space at ease!
Note that it could use an extra barrier too.
 1.24 23-Aug-2011  jmcneill unlink pmap backing file immediately after opening it, so we don't leave
a bunch of 128MB turds sitting around in /tmp
 1.23 23-Aug-2011  reinoud Implement pmap_create()
 1.22 23-Aug-2011  reinoud Fix zero page cleaning. The supplied `pa' is a physical address and no page
number so don't multiply with PAGE_SIZE
 1.21 23-Aug-2011  reinoud Clean up chatty pmap.c and fix important bug that claimed too little kmem
space. Thanks go to jmcneill for finding it!
 1.20 23-Aug-2011  reinoud OOps... there is no aprintf_debug()
 1.19 23-Aug-2011  reinoud Braindead implementation of pmap_zero_page()
 1.18 23-Aug-2011  reinoud The pv_tables and the kernel pmap structure are not managed by UVM and thus
shouldn't be returned in pmap_virtual_space() for UVM.
 1.17 23-Aug-2011  jmcneill get rid of uvmhist stuff
 1.16 23-Aug-2011  reinoud Initial implementation of pmap_remove()

Also cleaned up some debug output to be aprint_debug()'d.
 1.15 23-Aug-2011  reinoud Implement pv_alloc() and pv_free() and add various printf's to see what
functions are called that might have side effects due to not being
implemented!
 1.14 23-Aug-2011  reinoud Cleanup pv_get() before enabling multiple-mappings
 1.13 23-Aug-2011  jmcneill pmap_enter: fix pmap_do_enter parameters
 1.12 22-Aug-2011  reinoud Dirty patch fixing the assert triggered on i386. On this arch the sbrk(0) HAS
been moved upward and will trigger the assert. When this situation is
encountered the kmem_data_end will be moved upward equaly.
 1.11 22-Aug-2011  jmcneill build fixes for netbsd-5 and i386
 1.10 22-Aug-2011  reinoud Implement pmap_extract() and print pmap_zero_page() pa address.
 1.9 22-Aug-2011  reinoud Start NetBSD/usermode's pmap. Its using a temp file as a physical memory
backup and that should be documented in the code. A physical address is thus a
file offset(!) and a virtual address is a `normal' accesible address.

Still to do: various misc functions and pmap_extract() in special.

Credits also go to Ben Harris for his work on the Acorn26 pmap that followed
the Daemon Book recommendation for systems without real page tables on wich
this implementation is modelled after.
 1.8 13-Aug-2011  jmcneill - initialize cpu_info_primary early, before cpu0 attaches
- track idepth in cpu_info struct and use it in cpu_intr_p
- for debug and diagnostic kernels, abort when rebooting
- fill in __cpu_simple_lock_* stubs
- splraise(IPL_HIGH) before calling kernmain
- pmap_extract: only return phys addr if pap is not NULL
 1.7 11-Aug-2011  jmcneill pmap_memory isn't a static array anymore so sizeof doesn't work on it
 1.6 10-Aug-2011  jmcneill fix build
 1.5 07-Nov-2009  cegger branches: 1.5.2;
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.4 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.3 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.2 21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18; 1.1.26; 1.1.32;
Import work-in-progress NetBSD/usermode port.
 1.1.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.18.2 11-Mar-2010  yamt sync with head
 1.1.18.1 04-May-2009  yamt sync with head.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file pmap.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file pmap.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:56 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file pmap.c was added on branch matt-armv6 on 2008-01-09 01:49:30 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file pmap.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:05 +0000
 1.5.2.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.73.2.2 30-Oct-2012  yamt sync with head
 1.73.2.1 17-Apr-2012  yamt sync with head
 1.74.2.4 06-Mar-2012  mrg sync to -current
 1.74.2.3 06-Mar-2012  mrg sync to -current
 1.74.2.2 04-Mar-2012  mrg sync to latest -current.
 1.74.2.1 18-Feb-2012  mrg merge to -current.
 1.102.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #78):
sys/arch/usermode/usermode/pmap.c: revision 1.103
Move from pool(9) to kmem_zalloc(9) for L2 page tables. A pool with PAGE_SIZE
elements is accepted but seems to panic now and then claiming it can't find
the header info.
XXX should this be PR'd?
 1.105.16.1 09-Jul-2016  skrll Sync with HEAD
 1.105.2.1 03-Dec-2017  jdolecek update from HEAD
 1.106.16.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.106.16.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.106.16.1 21-May-2018  pgoyette Sync with HEAD
 1.107.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.2.1 10-Jun-2019  christos Sync with HEAD
 1.115.8.1 01-Aug-2021  thorpej Sync with HEAD.
 1.5 18-May-2018  reinoud Second part for creating sensible coredumps
 1.4 13-Jan-2018  reinoud branches: 1.4.2;
Implement dummy process_read_dbreg() and process_write_dbreg() used in x86
 1.3 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.2 21-Oct-2009  snj branches: 1.2.12; 1.2.22; 1.2.26;
Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file process_machdep.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file process_machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:57 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file process_machdep.c was added on branch matt-armv6 on 2008-01-09 01:49:30 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file process_machdep.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:05 +0000
 1.2.26.1 18-May-2014  rmind sync with head
 1.2.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.2.1 21-May-2018  pgoyette Sync with HEAD
 1.4 05-Apr-2014  christos adjust to new signature; return consistent stuff. 0 is ok -1 is error
 1.3 15-Dec-2011  jmcneill branches: 1.3.6; 1.3.10;
implement /proc/cpuinfo
 1.2 28-Aug-2011  jmcneill branches: 1.2.2; 1.2.6;
pull in sys/mount.h; build fix for amd64
 1.1 24-Aug-2011  jmcneill add procfs support
 1.2.6.1 18-Feb-2012  mrg merge to -current.
 1.2.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.2.2.1 17-Apr-2012  yamt sync with head
 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.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file sys_machdep.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file sys_machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:57 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file sys_machdep.c was added on branch matt-armv6 on 2008-01-09 01:49:31 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file sys_machdep.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:06 +0000
 1.27 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.26 03-Apr-2023  gutteridge usermode/syscall.c: s/fall trough/FALLTHROUGH/ (KNF)
 1.25 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.24 26-Jun-2013  matt branches: 1.24.34;
Use sy_invoke
 1.23 13-Feb-2012  reinoud branches: 1.23.6;
Add cpu_spawn_return() as per other archs to make it compile. No tests done
yet.
 1.22 14-Jan-2012  reinoud Reimplement userret() to also include AST for preemption.

Note it would be nice if we could do the check "are we going to userland?" in
a less intrusive way.
 1.21 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.20 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.19 20-Dec-2011  reinoud Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.
 1.18 15-Dec-2011  jmcneill add required trace_enter/trace_exit calls in syscall() to make ktrace work
 1.17 12-Dec-2011  reinoud Elaborate return value printing to include JUSTRETURN etc. instead of
reporting it as an error!
 1.16 12-Dec-2011  reinoud Enhance system call prints by printing out the execve() arguments
 1.15 12-Dec-2011  reinoud Return ZERO to the child on fork!
 1.14 12-Dec-2011  reinoud Print lwp values on syscall entry
 1.13 11-Dec-2011  reinoud Rework the debug printing to use functions instead of clutting the system call
code.
 1.12 09-Dec-2011  reinoud Enhance printing of system callss
 1.11 27-Nov-2011  reinoud branches: 1.11.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.10 15-Sep-2011  reinoud branches: 1.10.2;
Move to dprintf_debug() too
 1.9 09-Sep-2011  reinoud machdep.c: Cleanup the machine dependent code and set the carry flag on error
out. While here also clean up register printing.

syscall.c: Add debug syscall printing code to track basic syscalls being
taken.
 1.8 08-Sep-2011  reinoud Implement a working(!) syscall! well, it can call a number of syscalls without
dying ;)
 1.7 08-Sep-2011  reinoud Create syscall() prototype and let illegal instruction handler switch to that
switchframe
 1.6 08-Sep-2011  reinoud Create a ucontext for the system call to work in; its cloned from the new
pcb's call `userland' ucontext.
 1.5 29-Aug-2011  reinoud Update syscall prototype
 1.4 28-Aug-2011  reinoud Clean child_return()
 1.3 27-Aug-2011  reinoud Add dirty copy of child_return()
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file syscall.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file syscall.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:58 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file syscall.c was added on branch matt-armv6 on 2008-01-09 01:49:31 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file syscall.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:06 +0000
 1.10.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.11.2.1 18-Feb-2012  mrg merge to -current.
 1.23.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.34.1 10-Jun-2019  christos Sync with HEAD
 1.93 17-Mar-2024  andvar Add missing "e" in few words, in comments and one log message.
 1.92 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.91 01-Aug-2018  reinoud branches: 1.91.2;
Oops, forgot a debug printf
 1.90 04-Jun-2018  reinoud branches: 1.90.2;
Enhance the NetBSD/usermode thunk interface
 1.89 01-Jun-2018  reinoud Pretend we already included the <types.h>
 1.88 18-May-2018  reinoud Include our doctored types.h instead of the default
 1.87 21-Dec-2015  christos branches: 1.87.16;
fix label and variable name.
 1.86 21-Dec-2015  christos more checking
 1.85 06-Feb-2015  prlw1 Take procfs_machdep.c rev 1.4 one step further and adjust signature of
thunk_getcpuinfo().
 1.84 10-Nov-2013  jmcneill branches: 1.84.6;
define _KMEMUSER before including machine/vmparam.h
 1.83 22-May-2013  reinoud branches: 1.83.2;
Including missing include file <sys/ioctl.h> that broke compilation.
 1.82 02-Jul-2012  reinoud branches: 1.82.2;
Fix missing <stdarg.h> include that breaks the autobuild
 1.81 03-Mar-2012  reinoud Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.80 21-Jan-2012  reinoud branches: 1.80.2;
Add the complement to sigemptyset(), sigfillset()!
 1.79 15-Jan-2012  jmcneill if syscallemu returns -1 and sets errno = EACCES, it means it's already
enabled for this pid. don't treat this as a failure.
 1.78 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.77 11-Jan-2012  reinoud Add thunk_close()
 1.76 10-Jan-2012  reinoud Add thunk_madvise() for memory access hints to the host kernel.
 1.75 06-Jan-2012  jmcneill support disk images >= 2GB
 1.74 05-Jan-2012  jmcneill Get rid of MAP_NOSYSCALLS usage; now this relies on a separate kmod that
you can get here: http://www.netbsd.org/~jmcneill/syscallemu.tar
 1.73 04-Jan-2012  reinoud Add extra debugging info for the vncfb code
 1.72 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.71 31-Dec-2011  christos - fix syscall error returns
- fix clobbered errno
- use warn instead of perror
- use ssize_t consistently
- retry on EINTR and EAGAIN
 1.70 31-Dec-2011  reinoud Move the thunk_rfb_send_pending() up to where it belonged. It could disconnect
AND event could be NULL while it still would need to send... i.e. the barrier
in vncfbcopyrows()
 1.69 31-Dec-2011  reinoud Implement safe_recv() in analog to save_send() to make sure we don't miss
bytes along and mess up the protocol.
 1.68 30-Dec-2011  reinoud Add template code for a client driven display update request. This is
currently not possible since its event parameter is not allways passed.
 1.67 30-Dec-2011  jmcneill report rfb pointer events
 1.66 30-Dec-2011  jmcneill add a barrier before copyrows(), and add an RRE based fillrect functino,
use it for eraserows and erasecols
 1.65 30-Dec-2011  reinoud Implement VNC's copyrect sending and let the copyrows use the new
vncfb_copyrecs()
 1.64 30-Dec-2011  jmcneill support wskbd bell
 1.63 30-Dec-2011  jmcneill print key event info if RFB_DEBUG
 1.62 30-Dec-2011  reinoud Use the encoding values of the VNC spec and add a copyrect (not used yet)
 1.61 30-Dec-2011  reinoud Add RFB type flag to indicate what kind of request is waiting
 1.60 30-Dec-2011  jmcneill use O_ASYNC + SIGIO instead of polling for input
 1.59 30-Dec-2011  reinoud Rename variable Bpp to bytes_per_pixel
 1.58 30-Dec-2011  reinoud Use a wrapper around the send() to make sure it will transmit EVERYTHING and
not just a part of the data
 1.57 30-Dec-2011  jmcneill optimize rfb updates by allowing queueing of multiple update messages,
dropping duplicates, and transmitting them in batches
 1.56 29-Dec-2011  jmcneill Replace the SDL based genfb driver with a wsdisplay and wskbd driver that
implements the VNC (RFB) protocol.

To enable the VNC server, add 'vnc=640x480,5900' to the kernel command line
(where 640x480 is the desired fb resolution and 5900 is the TCP port).

Screenshot of it here: http://www.netbsd.org/~jmcneill/usermode.tiff
 1.55 27-Dec-2011  jmcneill implement thunk_signal using sigaction so we ensure all of our signal
handlers run on the alternate signal stack
 1.54 26-Dec-2011  jmcneill add vaudio(4) audio device driver
 1.53 26-Dec-2011  jmcneill don't need O_NONBLOCK for tap
 1.52 26-Dec-2011  jmcneill first cut at networking support for usermode, doesn't fully work yet but
enough to get an address with dhcp and answer arps
 1.51 20-Dec-2011  jmcneill on second thought, set machine and machine_arch both from the host and
override module_machine
 1.50 20-Dec-2011  jmcneill set machine_arch to that of the host
 1.49 20-Dec-2011  jmcneill thunk_pollchar: use read instead of getchar
 1.48 20-Dec-2011  reinoud Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.
 1.47 15-Dec-2011  jmcneill Improve usermode timecounter. It's unreasonable to assume that we'll get
100 "SIGALRM" per second with an ITIMER_REAL at 100Hz on a HZ=100 host as
the timer may expire before a pending signal has been delivered.

Instead of setitimer, use timer_create + timer_settime and from our
intr handler use timer_getoverrun to determine how many ticks we have
missed.
 1.46 15-Dec-2011  jmcneill implement /proc/cpuinfo
 1.45 15-Dec-2011  jmcneill use write instead of putchar putchar putchar putchar putchar ... for console output
 1.44 15-Dec-2011  jmcneill implement cpu idle via sigsuspend
 1.43 13-Dec-2011  jmcneill fix timecounter
 1.42 12-Dec-2011  jmcneill make sure to set O_ASYNC on stdin to enable ttycons "interrupts"
 1.41 11-Dec-2011  jmcneill add thunk_pollchar
 1.40 27-Nov-2011  reinoud branches: 1.40.2;
Add thunk_sigprocmask()
 1.39 15-Sep-2011  reinoud branches: 1.39.2;
Use vfprintf() to make it compile under 5.1 again
 1.38 15-Sep-2011  reinoud Implement a dprintf_debug() analog to aprint_debug() but printing it to stderr
using vdprintf() to bypass the kernel buffer. It is currently printing only on
the -x boot flag but might get a more specific one since its quite verbose!
 1.37 14-Sep-2011  reinoud Provide thunk fuction to return the host machine's VM_MIN_ADDRESS
 1.36 09-Sep-2011  reinoud Sanitise thunk_makecontext() allowing upto 3 random arguments
 1.35 09-Sep-2011  reinoud Streamline makecontext() calls to really only specify the number of arguments
to prevent side-effects
 1.34 05-Sep-2011  reinoud Implement thunk_sigemptyset()
 1.33 05-Sep-2011  reinoud Add thunk_sigaddset()
 1.32 04-Sep-2011  jmcneill implement splraise/spllower
 1.31 04-Sep-2011  reinoud Rename err to nerrno
 1.30 04-Sep-2011  reinoud Implement thunk_seterrno()
 1.29 04-Sep-2011  reinoud -thunk_makecontext_trapframe2go(ucontext_t *ucp, void *func, void *trapframe)
+thunk_makecontext_1(ucontext_t *ucp, void *func, void *arg)
 1.28 03-Sep-2011  jmcneill Let NetBSD/usermode build & link on a Linux host:
- Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar & atomic_ops
- Don't use MAP_* and PROT_* with thunk API since the kernel and host
might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
- Add thunk_posix_memalign
- allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
- Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
THUNK_MAP_SHARED
- mkstemp on Linux requires exactly 6 "X" characters at the end of the
template string, so add an X
 1.27 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.26 02-Sep-2011  reinoud Revert
 1.25 02-Sep-2011  reinoud -thunk_makecontext_trapframe2go(ucontext_t *ucp, void *func, void *trapframe)
+thunk_makecontext_1(ucontext_t *ucp, void (*func)(void), void *arg)

Create a more general prototype for makecontext() with one variable.
 1.24 01-Sep-2011  reinoud Implement thunk_sigaltstack() so an alternative signal stack can be used
 1.23 01-Sep-2011  reinoud Prevent thunk_mmap() to mmap a page outside the box; just as a precaution.
 1.22 28-Aug-2011  jmcneill add thunk_tcgetattr and thunk_tcsetattr
 1.21 28-Aug-2011  reinoud Add thunk_makecontext_trapframe2go()
 1.20 27-Aug-2011  reinoud Add a thunk_atexit() so ucontext() ends can be dealt with as they should
 1.19 25-Aug-2011  jmcneill - build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.18 24-Aug-2011  reinoud Implement thunk_malloc() and think_free()
 1.17 23-Aug-2011  jmcneill add a wrapper for signal(3)
 1.16 23-Aug-2011  reinoud Use write(1,..) and not putchar()
 1.15 23-Aug-2011  jmcneill struct stat also has time_t in it, so we can't use that in the thunk api either
 1.14 23-Aug-2011  jmcneill more time_t fixes
 1.13 23-Aug-2011  jmcneill unlink pmap backing file immediately after opening it, so we don't leave
a bunch of 128MB turds sitting around in /tmp
 1.12 23-Aug-2011  jmcneill more host vs. userkernel time_t fixes
 1.11 23-Aug-2011  jmcneill host and userkernel timespec might differ in size (because of time_t) so
instead of thunk_clock_getres() filling in a timespec, use instead
thunk_clock_getres_monotonic() that returns the resolution as a long
 1.10 22-Aug-2011  jmcneill build fixes for netbsd-5 and i386
 1.9 22-Aug-2011  reinoud Add thunk_munmap() to NetBSD/usermode's thunk
 1.8 21-Aug-2011  reinoud Fix thunk_mkstemp() prototype and add thunk_mprotect()
 1.7 21-Aug-2011  reinoud Add mmap() reachover call in thunk for NetBSD/usermode
 1.6 20-Aug-2011  reinoud Create mkstemp() and sbrk() prototypes to NetBSD/usermode's thunk
 1.5 13-Aug-2011  jmcneill - replace the gettimeofday timecounter with one based on CLOCK_MONOTONIC
- use gettimeofday for TODR clock
 1.4 13-Aug-2011  jmcneill try to use aio_read/aio_write instead of pread/pwrite
 1.3 12-Aug-2011  jmcneill add a simple disk driver, pass the path to the disk image on the kernel command line:

soundwave$ ./netbsd /tmp/test.fs
NetBSD/usermode startup
[...]
ld0 at mainbus0: /tmp/test.fs (33554432)
ld0: 32768 KB, 8322 cyl, 64 head, 63 sec, 1 bytes/sect x 33554432 sectors
boot device: ld0
root on ld0a dumps on ld0b
 1.2 12-Aug-2011  jmcneill implement reboot using execv
 1.1 12-Aug-2011  jmcneill Clean up extern mess by adding an API for kernel components to call libc
functions. thunk.c is built with special cflags that makes it compile
against standard system headers instead of kernel ones.
 1.39.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.39.2.2 30-Oct-2012  yamt sync with head
 1.39.2.1 17-Apr-2012  yamt sync with head
 1.40.2.4 06-Mar-2012  mrg sync to -current
 1.40.2.3 06-Mar-2012  mrg sync to -current
 1.40.2.2 04-Mar-2012  mrg sync to latest -current.
 1.40.2.1 18-Feb-2012  mrg merge to -current.
 1.80.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.82.2.3 03-Dec-2017  jdolecek update from HEAD
 1.82.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.82.2.1 23-Jun-2013  tls resync from head
 1.83.2.1 18-May-2014  rmind sync with head
 1.84.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.84.6.1 06-Apr-2015  skrll Sync with HEAD
 1.87.16.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.87.16.2 25-Jun-2018  pgoyette Sync with HEAD
 1.87.16.1 21-May-2018  pgoyette Sync with HEAD
 1.90.2.1 10-Jun-2019  christos Sync with HEAD
 1.91.2.1 27-Apr-2019  isaki Adapt to audio2.
 1.2 07-Jan-2012  reinoud Remove unused thunk_sdl.c file
 1.1 25-Aug-2011  jmcneill branches: 1.1.2; 1.1.6;
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
options SDL
genfb* at mainbus?
wsdisplay* at genfb?
options WS_KERNEL_FG=WSCOL_GREEN
options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()
 1.1.6.1 18-Feb-2012  mrg merge to -current.
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.74 28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.73 28-May-2022  andvar fix various typos, mainly in comments.
 1.72 29-Nov-2019  ad PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().
 1.71 21-Nov-2019  ad mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.
 1.70 01-Aug-2018  reinoud Oops, forgot a debug printf
 1.69 28-Jul-2018  reinoud Fix typo
 1.68 11-Jun-2018  reinoud branches: 1.68.2;
Prevent nested SIGIOs ruining the system stack
 1.67 18-May-2018  reinoud Replace the dynamically allocated signal stack to a static claimed one and add
diagnostic messages that can be enabled.
 1.66 04-Aug-2012  reinoud branches: 1.66.38;
Fix IO lockups in NetBSD/usermode.

1) Don't block IO signals since the return path is not garanteed to enable the
signal again.
2) Since signals can get dropped, do a 2nd pass over the routines.
 1.65 03-Mar-2012  reinoud Use the signal's signo instead of just returning SIGSEGV and add a comment
 1.64 03-Mar-2012  reinoud Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.63 15-Feb-2012  reinoud branches: 1.63.2;
Prevent recursive IO signals. This prevents crashes when pieces of text are
pasted in say an Xterm. Each char might create a SIGIO running out of
stackspace very quickly!
 1.62 22-Jan-2012  reinoud Fix compilation issue for target amd64.
 1.61 21-Jan-2012  reinoud Complete rewrite of the signal and spl framework for NetBSD/usermode

Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.

Preemption now works though could be enhanced a bit more
 1.60 18-Jan-2012  reinoud Another step towards unification of the signal handers: separate the printing
of details usefull for debugging / porting from the main code.
 1.59 17-Jan-2012  reinoud Do init the astpending variable.
 1.58 17-Jan-2012  reinoud Clean up userret/ast handling. Now called ONLY when its 100% clear that it is
returning to userland.
 1.57 14-Jan-2012  reinoud Reimplement userret() to also include AST for preemption.

Note it would be nice if we could do the check "are we going to userland?" in
a less intrusive way.
 1.56 14-Jan-2012  reinoud Revamp the NetBSD/usermode pagefault and illegal instruction handing. It now
can handle recursive entry and is a lot more memory tight compared to the old
implementation. Performance wise:

* slightly less number of syscalls/sec possible though could be optimized
* a lot faster context creation / destruction making overall operation faster.
 1.55 11-Jan-2012  reinoud Cleanup trap.c and add a stop_all_signal_handlers(void) i: bluntly stopping
all known usages of signal handlers, to be used in shutdown.
 1.54 07-Jan-2012  reinoud Cleanup trap debug messages
 1.53 06-Jan-2012  reinoud printf()->thunk_printf() since its for debugging and should be printed outside
the kernel's printing system.
 1.52 03-Jan-2012  reinoud Rework NetBSD/usermode pmap fixing some oddities that were left over from
earlier times when we were forced to run PIE executables and were forced to
use a KVM above the kernel.
 1.51 03-Jan-2012  reinoud Rename the debug printf's to use a thunk_ prefix to avoid confusion.
 1.50 03-Jan-2012  reinoud Fix logic that checks if its the kernel or a userland process that causes the
trap. Signal sending still needs to be addressed.
 1.49 02-Jan-2012  reinoud Remove tests that are dubious and should be (re)moved anyway.
 1.48 26-Dec-2011  jmcneill make sure the sigio signal handler runs on the alternate signal stack,
fixes random SIGILLs seen recently
 1.47 26-Dec-2011  jmcneill add sigio_intr_establish so more than one driver can register a SIGIO handler
 1.46 25-Dec-2011  reinoud Fix VM_MAX_ADDRESS that is NOT the max address BUT the max userland address
Fix VM_MAX_KERNEL_ADDRESS that is the absolute max address accesable by the
kernel...
 1.45 14-Dec-2011  reinoud Remove the need for a siginfo structure in illegal instruction handling.
 1.44 14-Dec-2011  jmcneill need to sigaltstack for each lwp
 1.43 13-Dec-2011  reinoud Remove old debugging cruft
 1.42 27-Nov-2011  reinoud branches: 1.42.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.41 16-Sep-2011  reinoud branches: 1.41.2;
Move the debug printf's to the new dprintf_debug() and disable the SIGALRM
blocking since we queue them now.
 1.40 15-Sep-2011  reinoud Move to dprintf_debug()
 1.39 10-Sep-2011  reinoud The illegal instruction handler can exist on the usermodes stack and the
stackframe will disappear when its switched back.
 1.38 09-Sep-2011  reinoud Be more verbose in trap.c on what address should be passed to userland. Also
detail about what function goes into recurse
 1.37 08-Sep-2011  reinoud Implement a working(!) syscall! well, it can call a number of syscalls without
dying ;)
 1.36 08-Sep-2011  reinoud Use the machdep.h and now use the md_check_syscall_opcode()
 1.35 08-Sep-2011  reinoud Create syscall() prototype and let illegal instruction handler switch to that
switchframe
 1.34 08-Sep-2011  reinoud Remove struct trapframe
 1.33 07-Sep-2011  reinoud Add skeleton for possible system call implementation
 1.32 07-Sep-2011  reinoud Better not copy this trapframe
 1.31 07-Sep-2011  reinoud Print the byte codes that failed

State actions to implement.
 1.30 06-Sep-2011  jmcneill cpu_lwp_inkernel approach won't work, back to the drawing board
 1.29 06-Sep-2011  reinoud Move sanity check before pmap since pmap and uvm can't be looking outside this
box
 1.28 05-Sep-2011  jmcneill adjust cpu_lwp_inkernel in mem access and illegal insn handlers
 1.27 05-Sep-2011  reinoud Check for NULL pcb!
 1.26 05-Sep-2011  reinoud Use thunk's version of sigemptyset()
 1.25 05-Sep-2011  reinoud Initialise the alternative signal stack before referring to it
 1.24 05-Sep-2011  reinoud Block SIGALRM on memory access and illegal instruction signal
 1.23 04-Sep-2011  reinoud pcb->errno to pcb->pcb_errno
 1.22 04-Sep-2011  reinoud Try to preserve errno over traps and on context switches
 1.21 04-Sep-2011  jmcneill mem_access_handler: panic if we receive sigsegv or sigbus with SI_NOINFO,
and when "peeing outside the box" print the offending va
 1.20 03-Sep-2011  reinoud Add SIGILL handler, doing nothing than printing out details.
Move the address check to be done later so pmap and uvm have their go first.

Also some minor cosmetic fixes
 1.19 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.18 02-Sep-2011  reinoud Add note on how to posibly create a signal and send it to a userland program
 1.17 02-Sep-2011  reinoud Disable the debug_fh code for now
 1.16 01-Sep-2011  reinoud Use a alternative dedicated signal stack for the sigsegv errors; the userland
stack like that of ld.elf_so can be too short to allow for such deep
stacktraces.
 1.15 01-Sep-2011  reinoud Enhance debugging capabilities of NetBSD/usermode by allowing `trap.c' to
write a system image of the memory it traps. Its extremely dirty but at least
you can look at the data and code thats giving the trouble. Its memory or
state is NOT saved in the coredump of the NetBSD/usermode program.
 1.14 31-Aug-2011  reinoud Completely redo R/M emulation and fault handling taking UVM as authorative
answer and not relying on UVM's pmap directions since UVM has its own schemes
for COW etc.
 1.13 29-Aug-2011  reinoud Implement read and modify detection code
 1.12 29-Aug-2011  jmcneill mem_access_handler: print originating lwp ptr + pid + lid
 1.11 29-Aug-2011  reinoud Hack trap for now to upgrade protection.. this really needs fixing soon
 1.10 28-Aug-2011  reinoud Don't use the content of trapframe yet until we know how to use fill it
 1.9 28-Aug-2011  jmcneill cpu_lwp_trampoline isn't supposed to return, so drop the atexit handler
and drop a panic() at the end of the function
 1.8 27-Aug-2011  reinoud Catch the atexit() so we can bypass the libc feature that if one ucontext()
ends that it then call exit()
 1.7 27-Aug-2011  reinoud Implement trap recursion detection and fix small one-off error in range
checks for kernel space
 1.6 25-Aug-2011  reinoud A trap is now allways asked for RW access... that needs to be fixed but thats
later care.
 1.5 25-Aug-2011  reinoud Check if we pee'd outside the box!
 1.4 25-Aug-2011  reinoud Update and claim copyright
 1.3 25-Aug-2011  reinoud Implement first generation of memory access handler for the kernel.
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file trap.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file trap.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:58 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file trap.c was added on branch matt-armv6 on 2008-01-09 01:49:31 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file trap.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:07 +0000
 1.41.2.2 30-Oct-2012  yamt sync with head
 1.41.2.1 17-Apr-2012  yamt sync with head
 1.42.2.4 06-Mar-2012  mrg sync to -current
 1.42.2.3 06-Mar-2012  mrg sync to -current
 1.42.2.2 04-Mar-2012  mrg sync to latest -current.
 1.42.2.1 18-Feb-2012  mrg merge to -current.
 1.63.2.3 08-Aug-2012  martin Pull up following revision(s) (requested by reinoud in ticket #463):
sys/arch/usermode/usermode/trap.c: revision 1.66
Fix IO lockups in NetBSD/usermode.
1) Don't block IO signals since the return path is not garanteed to enable the
signal again.
2) Since signals can get dropped, do a 2nd pass over the routines.
 1.63.2.2 08-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #91):
sys/arch/usermode/usermode/trap.c: revision 1.65
Use the signal's signo instead of just returning SIGSEGV and add a comment
 1.63.2.1 07-Mar-2012  riz Pull up following revision(s) (requested by reinoud in ticket #89):
sys/arch/usermode/usermode/thunk.c: revision 1.81
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.4
sys/arch/usermode/include/thunk.h: revision 1.61
sys/arch/usermode/include/intr.h: revision 1.9
sys/arch/usermode/dev/cpu.c: revision 1.70
sys/arch/usermode/dev/ttycons.c: revision 1.19
sys/arch/usermode/usermode/trap.c: revision 1.64
Implement signal forwarding to userland for usermode kernels. Especially
SIGFPE is important since the urkel shouldn't stop when a userland program
devides by zero!
 1.66.38.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.66.38.2 25-Jun-2018  pgoyette Sync with HEAD
 1.66.38.1 21-May-2018  pgoyette Sync with HEAD
 1.68.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.68.2.1 10-Jun-2019  christos Sync with HEAD
 1.10 20-Dec-2011  jmcneill get rid of urkelvisor, and use same MD majors as the host
 1.9 27-Nov-2011  reinoud branches: 1.9.2;
Big patch that changes the signal stack usage of urkel significantly.

Formerly, all signals came on the signal stack and the two important ones were
then forwared to either the system call or the pagefault handler. This worked
fine but the signal stack remains that, a stack. When we go multi-process this
stack gets corrupted and out-of-order with all kind of nastyness since a
userland process switch can occure when a system call is called or when a
process gets a page fault.

The new scheme only uses the signal stack as a jumpboard. It swaps states and
then returns from the signal, clearing the stack but instead of returning to
the code it now jumpt to the handler and that handler then returns to the code
when its finished.
 1.8 06-Sep-2011  jmcneill branches: 1.8.2;
cpu_lwp_inkernel approach won't work, back to the drawing board
 1.7 05-Sep-2011  jmcneill Have the urkel maintain a 'cpu_lwp_inkernel' variable and read it from the
urkelvisor to determine the origin of a syscall.
 1.6 05-Sep-2011  jmcneill check WIFSTOPPED status
 1.5 05-Sep-2011  jmcneill rearrange ptrace_getregs and have the child raise(SIGSTOP) instead of wait()
 1.4 05-Sep-2011  jmcneill let env URKELVISOR=0 disable it at runtime
 1.3 03-Sep-2011  jmcneill Get this compiling (but not quite linking yet) on Linux
 1.2 03-Sep-2011  jmcneill if emulating the syscall, toggle insyscall as the child won't get stopped a
second time
 1.1 03-Sep-2011  jmcneill Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.9.2.1 18-Feb-2012  mrg merge to -current.
 1.5 24-Jan-2018  skrll Remove port-acorn26

OK core@
 1.4 27-Dec-2011  reinoud Implement physio() for NetBSD/usermode the right way!
 1.3 10-Aug-2011  jmcneill branches: 1.3.2; 1.3.6;
fix build
 1.2 21-Oct-2009  snj Drop 3rd and 4th clauses. OK jmcneill (copyright holder).
 1.1 29-Dec-2007  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18;
Import work-in-progress NetBSD/usermode port.
 1.1.18.1 11-Mar-2010  yamt sync with head
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 29-Dec-2007  mjf file vm_machdep.c was added on branch mjf-devfs on 2008-02-18 21:05:13 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 29-Dec-2007  yamt file vm_machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:39:58 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 29-Dec-2007  matt file vm_machdep.c was added on branch matt-armv6 on 2008-01-09 01:49:32 +0000
 1.1.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 29-Dec-2007  bouyer file vm_machdep.c was added on branch bouyer-xeni386 on 2008-01-02 21:51:08 +0000
 1.3.6.1 18-Feb-2012  mrg merge to -current.
 1.3.2.1 17-Apr-2012  yamt sync with head

RSS XML Feed