rw_super(SUPER_GET);
- if(block_size < _MIN_BLOCK_SIZE)
+ if(block_size < SUPER_BLOCK_BYTES)
fatal("funny block size");
if(!(rwbuf = malloc(block_size))) fatal("couldn't allocate fs buf (1)");
}
return(0);
}
+
+void panic(char *fmt, ...)
+{
+ fprintf(stderr, "%s\n", fmt);
+ exit(1);
+}
+
./usr/include/arm/mcontext.h minix-sys
./usr/include/arm/mutex.h minix-sys
./usr/include/arm/param.h minix-sys
+./usr/include/arm/proc.h minix-sys
./usr/include/arm/profile.h minix-sys
./usr/include/arm/rwlock.h minix-sys
./usr/include/arm/setjmp.h minix-sys
./usr/include/evbarm/mutex.h minix-sys
./usr/include/evbarm/param.h minix-sys
./usr/include/evbarm/partition.h minix-sys
+./usr/include/evbarm/proc.h minix-sys
./usr/include/evbarm/profile.h minix-sys
./usr/include/evbarm/rwlock.h minix-sys
./usr/include/evbarm/setjmp.h minix-sys
./usr/include/i386/fenv.h minix-sys
./usr/include/i386/float.h minix-sys
./usr/include/i386/fpu.h minix-sys
+./usr/include/i386/frame.h minix-sys
./usr/include/i386/ieeefp.h minix-sys
./usr/include/i386/ieee.h minix-sys
./usr/include/i386/int86.h minix-sys
./usr/include/i386/int_types.h minix-sys
./usr/include/i386/ipcconst.h minix-sys
./usr/include/i386/limits.h minix-sys
+./usr/include/i386/lock.h minix-sys
./usr/include/i386/math.h minix-sys
./usr/include/i386/mcontext.h minix-sys
./usr/include/i386/memory.h minix-sys
./usr/include/i386/npx.h minix-sys
./usr/include/i386/param.h minix-sys
./usr/include/i386/partition.h minix-sys
+./usr/include/i386/pcb.h minix-sys
./usr/include/i386/pci_amd.h minix-sys
./usr/include/i386/pci.h minix-sys
./usr/include/i386/pci_intel.h minix-sys
./usr/include/i386/pci_via.h minix-sys
./usr/include/i386/pio.h minix-sys
./usr/include/i386/ports.h minix-sys
+./usr/include/i386/proc.h minix-sys
./usr/include/i386/profile.h minix-sys
./usr/include/i386/rwlock.h minix-sys
+./usr/include/i386/segments.h minix-sys
./usr/include/i386/setjmp.h minix-sys
./usr/include/i386/signal.h minix-sys
./usr/include/i386/stackframe.h minix-sys
+./usr/include/i386/sysarch.h minix-sys
+./usr/include/i386/tss.h minix-sys
./usr/include/i386/types.h minix-sys
./usr/include/i386/vm.h minix-sys
./usr/include/i386/vmparam.h minix-sys
./usr/include/minix/debug.h minix-sys
./usr/include/minix/devio.h minix-sys
./usr/include/minix/devman.h minix-sys
-./usr/include/minix/dirent.h minix-sys
+./usr/include/minix/dirent.h minix-sys obsolete
./usr/include/minix/dmap.h minix-sys
./usr/include/minix/driver.h minix-sys
./usr/include/minix/drivers.h minix-sys
./usr/include/strings.h minix-sys
./usr/include/struct.h minix-sys
./usr/include/sys minix-sys
+./usr/include/sys/acct.h minix-sys
+./usr/include/sys/agpio.h minix-sys
+./usr/include/sys/aio.h minix-sys
./usr/include/sys/ansi.h minix-sys
+./usr/include/sys/aout_mids.h minix-sys
./usr/include/sys/asynchio.h minix-sys
+./usr/include/sys/ataio.h minix-sys
./usr/include/sys/atomic.h minix-sys
+./usr/include/sys/audioio.h minix-sys
./usr/include/sys/bitops.h minix-sys
./usr/include/sys/bootblock.h minix-sys
./usr/include/sys/bswap.h minix-sys
+./usr/include/sys/buf.h minix-sys
+./usr/include/sys/callback.h minix-sys
+./usr/include/sys/callout.h minix-sys
./usr/include/sys/cdefs_aout.h minix-sys
./usr/include/sys/cdefs_elf.h minix-sys
./usr/include/sys/cdefs.h minix-sys
+./usr/include/sys/cdio.h minix-sys
+./usr/include/sys/chio.h minix-sys
+./usr/include/sys/clockctl.h minix-sys
./usr/include/sys/condvar.h minix-sys
+./usr/include/sys/conf.h minix-sys
+./usr/include/sys/core.h minix-sys
+./usr/include/sys/cpufreq.h minix-sys
+./usr/include/sys/cpuio.h minix-sys
./usr/include/sys/ctype_bits.h minix-sys
./usr/include/sys/ctype_inline.h minix-sys
+./usr/include/sys/device.h minix-sys
+./usr/include/sys/device_if.h minix-sys
./usr/include/sys/dirent.h minix-sys
+./usr/include/sys/dir.h minix-sys
./usr/include/sys/disk.h minix-sys
./usr/include/sys/disklabel_acorn.h minix-sys
./usr/include/sys/disklabel_gpt.h minix-sys
./usr/include/sys/disklabel.h minix-sys
+./usr/include/sys/disklabel_rdb.h minix-sys
./usr/include/sys/dkbad.h minix-sys
./usr/include/sys/dkio.h minix-sys
+./usr/include/sys/dkstat.h minix-sys
+./usr/include/sys/domain.h minix-sys
+./usr/include/sys/drvctlio.h minix-sys
+./usr/include/sys/dvdio.h minix-sys
./usr/include/sys/elf64.h minix-sys
./usr/include/sys/elf_common.h minix-sys
./usr/include/sys/elf_core.h minix-sys
./usr/include/sys/elf_generic.h minix-sys
./usr/include/sys/endian.h minix-sys
+./usr/include/sys/envsys.h minix-sys
./usr/include/sys/errno.h minix-sys
+./usr/include/sys/evcnt.h minix-sys
+./usr/include/sys/event.h minix-sys
+./usr/include/sys/exec_aout.h minix-sys
+./usr/include/sys/exec_coff.h minix-sys
+./usr/include/sys/exec_ecoff.h minix-sys
./usr/include/sys/exec_elf.h minix-sys
./usr/include/sys/exec.h minix-sys
+./usr/include/sys/exec_script.h minix-sys
./usr/include/sys/extattr.h minix-sys
+./usr/include/sys/extent.h minix-sys
./usr/include/sys/fcntl.h minix-sys
+./usr/include/sys/fdio.h minix-sys
./usr/include/sys/fd_set.h minix-sys
./usr/include/sys/featuretest.h minix-sys
+./usr/include/sys/filedesc.h minix-sys
./usr/include/sys/file.h minix-sys
+./usr/include/sys/filio.h minix-sys
+./usr/include/sys/flashio.h minix-sys
./usr/include/sys/float_ieee754.h minix-sys
./usr/include/sys/fstypes.h minix-sys
./usr/include/sys/gcq.h minix-sys
./usr/include/sys/gmon.h minix-sys
+./usr/include/sys/gpio.h minix-sys
./usr/include/sys/hash.h minix-sys
./usr/include/sys/ieee754.h minix-sys
./usr/include/sys/inttypes.h minix-sys
./usr/include/sys/ioc_net.h minix-sys
./usr/include/sys/ioc_sound.h minix-sys
./usr/include/sys/ioc_tape.h minix-sys
+./usr/include/sys/ioctl_compat.h minix-sys
./usr/include/sys/ioctl.h minix-sys
./usr/include/sys/ioc_tty.h minix-sys
./usr/include/sys/iostat.h minix-sys
./usr/include/sys/ipc.h minix-sys
./usr/include/sys/jmp_buf.h minix-sys
+./usr/include/sys/joystick.h minix-sys
./usr/include/sys/kbdio.h minix-sys
+./usr/include/sys/kcore.h minix-sys
+./usr/include/sys/kcpuset.h minix-sys
+./usr/include/sys/kgdb.h minix-sys
+./usr/include/sys/kmem.h minix-sys
+./usr/include/sys/ksem.h minix-sys
+./usr/include/sys/ksyms.h minix-sys
+./usr/include/sys/ktrace.h minix-sys
./usr/include/sys/localedef.h minix-sys
+./usr/include/sys/lockf.h minix-sys
./usr/include/sys/lock.h minix-sys
+./usr/include/sys/lwpctl.h minix-sys
./usr/include/sys/lwp.h minix-sys
+./usr/include/sys/malloc.h minix-sys
+./usr/include/sys/mallocvar.h minix-sys
+./usr/include/sys/mbuf.h minix-sys
./usr/include/sys/md4.h minix-sys
./usr/include/sys/md5.h minix-sys
+./usr/include/sys/midiio.h minix-sys
./usr/include/sys/mman.h minix-sys
+./usr/include/sys/module.h minix-sys
./usr/include/sys/mount.h minix-sys
+./usr/include/sys/mqueue.h minix-sys
+./usr/include/sys/msgbuf.h minix-sys
+./usr/include/sys/msg.h minix-sys
./usr/include/sys/mtio.h minix-sys
./usr/include/sys/mutex.h minix-sys
+./usr/include/sys/namei.h minix-sys
./usr/include/sys/null.h minix-sys
./usr/include/sys/param.h minix-sys
+./usr/include/sys/pcu.h minix-sys
+./usr/include/sys/pipe.h minix-sys
+./usr/include/sys/pmc.h minix-sys
./usr/include/sys/poll.h minix-sys
+./usr/include/sys/pool.h minix-sys
+./usr/include/sys/power.h minix-sys
./usr/include/sys/procfs.h minix-sys
+./usr/include/sys/proc.h minix-sys
+./usr/include/sys/protosw.h minix-sys
+./usr/include/sys/pset.h minix-sys
./usr/include/sys/ptrace.h minix-sys
./usr/include/sys/ptree.h minix-sys
./usr/include/sys/queue.h minix-sys
+./usr/include/sys/quotactl.h minix-sys
+./usr/include/sys/quota.h minix-sys
+./usr/include/sys/radioio.h minix-sys
./usr/include/sys/ras.h minix-sys
./usr/include/sys/rbtree.h minix-sys
./usr/include/sys/reboot.h minix-sys
./usr/include/sys/resource.h minix-sys
+./usr/include/sys/resourcevar.h minix-sys
./usr/include/sys/rmd160.h minix-sys
+./usr/include/sys/rnd.h minix-sys
./usr/include/sys/rwlock.h minix-sys
+./usr/include/sys/scanio.h minix-sys
+./usr/include/sys/sched.h minix-sys
+./usr/include/sys/scsiio.h minix-sys
+./usr/include/sys/sdt.h minix-sys
./usr/include/sys/select.h minix-sys
+./usr/include/sys/selinfo.h minix-sys
./usr/include/sys/sem.h minix-sys
./usr/include/sys/sha1.h minix-sys
./usr/include/sys/sha2.h minix-sys
./usr/include/sys/shm.h minix-sys
./usr/include/sys/siginfo.h minix-sys
./usr/include/sys/signal.h minix-sys
+./usr/include/sys/signalvar.h minix-sys
./usr/include/sys/sigtypes.h minix-sys
+./usr/include/sys/simplelock.h minix-sys
+./usr/include/sys/sleepq.h minix-sys
./usr/include/sys/socket.h minix-sys
+./usr/include/sys/socketvar.h minix-sys
+./usr/include/sys/sockio.h minix-sys
+./usr/include/sys/soundcard.h minix-sys
+./usr/include/sys/spawn.h minix-sys
./usr/include/sys/specificdata.h minix-sys
./usr/include/sys/statfs.h minix-sys
./usr/include/sys/stat.h minix-sys
./usr/include/sys/stdarg.h minix-sys
./usr/include/sys/stdint.h minix-sys
./usr/include/sys/svrctl.h minix-sys
+./usr/include/sys/swap.h minix-sys
+./usr/include/sys/syncobj.h minix-sys
+./usr/include/sys/syscallargs.h minix-sys
+./usr/include/sys/syscall.h minix-sys
./usr/include/sys/sysctl.h minix-sys
./usr/include/sys/syslimits.h minix-sys
./usr/include/sys/syslog.h minix-sys
+./usr/include/sys/tape.h minix-sys
./usr/include/sys/termios.h minix-sys
+./usr/include/sys/timeb.h minix-sys
./usr/include/sys/time.h minix-sys
+./usr/include/sys/timepps.h minix-sys
./usr/include/sys/times.h minix-sys
+./usr/include/sys/timex.h minix-sys
./usr/include/sys/tls.h minix-sys
+./usr/include/sys/trace.h minix-sys
./usr/include/sys/tree.h minix-sys
+./usr/include/sys/ttychars.h minix-sys
./usr/include/sys/ttycom.h minix-sys
./usr/include/sys/ttydefaults.h minix-sys
+./usr/include/sys/ttydev.h minix-sys
+./usr/include/sys/tty.h minix-sys
./usr/include/sys/types.h minix-sys
./usr/include/sys/ucontext.h minix-sys
./usr/include/sys/ucred.h minix-sys
./usr/include/sys/uio.h minix-sys
./usr/include/sys/un.h minix-sys
./usr/include/sys/unistd.h minix-sys
+./usr/include/sys/unpcb.h minix-sys
+./usr/include/sys/user.h minix-sys
./usr/include/sys/utsname.h minix-sys
./usr/include/sys/uuid.h minix-sys
+./usr/include/sys/vadvise.h minix-sys
+./usr/include/sys/verified_exec.h minix-sys
./usr/include/sys/video.h minix-sys
+./usr/include/sys/videoio.h minix-sys
./usr/include/sys/vm.h minix-sys
+./usr/include/sys/vmmeter.h minix-sys
+./usr/include/sys/vnode.h minix-sys
+./usr/include/sys/vnode_if.h minix-sys
./usr/include/sys/wait.h minix-sys
+./usr/include/sys/wapbl.h minix-sys
+./usr/include/sys/wapbl_replay.h minix-sys
+./usr/include/sys/wdog.h minix-sys
+./usr/include/sys/xattr.h minix-sys
./usr/include/sysexits.h minix-sys
./usr/include/syslog.h minix-sys
./usr/include/tar.h minix-sys
./usr/include/utmp.h minix-sys
./usr/include/utmpx.h minix-sys
./usr/include/uuid.h minix-sys
+./usr/include/uvm minix-sys
+./usr/include/uvm/uvm_amap.h minix-sys
+./usr/include/uvm/uvm_anon.h minix-sys
+./usr/include/uvm/uvm_aobj.h minix-sys
+./usr/include/uvm/uvm_device.h minix-sys
+./usr/include/uvm/uvm_extern.h minix-sys
+./usr/include/uvm/uvm_fault.h minix-sys
+./usr/include/uvm/uvm_fault_i.h minix-sys
+./usr/include/uvm/uvm_glue.h minix-sys
+./usr/include/uvm/uvm.h minix-sys
+./usr/include/uvm/uvm_km.h minix-sys
+./usr/include/uvm/uvm_loan.h minix-sys
+./usr/include/uvm/uvm_map.h minix-sys
+./usr/include/uvm/uvm_object.h minix-sys
+./usr/include/uvm/uvm_page.h minix-sys
+./usr/include/uvm/uvm_pager.h minix-sys
+./usr/include/uvm/uvm_param.h minix-sys
+./usr/include/uvm/uvm_pdaemon.h minix-sys
+./usr/include/uvm/uvm_pglist.h minix-sys
+./usr/include/uvm/uvm_pmap.h minix-sys
+./usr/include/uvm/uvm_prot.h minix-sys
+./usr/include/uvm/uvm_stat.h minix-sys
+./usr/include/uvm/uvm_swap.h minix-sys
./usr/include/varargs.h minix-sys
./usr/include/vis.h minix-sys
./usr/include/wchar.h minix-sys
./usr/tests/minix-posix/test75 minix-sys
./usr/tests/minix-posix/test76 minix-sys
./usr/tests/minix-posix/test77 minix-sys
+./usr/tests/minix-posix/test78 minix-sys
./usr/tests/minix-posix/test8 minix-sys
./usr/tests/minix-posix/test9 minix-sys
./usr/tests/minix-posix/testinterp minix-sys
LIB= utils
+.if defined(__MINIX)
+WARNS= # empty
+.endif
+
WARNS?= 2
SRCS= datetime.cpp \
*/
#include <sys/dirent.h>
-#ifndef __minix
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
#define d_ino d_fileno /* backward compatibility */
#endif
-#endif /* !__minix */
typedef struct _dirdesc DIR;
#define FTS_PHYSICAL 0x010 /* physical walk */
#define FTS_SEEDOT 0x020 /* return dot and dot-dot */
#define FTS_XDEV 0x040 /* don't cross devices */
-#ifndef __minix
#define FTS_WHITEOUT 0x080 /* return whiteout information */
-#endif
#define FTS_OPTIONMASK 0x0ff /* valid user option mask */
#define FTS_NAMEONLY 0x100 /* (private) child names only */
INCSDIR= /usr/include/minix
-INCS+= dirent.h paths.h param.h
+INCS+= paths.h param.h
INCS+= acpi.h audio_fw.h bitmap.h \
bdev.h blockdriver.h blockdriver_mt.h \
board.h btrace.h \
+++ /dev/null
-/* dirent.h - Declarations for directory reading routines.
- * Author: Kees J. Bot
- * 24 Apr 1989
- *
- * Note: The V7 format directory entries used under Minix must be transformed
- * into a struct dirent with a d_name of at least 15 characters. Given that
- * we have to transform V7 entries anyhow it is little trouble to let the
- * routines understand the so-called "flex" directory format too.
- */
-
-#ifndef _DIRENT_H
-#define _DIRENT_H
-
-#include <sys/cdefs.h>
-
- /* Name of length len needs _EXTENT(len) extra slots. */
-#define _EXTENT(len) (((len) + 5) >> 3)
-
-/* The block size must be at least 1024 bytes, because otherwise
- * the superblock (at 1024 bytes) overlaps with other filesystem data.
- */
-#define _MIN_BLOCK_SIZE 1024
-
-/* The below is allocated in some parts of the system as the largest
- * a filesystem block can be. For instance, the boot monitor allocates
- * 3 of these blocks and has to fit within 64kB, so this can't be
- * increased without taking that into account.
- */
-#define _MAX_BLOCK_SIZE 4096
-
-/* This is the block size for the fixed versions of the filesystem (V1/V2) */
-#define _STATIC_BLOCK_SIZE 1024
-
-#endif /* _DIRENT_H */
int bitmapsize(bit_t _nr_bits, int block_size);
unsigned conv2(int _norm, int _w);
long conv4(int _norm, long _x);
-void conv_inode(struct inode *_rip, d1_inode *_dip, d2_inode *_dip2, int
- _rw_flag, int _magic);
-void old_icopy(struct inode *_rip, d1_inode *_dip, int _direction, int
- _norm);
-void new_icopy(struct inode *_rip, d2_inode *_dip, int _direction, int
- _norm);
+void new_icopy(struct inode *_rip, d2_inode *_dip, int _direction, int _norm);
int getprocessor(void);
void _cpuid(u32_t *eax, u32_t *ebx, u32_t *ecx, u32_t *edx);
int load_mtab(char *_prog_name);
+uint8_t fs_mode_to_type(mode_t mode);
int get_mtab_entry(char dev[PATH_MAX], char mount_point[PATH_MAX],
char type[MNTNAMELEN], char flags[MNTFLAGLEN]);
rewinddir.c scandir.c seekdir.c \
setjmperr.c setmode.c \
shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \
+ sysctl.c sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c \
siglist.c signal.c signame.c sigrelse.c \
sigset.c sigsetops.c sleep.c \
stringlist.c sysconf.c \
#include <stdlib.h>
+#ifdef __minix
+int __sysctl(const int *name, unsigned int namelen,
+ void *oldp, size_t *oldlenp,
+ const void *newp, size_t newlen)
+{
+ return ENOENT;
+}
+#endif
+
int
sysctl(const int *name, unsigned int namelen,
void *oldp, size_t *oldlenp,
#include <sys/types.h>
#include <minix/const.h>
#include <minix/type.h> /* for unshort :-( */
+#include <minix/sysutil.h>
#include "mfs/const.h" /* depends of -I flag in Makefile */
#include "mfs/type.h" /* ditto */
#include "mfs/inode.h" /* ditto */
#include "mfs/super.h"
#include <minix/fslib.h>
+#include <sys/stat.h>
/* The next routine is copied from fsck.c and mkfs.c... (Re)define some
* things for consistency. Some things should be done better.
return(nr_blocks);
}
-
-/*===========================================================================*
- * conv2 *
- *===========================================================================*/
-unsigned conv2(norm, w)
-int norm; /* TRUE if no swap, FALSE for byte swap */
-int w; /* promotion of 16-bit word to be swapped */
+uint8_t fs_mode_to_type(mode_t mode)
{
-/* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
-
- if (norm) return( (unsigned) w & 0xFFFF);
- return( ((w&BYTE) << 8) | ( (w>>8) & BYTE));
-}
-
-
-/*===========================================================================*
- * conv4 *
- *===========================================================================*/
-long conv4(norm, x)
-int norm; /* TRUE if no swap, FALSE for byte swap */
-long x; /* 32-bit long to be byte swapped */
-{
-/* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
-
- unsigned lo, hi;
- long l;
-
- if (norm) return(x); /* byte order was already ok */
- lo = conv2(FALSE, (int) x & 0xFFFF); /* low-order half, byte swapped */
- hi = conv2(FALSE, (int) (x>>16) & 0xFFFF); /* high-order half, swapped */
- l = ( (long) lo <<16) | hi;
- return(l);
+ if(S_ISREG(mode)) return DT_REG;
+ else if(S_ISDIR(mode)) return DT_DIR;
+ else if(S_ISLNK(mode)) return DT_LNK;
+ else if(S_ISCHR(mode)) return DT_CHR;
+ else if(S_ISBLK(mode)) return DT_BLK;
+ else if(S_ISFIFO(mode)) return DT_FIFO;
+ else if(S_ISSOCK(mode)) return DT_SOCK;
+
+ panic("unknown type, mode 0x%x", mode);
}
-
-/*===========================================================================*
- * conv_inode *
- *===========================================================================*/
-void conv_inode(rip, dip, dip2, rw_flag, magic)
-register struct inode *rip; /* pointer to the in-core inode struct */
-register d1_inode *dip; /* pointer to the V1 on-disk inode struct */
-register d2_inode *dip2; /* pointer to the V2 on-disk inode struct */
-int rw_flag; /* READING or WRITING */
-int magic; /* magic number of file system */
-{
-/* Copy the inode from the disk block to the in-core table or vice versa.
- * If the fourth parameter below is FALSE, the bytes are swapped.
- */
- switch (magic) {
- case SUPER_MAGIC: old_icopy(rip, dip, rw_flag, TRUE); break;
- case SUPER_REV: old_icopy(rip, dip, rw_flag, FALSE); break;
- case SUPER_V3:
- case SUPER_V2: new_icopy(rip, dip2, rw_flag, TRUE); break;
- case SUPER_V2_REV: new_icopy(rip, dip2, rw_flag, FALSE); break;
- }
-}
-
-
-/*===========================================================================*
- * old_icopy *
- *===========================================================================*/
-void old_icopy(rip, dip, direction, norm)
-register struct inode *rip; /* pointer to the in-core inode struct */
-register d1_inode *dip; /* pointer to the d1_inode inode struct */
-int direction; /* READING (from disk) or WRITING (to disk) */
-int norm; /* TRUE = do not swap bytes; FALSE = swap */
-
-{
-/* 4 different on-disk inode layouts are supported, one for each combination
- * of V1.x/V2.x * bytes-swapped/not-swapped. When an inode is read or written
- * this routine handles the conversions so that the information in the inode
- * table is independent of the disk structure from which the inode came.
- * The old_icopy routine copies to and from V1 disks.
- */
-
- int i;
-
- if (direction == READING) {
- /* Copy V1.x inode to the in-core table, swapping bytes if need be. */
- rip->i_mode = conv2(norm, dip->d1_mode);
- rip->i_uid = conv2(norm,dip->d1_uid );
- rip->i_size = conv4(norm,dip->d1_size);
- rip->i_mtime = conv4(norm,dip->d1_mtime);
- rip->i_atime = 0;
- rip->i_ctime = 0;
- rip->i_nlinks = (nlink_t) dip->d1_nlinks; /* 1 char */
- rip->i_gid = (gid_t) dip->d1_gid; /* 1 char */
- rip->i_ndzones = V1_NR_DZONES;
- rip->i_nindirs = V1_INDIRECTS;
- for (i = 0; i < V1_NR_TZONES; i++)
- rip->i_zone[i] = conv2(norm, (int) dip->d1_zone[i]);
- } else {
- /* Copying V1.x inode to disk from the in-core table. */
- dip->d1_mode = conv2(norm,rip->i_mode);
- dip->d1_uid = conv2(norm,rip->i_uid );
- dip->d1_size = conv4(norm,rip->i_size);
- dip->d1_mtime = conv4(norm,rip->i_mtime);
- dip->d1_nlinks = (nlink_t) rip->i_nlinks; /* 1 char */
- dip->d1_gid = (gid_t) rip->i_gid; /* 1 char */
- for (i = 0; i < V1_NR_TZONES; i++)
- dip->d1_zone[i] = conv2(norm, (int) rip->i_zone[i]);
- }
-}
-
-
-/*===========================================================================*
- * new_icopy *
- *===========================================================================*/
-void new_icopy(rip, dip, direction, norm)
-register struct inode *rip; /* pointer to the in-core inode struct */
-register d2_inode *dip; /* pointer to the d2_inode struct */
-int direction; /* READING (from disk) or WRITING (to disk) */
-int norm; /* TRUE = do not swap bytes; FALSE = swap */
-
-{
-/* Same as old_icopy, but to/from V2 disk layout. */
-
- int i;
-
- if (direction == READING) {
- /* Copy V2.x inode to the in-core table, swapping bytes if need be. */
- rip->i_mode = conv2(norm,dip->d2_mode);
- rip->i_uid = conv4(norm,dip->d2_uid );
- rip->i_nlinks = conv2(norm,(int) dip->d2_nlinks);
- rip->i_gid = conv4(norm,(int) dip->d2_gid );
- rip->i_size = conv4(norm,dip->d2_size);
- rip->i_atime = conv4(norm,dip->d2_atime);
- rip->i_ctime = conv4(norm,dip->d2_ctime);
- rip->i_mtime = conv4(norm,dip->d2_mtime);
- rip->i_ndzones = V2_NR_DZONES;
- rip->i_nindirs = V2_INDIRECTS(rip->i_sp->s_block_size);
- for (i = 0; i < V2_NR_TZONES; i++)
- rip->i_zone[i] = conv4(norm, (long) dip->d2_zone[i]);
- } else {
- /* Copying V2.x inode to disk from the in-core table. */
- dip->d2_mode = conv2(norm,rip->i_mode);
- dip->d2_uid = conv4(norm,rip->i_uid );
- dip->d2_nlinks = conv2(norm,rip->i_nlinks);
- dip->d2_gid = conv4(norm,rip->i_gid );
- dip->d2_size = conv4(norm,rip->i_size);
- dip->d2_atime = conv4(norm,rip->i_atime);
- dip->d2_ctime = conv4(norm,rip->i_ctime);
- dip->d2_mtime = conv4(norm,rip->i_mtime);
- for (i = 0; i < V2_NR_TZONES; i++)
- dip->d2_zone[i] = conv4(norm, (long) rip->i_zone[i]);
- }
-}
if (o != 0)
reclen += sizeof(long) - o;
- /* FIXME: Set d_off?
- * dep->d_off =
- */
d->d_reclen = (unsigned short) reclen;
(void)memcpy(d->d_name, name, (size_t)len);
d->d_name[len] = '\0';
struct sffs_attr attr;
size_t len, off, user_off, user_left;
off_t pos;
- int r;
+ int r, namelen;
/* must be at least sizeof(struct dirent) + NAME_MAX */
static char buf[BLOCK_SIZE];
}
}
- len = DWORD_ALIGN(sizeof(struct dirent) + strlen(name));
+ /* record length incl. alignment. */
+ namelen = strlen(name);
+ len = _DIRENT_RECLEN(dent, namelen);
/* Is the user buffer too small to store another record?
* Note that we will be rerequesting the same dentry upon a subsequent
/* Fill in the actual directory entry. */
dent = (struct dirent *) &buf[off];
dent->d_ino = INODE_NR(child);
- dent->d_off = pos;
dent->d_reclen = len;
+ dent->d_namlen = namelen;
+ dent->d_type = IS_DIR(child) ? DT_DIR : DT_REG;
strcpy(dent->d_name, name);
off += len;
#include "inc.h"
#include <dirent.h>
+#include <minix/minlib.h>
#define GETDENTS_BUFSIZ 4096
#define DWORD_ALIGN(len) (((len) + sizeof(long) - 1) & ~(sizeof(long) - 1))
name = child->i_name;
}
- len = DWORD_ALIGN(sizeof(struct dirent) + strlen(name));
+ /* record length incl. alignment. */
+ len = _DIRENT_RECLEN(dent, strlen(name));
/* Is the user buffer too small to store another record? */
if (user_off + off + len > user_left) {
/* Fill in the actual directory entry. */
dent = (struct dirent *) &buf[off];
dent->d_ino = (ino_t) get_inode_number(child);
- dent->d_off = (off_t) pos;
dent->d_reclen = len;
+ dent->d_type = fs_mode_to_type(child->i_stat.mode);
+ dent->d_namlen = strlen(name);
strcpy(dent->d_name, name);
off += len;
SRCS= mknod.c pack_dev.c
MAN= mknod.8
+# LSC Does not compile without any warnings...
+NOGCCERROR:=yes
+NOCLANGERROR:=yes
+
.include <bsd.prog.mk>
static void
get_device_info(void)
{
+#ifdef __minix
+ err(1, "no kern.drivers on minix" );
+#else
static int mib[2] = {CTL_KERN, KERN_DRIVERS};
size_t len;
err(1, "kern.drivers" );
num_drivers = len / sizeof *kern_drivers;
+#endif
}
static void
SRCS = main.c device.c buf.c bind.c
-DPADD+= ${LIBSYS}
-LDADD = -lvtreefs -lsys
+DPADD+= ${LIBSYS} ${LIBMINLIB}
+LDADD = -lvtreefs -lsys -lminlib
BINDIR?= /sbin
MAN=
stadir.c table.c time.c utility.c \
write.c ialloc.c inode.c main.c path.c \
super.c
-DPADD+= ${LIBMINIXFS} ${LIBBDEV} ${LIBSYS}
-LDADD+= -lminixfs -lbdev -lsys
+DPADD+= ${LIBMINIXFS} ${LIBBDEV} ${LIBSYS} ${LIBMINLIB}
+LDADD+= -lminixfs -lbdev -lsys -lminlib
WARNS=3
#ifndef EXT2_BUF_H
#define EXT2_BUF_H
-#include <dirent.h>
+#include <sys/dirent.h>
union fsdata_u {
- char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
+ char b__data[1]; /* ordinary user data */
/* indirect block */
- block_t b__ind[_MAX_BLOCK_SIZE/sizeof(block_t)];
+ block_t b__ind[1];
/* bit map block */
- bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
+ bitchunk_t b__bitmap[1];
};
/* A block is free if b_dev == NO_DEV. */
#include "inode.h"
#include "super.h"
#include <minix/vfsif.h>
+#include <minix/minlib.h>
#include <sys/param.h>
#include <assert.h>
#include <sys/param.h>
#define GETDENTS_ENTRIES 8
static char getdents_buf[GETDENTS_BUFSIZE * GETDENTS_ENTRIES];
struct inode *rip;
- int o, r, done;
+ int r, done;
unsigned int block_size, len, reclen;
pino_t ino;
cp_grant_id_t gid;
assert(len <= NAME_MAX);
assert(len <= EXT2_NAME_MAX);
- /* Compute record length */
- reclen = offsetof(struct dirent, d_name) + len + 1;
- o = (reclen % sizeof(long));
- if (o != 0)
- reclen += sizeof(long) - o;
+ /* Compute record length, incl alignment. */
+ reclen = _DIRENT_RECLEN(dep, len);
/* Need the position of this entry in the directory */
ent_pos = block_pos + ((char *)d_desc - b_data(bp));
}
dep = (struct dirent *) &getdents_buf[tmpbuf_off];
- dep->d_ino = (ino_t) conv4(le_CPU, d_desc->d_ino);
- dep->d_off = (off_t) ent_pos;
+ dep->d_fileno = (ino_t) conv4(le_CPU, d_desc->d_ino);
dep->d_reclen = (unsigned short) reclen;
+ dep->d_namlen = len;
memcpy(dep->d_name, d_desc->d_name, len);
dep->d_name[len] = '\0';
+ {
+ struct inode *entrip;
+ if(!(entrip = get_inode(fs_dev, dep->d_fileno)))
+ panic("unexpected get_inode failure");
+ dep->d_type = fs_mode_to_type(entrip->i_mode);
+ put_inode(entrip);
+ }
tmpbuf_off += reclen;
}
#include <minix/com.h>
#include <minix/u64.h>
#include <minix/bdev.h>
+#include <machine/vmparam.h>
#include "buf.h"
#include "inode.h"
#include "super.h"
char *buf;
block_t gd_size; /* group descriptors table size in blocks */
int gdt_position;
+ static char superblock_buf[1024];
+
+ ondisk_superblock = (struct super_block *) superblock_buf;
dev = sp->s_dev; /* save device (will be overwritten by copy) */
if (dev == NO_DEV)
super_block_offset = opt.block_with_super * 1024;
}
- STATICINIT(ondisk_superblock, 1);
-
- if (!ondisk_superblock)
- panic("can't allocate memory for super_block buffers");
-
- assert(_MIN_BLOCK_SIZE <= sizeof(*ondisk_superblock));
r = bdev_read(dev, ((u64_t)(super_block_offset)), (char*) ondisk_superblock,
- _MIN_BLOCK_SIZE, BDEV_NOFLAGS);
+ sizeof(superblock_buf), BDEV_NOFLAGS);
- if (r != _MIN_BLOCK_SIZE)
+ if (r != sizeof(superblock_buf))
return(EINVAL);
super_copy(sp, ondisk_superblock);
sp->s_block_size = 1024*(1<<sp->s_log_block_size);
- if (sp->s_block_size < _MIN_BLOCK_SIZE
- || sp->s_block_size >_MAX_BLOCK_SIZE) {
+ if (sp->s_block_size < PAGE_SIZE) {
printf("data block size (%u) is invalid\n", sp->s_block_size);
return(EINVAL);
}
file, line, #c); panic("sanity check " #c " failed: %d", __LINE__); }
-/*===========================================================================*
- * sanity_check *
- *===========================================================================*/
-void sanitycheck(char *file, int line)
-{
- MYASSERT(SELF_E > 0);
- if(superblock->s_dev != NO_DEV) {
- MYASSERT(superblock->s_dev == fs_dev);
- MYASSERT(superblock->s_block_size == lmfs_fs_block_size());
- } else {
- MYASSERT(_MIN_BLOCK_SIZE == lmfs_fs_block_size());
- }
-}
-
/*===========================================================================*
* ansi_strcmp *
*===========================================================================*/
SRCS= main.c table.c mount.c super.c inode.c \
utility.c misc.c path.c read.c stadir.c
-DPADD+= ${LIBBDEV} ${LIBSYS}
-LDADD+= -lbdev -lsys -lc -lminixfs
+DPADD+= ${LIBBDEV} ${LIBSYS} ${LIBMINLIB}
+LDADD+= -lbdev -lsys -lc -lminixfs -lminlib
MAN=
-#include <dirent.h>
+#include <sys/dirent.h>
#define b_data(bp) ((char *) (bp->data))
#include "inc.h"
#include <minix/com.h>
#include <minix/vfsif.h>
+#include <minix/minlib.h>
#include <fcntl.h>
#include <stddef.h>
#include "buf.h"
/*===========================================================================*
* fs_getdents *
*===========================================================================*/
-int fs_getdents(void) {
+int fs_getdents(void)
+{
struct dir_record *dir;
pino_t ino;
cp_grant_id_t gid;
/* Compute the length of the name */
cp = memchr(name, '\0', NAME_MAX);
- if (cp == NULL) len = NAME_MAX;
- else len= cp - name;
+ if (cp == NULL)
+ len = NAME_MAX;
+ else
+ len= cp - name;
- /* Compute record length */
- reclen = offsetof(struct dirent, d_name) + len + 1;
- o = (reclen % sizeof(long));
- if (o != 0)
- reclen += sizeof(long) - o;
+ /* Compute record length; also does alignment. */
+ reclen = _DIRENT_RECLEN(dirp, len);
/* If the new record does not fit, then copy the buffer
* and start from the beginning. */
/* The standard data structure is created using the
* data in the buffer. */
dirp = (struct dirent *) &getdents_buf[tmpbuf_offset];
- dirp->d_ino = (u32_t)(b_data(bp) + (size_t)block_pos);
- dirp->d_off= cur_pos;
+ dirp->d_fileno = (u32_t)(b_data(bp) + (size_t)block_pos);
dirp->d_reclen= reclen;
+ dirp->d_type = fs_mode_to_type(dir_tmp->d_mode);
+ dirp->d_namlen = len;
memcpy(dirp->d_name, name, len);
dirp->d_name[len]= '\0';
tmpbuf_offset += reclen;
* will eventually be rewritten to the disk.
*/
-#include <dirent.h>
+#include <sys/dirent.h>
union fsdata_u {
- char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
+ char b__data[1]; /* ordinary user data */
/* directory block */
- struct direct b__dir[NR_DIR_ENTRIES(_MAX_BLOCK_SIZE)];
-/* V1 indirect block */
- zone1_t b__v1_ind[V1_INDIRECTS];
+ struct direct b__dir[1];
/* V2 indirect block */
- zone_t b__v2_ind[V2_INDIRECTS(_MAX_BLOCK_SIZE)];
-/* V1 inode block */
- d1_inode b__v1_ino[V1_INODES_PER_BLOCK];
+ zone_t b__v2_ind[1];
/* V2 inode block */
- d2_inode b__v2_ino[V2_INODES_PER_BLOCK(_MAX_BLOCK_SIZE)];
+ d2_inode b__v2_ino[1];
/* bit map block */
- bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
+ bitchunk_t b__bitmap[1];
};
/* A block is free if b_dev == NO_DEV. */
/* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
#define b_data(b) ((union fsdata_u *) b->data)->b__data
#define b_dir(b) ((union fsdata_u *) b->data)->b__dir
-#define b_v1_ind(b) ((union fsdata_u *) b->data)->b__v1_ind
#define b_v2_ind(b) ((union fsdata_u *) b->data)->b__v2_ind
-#define b_v1_ino(b) ((union fsdata_u *) b->data)->b__v1_ino
#define b_v2_ino(b) ((union fsdata_u *) b->data)->b__v2_ino
#define b_bitmap(b) ((union fsdata_u *) b->data)->b__bitmap
#define __MFS_CONST_H__
/* Tables sizes */
-#define V1_NR_DZONES 7 /* # direct zone numbers in a V1 inode */
-#define V1_NR_TZONES 9 /* total # zone numbers in a V1 inode */
#define V2_NR_DZONES 7 /* # direct zone numbers in a V2 inode */
#define V2_NR_TZONES 10 /* total # zone numbers in a V2 inode */
#define SUPER_V2_REV 0x6824 /* V2 magic written on PC, read on 68K or vv */
#define SUPER_V3 0x4d5a /* magic # for V3 file systems */
-#define V1 1 /* version number of V1 file systems */
#define V2 2 /* version number of V2 file systems */
#define V3 3 /* version number of V3 file systems */
#define FS_BITCHUNK_BITS (usizeof(bitchunk_t) * CHAR_BIT)
#define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
-/* Derived sizes pertaining to the V1 file system. */
-#define V1_ZONE_NUM_SIZE usizeof (zone1_t) /* # bytes in V1 zone */
-#define V1_INODE_SIZE usizeof (d1_inode) /* bytes in V1 dsk ino */
-
-/* # zones/indir block */
-#define V1_INDIRECTS (_STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE)
-
-/* # V1 dsk inodes/blk */
-#define V1_INODES_PER_BLOCK (_STATIC_BLOCK_SIZE/V1_INODE_SIZE)
-
/* Derived sizes pertaining to the V2 file system. */
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */
#define V2_INODE_SIZE usizeof (d2_inode) /* bytes in V2 dsk ino */
#include "inode.h"
#include "super.h"
#include <minix/vfsif.h>
+#include <assert.h>
static void addhash_inode(struct inode *node);
static void free_inode(dev_t dev, pino_t numb);
static void new_icopy(struct inode *rip, d2_inode *dip, int direction,
int norm);
-static void old_icopy(struct inode *rip, d1_inode *dip, int direction,
- int norm);
static void unhash_inode(struct inode *node);
static void wipe_inode(struct inode *rip);
register struct buf *bp;
register struct super_block *sp;
- d1_inode *dip;
d2_inode *dip2;
block_t b, offset;
offset = START_BLOCK + sp->s_imap_blocks + sp->s_zmap_blocks;
b = (block_t) (rip->i_num - 1)/sp->s_inodes_per_block + offset;
bp = get_block(rip->i_dev, b, NORMAL);
- dip = b_v1_ino(bp) + (rip->i_num - 1) % V1_INODES_PER_BLOCK;
dip2 = b_v2_ino(bp) + (rip->i_num - 1) %
V2_INODES_PER_BLOCK(sp->s_block_size);
/* Copy the inode from the disk block to the in-core table or vice versa.
* If the fourth parameter below is FALSE, the bytes are swapped.
*/
- if (sp->s_version == V1)
- old_icopy(rip, dip, rw_flag, sp->s_native);
- else
- new_icopy(rip, dip2, rw_flag, sp->s_native);
+ assert(sp->s_version == V3);
+ new_icopy(rip, dip2, rw_flag, sp->s_native);
put_block(bp, INODE_BLOCK);
IN_MARKCLEAN(rip);
}
-
-/*===========================================================================*
- * old_icopy *
- *===========================================================================*/
-static void old_icopy(rip, dip, direction, norm)
-register struct inode *rip; /* pointer to the in-core inode struct */
-register d1_inode *dip; /* pointer to the d1_inode inode struct */
-int direction; /* READING (from disk) or WRITING (to disk) */
-int norm; /* TRUE = do not swap bytes; FALSE = swap */
-{
-/* The V1.x IBM disk, the V1.x 68000 disk, and the V2 disk (same for IBM and
- * 68000) all have different inode layouts. When an inode is read or written
- * this routine handles the conversions so that the information in the inode
- * table is independent of the disk structure from which the inode came.
- * The old_icopy routine copies to and from V1 disks.
- */
-
- int i;
-
- if (direction == READING) {
- /* Copy V1.x inode to the in-core table, swapping bytes if need be. */
- rip->i_mode = (pmode_t) conv2(norm, (int) dip->d1_mode);
- rip->i_uid = (uid_t) conv2(norm, (int) dip->d1_uid );
- rip->i_size = (off_t) conv4(norm, dip->d1_size);
- rip->i_mtime = (time_t) conv4(norm, dip->d1_mtime);
- rip->i_atime = (time_t) rip->i_mtime;
- rip->i_ctime = (time_t) rip->i_mtime;
- rip->i_nlinks = (nlink_t) dip->d1_nlinks; /* 1 char */
- rip->i_gid = (gid_t) dip->d1_gid; /* 1 char */
- rip->i_ndzones = V1_NR_DZONES;
- rip->i_nindirs = V1_INDIRECTS;
- for (i = 0; i < V1_NR_TZONES; i++)
- rip->i_zone[i] = (zone_t) conv2(norm, (int) dip->d1_zone[i]);
- } else {
- /* Copying V1.x inode to disk from the in-core table. */
- dip->d1_mode = (u16_t) conv2(norm, (int) rip->i_mode);
- dip->d1_uid = (i16_t) conv2(norm, (int) rip->i_uid );
- dip->d1_size = (i32_t) conv4(norm, rip->i_size);
- dip->d1_mtime = (i32_t) conv4(norm, rip->i_mtime);
- dip->d1_nlinks = (u8_t) rip->i_nlinks; /* 1 char */
- dip->d1_gid = (u8_t) rip->i_gid; /* 1 char */
- for (i = 0; i < V1_NR_TZONES; i++)
- dip->d1_zone[i] = (u16_t) conv2(norm, (int) rip->i_zone[i]);
- }
-}
-
-
/*===========================================================================*
* new_icopy *
*===========================================================================*/
int direction; /* READING (from disk) or WRITING (to disk) */
int norm; /* TRUE = do not swap bytes; FALSE = swap */
{
-/* Same as old_icopy, but to/from V2 disk layout. */
-
int i;
if (direction == READING) {
* such as to search a directory for a path name.
* The first part of the struct holds fields that are present on the
* disk; the second part holds fields not present on the disk.
- * The disk inode part is also declared in "type.h" as 'd1_inode' for V1
- * file systems and 'd2_inode' for V2 file systems.
*
* Updates:
* 2007-01-06: jfdsmit@gmail.com added i_zsearch
/* Allocate a disk block for the contents of the symlink.
* Copy contents of symlink (the name pointed to) into first disk block. */
if( (r = err_code) == OK) {
+ size_t namelen = (size_t) fs_m_in.REQ_MEM_SIZE;
bp = new_block(sip, (off_t) 0);
if (bp == NULL)
r = err_code;
- else
- r = sys_safecopyfrom(VFS_PROC_NR,
+ else {
+ if(get_block_size(sip->i_dev) <= namelen) {
+ r = ENAMETOOLONG;
+ } else {
+ r = sys_safecopyfrom(VFS_PROC_NR,
(cp_grant_id_t) fs_m_in.REQ_GRANT3,
(vir_bytes) 0, (vir_bytes) b_data(bp),
- (size_t) fs_m_in.REQ_MEM_SIZE);
+ namelen);
+ b_data(bp)[namelen] = '\0';
+ }
+ }
if(bp != NULL && r == OK) {
- b_data(bp)[_MIN_BLOCK_SIZE-1] = '\0';
sip->i_size = (off_t) strlen(b_data(bp));
if(sip->i_size != fs_m_in.REQ_MEM_SIZE) {
/* This can happen if the user provides a buffer
#include "inode.h"
#include "super.h"
#include <minix/vfsif.h>
+#include <minix/minlib.h>
#include <sys/param.h>
#include <assert.h>
struct buf *bp; /* pointer to indirect block */
int index; /* index into *bp */
{
-/* Given a pointer to an indirect block, read one entry. The reason for
- * making a separate routine out of this is that there are four cases:
- * V1 (IBM and 68000), and V2 (IBM and 68000).
- */
-
struct super_block *sp;
- zone_t zone; /* V2 zones are longs (shorts in V1) */
+ zone_t zone;
if(bp == NULL)
panic("rd_indir() on NULL");
sp = get_super(lmfs_dev(bp)); /* need super block to find file sys type */
/* read a zone from an indirect block */
- if (sp->s_version == V1)
- zone = (zone_t) conv2(sp->s_native, (int) b_v1_ind(bp)[index]);
- else
- zone = (zone_t) conv4(sp->s_native, (long) b_v2_ind(bp)[index]);
+ assert(sp->s_version == V3);
+ zone = (zone_t) conv4(sp->s_native, (long) b_v2_ind(bp)[index]);
if (zone != NO_ZONE &&
(zone < (zone_t) sp->s_firstdatazone || zone >= sp->s_zones)) {
else
len = cp - (dp->mfs_d_name);
- /* Compute record length */
- reclen = offsetof(struct dirent, d_name) + len + 1;
- o = (reclen % sizeof(long));
- if (o != 0)
- reclen += sizeof(long) - o;
+ /* Compute record length; also does alignment. */
+ reclen = _DIRENT_RECLEN(dep, len);
/* Need the position of this entry in the directory */
ent_pos = block_pos + ((char *) dp - (char *) bp->data);
}
dep = (struct dirent *) &getdents_buf[tmpbuf_off];
- dep->d_ino = (ino_t) dp->mfs_d_ino;
- dep->d_off = (off_t) ent_pos;
+ dep->d_fileno = (ino_t) dp->mfs_d_ino;
dep->d_reclen = (unsigned short) reclen;
+ dep->d_namlen = len;
memcpy(dep->d_name, dp->mfs_d_name, len);
+ {
+ struct inode *entrip;
+ if(!(entrip = get_inode(fs_dev, dep->d_fileno)))
+ panic("unexpected get_inode failure");
+ dep->d_type = fs_mode_to_type(entrip->i_mode);
+ put_inode(entrip);
+ }
dep->d_name[len] = '\0';
tmpbuf_off += reclen;
}
#include <minix/com.h>
#include <minix/u64.h>
#include <minix/bdev.h>
+#include <machine/vmparam.h>
#include "buf.h"
#include "inode.h"
#include "super.h"
+ sizeof(sp->LAST_ONDISK_FIELD);
assert(ondisk_bytes > 0);
- assert(ondisk_bytes < _MIN_BLOCK_SIZE);
+ assert(ondisk_bytes < PAGE_SIZE);
assert(ondisk_bytes < sizeof(struct super_block));
if (sp->s_dev == NO_DEV)
* disk block.
*/
assert(lmfs_fs_block_size() >= sizeof(struct super_block) + SUPER_BLOCK_BYTES);
- assert(lmfs_fs_block_size() >= _MIN_BLOCK_SIZE + SUPER_BLOCK_BYTES);
assert(SUPER_BLOCK_BYTES >= sizeof(struct super_block));
assert(SUPER_BLOCK_BYTES >= ondisk_bytes);
if(!(bp = get_block(sp->s_dev, 0, NORMAL)))
sbbuf = (char *) b_data(bp) + SUPER_BLOCK_BYTES;
if(writing) {
- memset(sbbuf, 0, _MIN_BLOCK_SIZE);
+ memset(b_data(bp), 0, lmfs_fs_block_size());
memcpy(sbbuf, sp, ondisk_bytes);
lmfs_markdirty(bp);
} else {
magic = sp->s_magic; /* determines file system type */
- /* Get file system version and type. */
- if (magic == SUPER_MAGIC || magic == conv2(BYTE_SWAP, SUPER_MAGIC)) {
- version = V1;
- native = (magic == SUPER_MAGIC);
- } else if (magic == SUPER_V2 || magic == conv2(BYTE_SWAP, SUPER_V2)) {
- version = V2;
- native = (magic == SUPER_V2);
- } else if (magic == SUPER_V3) {
- version = V3;
- native = 1;
- } else {
- return(EINVAL);
+ /* Get file system version and type - only support v3. */
+ if(magic != SUPER_V3) {
+ printf("MFS: only supports V3 filesystems.\n");
+ return EINVAL;
}
+ version = V3;
+ native = 1;
/* If the super block has the wrong byte order, swap the fields; the magic
* number doesn't need conversion. */
sp->s_max_size = (off_t) conv4(native, sp->s_max_size);
sp->s_zones = (zone_t)conv4(native, sp->s_zones);
- /* In V1, the device size was kept in a short, s_nzones, which limited
- * devices to 32K zones. For V2, it was decided to keep the size as a
- * long. However, just changing s_nzones to a long would not work, since
- * then the position of s_magic in the super block would not be the same
- * in V1 and V2 file systems, and there would be no way to tell whether
- * a newly mounted file system was V1 or V2. The solution was to introduce
- * a new variable, s_zones, and copy the size there.
- *
- * Calculate some other numbers that depend on the version here too, to
+ /* Calculate some other numbers that depend on the version here too, to
* hide some of the differences.
*/
- if (version == V1) {
- sp->s_block_size = _STATIC_BLOCK_SIZE;
- sp->s_zones = (zone_t) sp->s_nzones; /* only V1 needs this copy */
- sp->s_inodes_per_block = V1_INODES_PER_BLOCK;
- sp->s_ndzones = V1_NR_DZONES;
- sp->s_nindirs = V1_INDIRECTS;
- } else {
- if (version == V2) {
- sp->s_block_size = _STATIC_BLOCK_SIZE;
- } else {
- sp->s_block_size = (unsigned short)
- conv2(native,(int) sp->s_block_size);
- }
- if (sp->s_block_size < _MIN_BLOCK_SIZE) {
- return EINVAL;
- }
- sp->s_inodes_per_block = V2_INODES_PER_BLOCK(sp->s_block_size);
- sp->s_ndzones = V2_NR_DZONES;
- sp->s_nindirs = V2_INDIRECTS(sp->s_block_size);
+ assert(version == V3);
+ sp->s_block_size = (unsigned short) conv2(native,(int) sp->s_block_size);
+ if (sp->s_block_size < PAGE_SIZE) {
+ return EINVAL;
}
+ sp->s_inodes_per_block = V2_INODES_PER_BLOCK(sp->s_block_size);
+ sp->s_ndzones = V2_NR_DZONES;
+ sp->s_nindirs = V2_INDIRECTS(sp->s_block_size);
/* For even larger disks, a similar problem occurs with s_firstdatazone.
* If the on-disk field contains zero, we assume that the value was too
sp->s_firstdatazone = (zone_t) sp->s_firstdatazone_old;
}
- if (sp->s_block_size < _MIN_BLOCK_SIZE)
+ if (sp->s_block_size < PAGE_SIZE)
return(EINVAL);
if ((sp->s_block_size % 512) != 0)
if (SUPER_SIZE > sp->s_block_size)
return(EINVAL);
- if ((sp->s_block_size % V2_INODE_SIZE) != 0 ||
- (sp->s_block_size % V1_INODE_SIZE) != 0) {
+ if ((sp->s_block_size % V2_INODE_SIZE) != 0) {
return(EINVAL);
}
/* The following items are valid on disk only for V3 and above */
- /* The block size in bytes. Minimum MIN_BLOCK SIZE. SECTOR_SIZE
- * multiple. If V1 or V2 filesystem, this should be
- * initialised to STATIC_BLOCK_SIZE.
- */
short s_pad2; /* try to avoid compiler-dependent padding */
unsigned short s_block_size; /* block size in bytes. */
char s_disk_version; /* filesystem format sub-version */
#include <minix/libminixfs.h>
-/* Declaration of the V1 inode as it is on the disk (not in core). */
-typedef struct { /* V1.x disk inode */
- u16_t d1_mode; /* file type, protection, etc. */
- i16_t d1_uid; /* user id of the file's owner */
- i32_t d1_size; /* current file size in bytes */
- i32_t d1_mtime; /* when was file data last changed */
- u8_t d1_gid; /* group number */
- u8_t d1_nlinks; /* how many links to this file */
- u16_t d1_zone[V1_NR_TZONES]; /* block nums for direct, ind, and dbl ind */
-} d1_inode;
-
/* Declaration of the V2 inode as it is on the disk (not in core). */
typedef struct { /* V2.x disk inode */
u16_t d2_mode; /* file type, protection, etc. */
#define MYASSERT(c) if(!(c)) { printf("MFS:%s:%d: sanity check: %s failed\n", \
file, line, #c); panic("sanity check " #c " failed: %d", __LINE__); }
-
-/*===========================================================================*
- * sanity_check *
- *===========================================================================*/
-void sanitycheck(char *file, int line)
-{
- MYASSERT(SELF_E > 0);
- if(superblock.s_dev != NO_DEV) {
- MYASSERT(superblock.s_dev == fs_dev);
- MYASSERT(superblock.s_block_size == lmfs_fs_block_size());
- } else {
- MYASSERT(_MIN_BLOCK_SIZE == lmfs_fs_block_size());
- }
-}
-
sp = get_super(lmfs_dev(bp)); /* need super block to find file sys type */
/* write a zone into an indirect block */
- if (sp->s_version == V1)
- b_v1_ind(bp)[index] = (zone1_t) conv2(sp->s_native, (int) zone);
- else
- b_v2_ind(bp)[index] = (zone_t) conv4(sp->s_native, (long) zone);
+ assert(sp->s_version == V3);
+ b_v2_ind(bp)[index] = (zone_t) conv4(sp->s_native, (long) zone);
}
CPPFLAGS+= -I${NETBSDSRCDIR} -I${NETBSDSRCDIR}/servers
-DPADD+= ${LIBVTREEFS}
-LDADD+= -lvtreefs
+DPADD+= ${LIBVTREEFS} ${LIBMINLIB}
+LDADD+= -lvtreefs -lminlib
MAN=
#include <fcntl.h>
#include <lib.h>
#include <minix/timers.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include <minix/callnr.h>
#include <minix/type.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include <sys/exec.h>
#include <sys/param.h>
#include "path.h"
off_t pos, new_pos;
char *sp, *interp = NULL;
unsigned int cum_io;
- char buf[_MAX_BLOCK_SIZE];
+ char buf[PAGE_SIZE];
/* Make 'path' the new argv[0]. */
if (!insert_arg(stack, stk_bytes, path, vsp, REPLACE)) return(ENOMEM);
/* Issue request */
r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, pos, READING, VFS_PROC_NR,
- (vir_bytes) buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io);
+ (vir_bytes) buf, sizeof(buf), &new_pos, &cum_io);
if (r != OK) return(r);
n = vp->v_size;
- if (n > _MAX_BLOCK_SIZE)
- n = _MAX_BLOCK_SIZE;
+ if (n > sizeof(buf))
+ n = sizeof(buf);
if (n < 2) return ENOEXEC;
sp = &(buf[2]); /* just behind the #! */
#include <minix/com.h>
#include <minix/callnr.h>
#include <minix/vfsif.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include <assert.h>
#include "file.h"
#include "path.h"
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mount.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include <assert.h>
#include "file.h"
#include <minix/vfsif.h>
#include "scratchpad.h"
#include "lock.h"
#include "param.h"
-#include <dirent.h>
+#include <sys/dirent.h>
#include <assert.h>
#include <minix/vfsif.h>
#include "vnode.h"
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/un.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include "vmnt.h"
#include "vnode.h"
#include "path.h"
if(cur->d_name + name_len+1 > &buf[sizeof(buf)])
return(EINVAL); /* Rubbish in dir entry */
- if (entry->v_inode_nr == cur->d_ino) {
+ if (entry->v_inode_nr == cur->d_fileno) {
/* found the entry we were looking for */
int copylen = MIN(name_len + 1, NAME_MAX + 1);
if (strlcpy(ename, cur->d_name, copylen) >= copylen) {
#include <minix/u64.h>
#include <minix/vfsif.h>
#include <assert.h>
-#include <dirent.h>
+#include <sys/dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include "file.h"
SUBDIR= arch dev \
net netinet netinet6 \
\
- sys ufs
+ sys ufs uvm
.if !defined(__MINIX)
# LSC the test is OR, but as it is not relevant to MINIX, we have
elf_machdep.h endian.h endian_machdep.h \
float.h \
ieee.h ieeefp.h \
- int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
+ proc.h int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
\
limits.h lock.h \
math.h mcontext.h mutex.h \
--- /dev/null
+/* $NetBSD: proc.h,v 1.12 2012/08/16 17:35:01 matt Exp $ */
+
+/*
+ * Copyright (c) 1994 Mark Brinicombe.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the RiscBSD team.
+ * 4. The name "RiscBSD" nor the name of the author may be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM32_PROC_H_
+#define _ARM32_PROC_H_
+
+/*
+ * Machine-dependent part of the proc structure for arm.
+ */
+
+struct trapframe;
+struct lwp;
+
+struct mdlwp {
+ struct trapframe *md_tf;
+ int md_flags;
+};
+
+/* Flags setttings for md_flags */
+#define MDLWP_VFPUSED 0x00000001 /* Process used the VFP */
+#define MDLWP_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */
+
+
+struct mdproc {
+ void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t);
+ int pmc_enabled; /* bitfield of enabled counters */
+ void *pmc_state; /* port-specific pmc state */
+};
+
+#endif /* _ARM32_PROC_H_ */
\
limits.h lock.h \
math.h mcontext.h mutex.h \
- param.h profile.h \
+ param.h proc.h profile.h \
rwlock.h \
setjmp.h signal.h \
types.h \
--- /dev/null
+/* $NetBSD: proc.h,v 1.1 2001/11/25 15:56:05 thorpej Exp $ */
+
+#include <arm/proc.h>
cdefs.h cpu.h \
disklabel.h \
elf_machdep.h endian.h endian_machdep.h \
- fenv.h float.h \
- \
+ fenv.h float.h proc.h frame.h pcb.h segments.h tss.h sysarch.h \
+ lock.h \
ieee.h ieeefp.h \
int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
\
--- /dev/null
+/* $NetBSD: frame.h,v 1.35 2012/02/19 21:06:11 rmind Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)frame.h 5.2 (Berkeley) 1/18/91
+ */
+
+#ifndef _I386_FRAME_H_
+#define _I386_FRAME_H_
+
+#include <sys/signal.h>
+
+/*
+ * System stack frames.
+ */
+
+/*
+ * Exception/Trap Stack Frame
+ */
+struct trapframe {
+ uint16_t tf_gs;
+ uint16_t tf_gs_pad;
+ uint16_t tf_fs;
+ uint16_t tf_fs_pad;
+ uint16_t tf_es;
+ uint16_t tf_es_pad;
+ uint16_t tf_ds;
+ uint16_t tf_ds_pad;
+ int tf_edi;
+ int tf_esi;
+ int tf_ebp;
+ int tf_ebx;
+ int tf_edx;
+ int tf_ecx;
+ int tf_eax;
+ int tf_trapno;
+ /* below portion defined in 386 hardware */
+ int tf_err;
+ int tf_eip;
+ int tf_cs;
+ int tf_eflags;
+ /* below used when transitting rings (e.g. user to kernel) */
+ int tf_esp;
+ int tf_ss;
+ /* below used when switching out of VM86 mode */
+ int tf_vm86_es;
+ int tf_vm86_ds;
+ int tf_vm86_fs;
+ int tf_vm86_gs;
+};
+
+/*
+ * Interrupt stack frame
+ */
+struct intrframe {
+ int if_ppl;
+ int if_gs;
+ int if_fs;
+ int if_es;
+ int if_ds;
+ int if_edi;
+ int if_esi;
+ int if_ebp;
+ int if_ebx;
+ int if_edx;
+ int if_ecx;
+ int if_eax;
+ uint32_t __if_trapno; /* for compat with trap frame - trapno */
+ uint32_t __if_err; /* for compat with trap frame - err */
+ /* below portion defined in 386 hardware */
+ int if_eip;
+ int if_cs;
+ int if_eflags;
+ /* below only when transitting rings (e.g. user to kernel) */
+ int if_esp;
+ int if_ss;
+};
+
+/*
+ * Stack frame inside cpu_switchto()
+ */
+struct switchframe {
+ int sf_edi;
+ int sf_esi;
+ int sf_ebx;
+ int sf_eip;
+};
+
+#ifdef _KERNEL
+/*
+ * Old-style signal frame
+ */
+struct sigframe_sigcontext {
+ int sf_ra; /* return address for handler */
+ int sf_signum; /* "signum" argument for handler */
+ int sf_code; /* "code" argument for handler */
+ struct sigcontext *sf_scp; /* "scp" argument for handler */
+ struct sigcontext sf_sc; /* actual saved context */
+};
+#endif
+
+/*
+ * New-style signal frame
+ */
+struct sigframe_siginfo {
+ int sf_ra; /* return address for handler */
+ int sf_signum; /* "signum" argument for handler */
+ siginfo_t *sf_sip; /* "sip" argument for handler */
+ ucontext_t *sf_ucp; /* "ucp" argument for handler */
+ siginfo_t sf_si; /* actual saved siginfo */
+ ucontext_t sf_uc; /* actual saved ucontext */
+};
+
+#ifdef _KERNEL
+void *getframe(struct lwp *, int, int *);
+void buildcontext(struct lwp *, int, void *, void *);
+void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
+#endif
+
+#endif /* _I386_FRAME_H_ */
--- /dev/null
+/* $NetBSD: lock.h,v 1.9 2003/02/27 00:12:22 fvdl Exp $ */
+
+#include <x86/lock.h>
#ifndef _I386_NPX_H_
#define _I386_NPX_H_
-#ifndef __minix
/* Environment information of floating point unit */
struct env87 {
long en_cw; /* control word (16bits) */
struct save87 sv_87;
struct savexmm sv_xmm;
};
-#endif /* !__minix */
/*
* The i387 defaults to Intel extended precision mode and round to nearest,
--- /dev/null
+/* $NetBSD: pcb.h,v 1.48 2010/04/23 16:07:33 joerg Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pcb.h 5.10 (Berkeley) 5/12/91
+ */
+
+/*
+ * Intel 386 process control block
+ */
+
+#ifndef _I386_PCB_H_
+#define _I386_PCB_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_multiprocessor.h"
+#endif
+
+#include <sys/signal.h>
+
+#include <machine/segments.h>
+#include <machine/tss.h>
+#include <i386/npx.h>
+#include <i386/sysarch.h>
+
+struct pcb {
+ int pcb_esp0; /* ring0 esp */
+ int pcb_esp; /* kernel esp */
+ int pcb_ebp; /* kernel ebp */
+ int pcb_unused; /* unused */
+ int pcb_cr0; /* saved image of CR0 */
+ int pcb_cr2; /* page fault address (CR2) */
+ int pcb_cr3; /* page directory pointer */
+ int pcb_iopl; /* i/o privilege level */
+
+ /* floating point state for FPU */
+ union savefpu pcb_savefpu __aligned(16);
+
+ struct segment_descriptor pcb_fsd; /* %fs descriptor */
+ struct segment_descriptor pcb_gsd; /* %gs descriptor */
+ void * pcb_onfault; /* copyin/out fault recovery */
+ int vm86_eflags; /* virtual eflags for vm86 mode */
+ int vm86_flagmask; /* flag mask for vm86 mode */
+ void *vm86_userp; /* XXX performance hack */
+ struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
+ char *pcb_iomap; /* I/O permission bitmap */
+};
+
+/*
+ * The pcb is augmented with machine-dependent additional data for
+ * core dumps. For the i386, there is nothing to add.
+ */
+struct md_coredump {
+ long md_pad[8];
+};
+
+#endif /* _I386_PCB_H_ */
--- /dev/null
+/* $NetBSD: proc.h,v 1.38 2011/01/14 02:06:26 rmind Exp $ */
+
+/*
+ * Copyright (c) 1991 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)proc.h 7.1 (Berkeley) 5/15/91
+ */
+
+#ifndef _I386_PROC_H_
+#define _I386_PROC_H_
+
+#include <machine/frame.h>
+#include <machine/pcb.h>
+
+/*
+ * Machine-dependent part of the lwp structure for i386.
+ */
+struct pmap;
+struct vm_page;
+
+struct mdlwp {
+ struct trapframe *md_regs; /* registers on current frame */
+ int md_flags; /* machine-dependent flags */
+ volatile int md_astpending; /* AST pending for this process */
+ struct pmap *md_gc_pmap; /* pmap being garbage collected */
+ struct vm_page *md_gc_ptp; /* pages from pmap g/c */
+};
+
+/* md_flags */
+#define MDL_USEDFPU 0x0001 /* has used the FPU */
+#define MDL_IOPL 0x0002 /* XEN: i/o privilege */
+
+struct mdproc {
+ int md_flags;
+ void (*md_syscall)(struct trapframe *);
+ /* Syscall handling function */
+};
+
+/* md_flags */
+#define MDP_USEDMTRR 0x0002 /* has set volatile MTRRs */
+
+/* Kernel stack parameters. */
+#define UAREA_PCB_OFFSET (USPACE - ALIGN(sizeof(struct pcb)))
+#define KSTACK_LOWEST_ADDR(l) \
+ ((void *)((vaddr_t)(l)->l_addr - UAREA_PCB_OFFSET))
+#define KSTACK_SIZE UAREA_PCB_OFFSET
+
+#endif /* _I386_PROC_H_ */
--- /dev/null
+/* $NetBSD: segments.h,v 1.54 2011/04/26 15:51:23 joerg Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)segments.h 7.1 (Berkeley) 5/9/91
+ */
+
+/*-
+ * Copyright (c) 1995, 1997
+ * Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1989, 1990 William F. Jolitz
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)segments.h 7.1 (Berkeley) 5/9/91
+ */
+
+/*
+ * 386 Segmentation Data Structures and definitions
+ * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989
+ */
+
+#ifndef _I386_SEGMENTS_H_
+#define _I386_SEGMENTS_H_
+#ifdef _KERNEL_OPT
+#include "opt_xen.h"
+#endif
+
+/*
+ * Selectors
+ */
+
+#define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */
+#ifndef XEN
+#define SEL_KPL 0 /* kernel privilege level */
+#else
+#define SEL_XEN 0 /* Xen privilege level */
+#define SEL_KPL 1 /* kernel privilege level */
+#endif /* XEN */
+#define SEL_UPL 3 /* user privilege level */
+#define SEL_RPL 3 /* requester's privilege level mask */
+#ifdef XEN
+#define CHK_UPL 2 /* user privilege level mask */
+#else
+#define CHK_UPL SEL_RPL
+#endif /* XEN */
+#define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */
+#define SEL_LDT 4 /* local descriptor table */
+#define IDXSEL(s) (((s) >> 3) & 0x1fff) /* index of selector */
+#define IDXSELN(s) (((s) >> 3)) /* index of selector */
+#define GSEL(s,r) (((s) << 3) | r) /* a global selector */
+#define LSEL(s,r) (((s) << 3) | r | SEL_LDT) /* a local selector */
+#define GSYSSEL(s,r) GSEL(s,r) /* compat with amd64 */
+
+#if defined(_KERNEL_OPT)
+#include "opt_vm86.h"
+#endif
+
+#ifdef VM86
+#define USERMODE(c, f) (ISPL(c) == SEL_UPL || ((f) & PSL_VM) != 0)
+#define KERNELMODE(c, f) (ISPL(c) == SEL_KPL && ((f) & PSL_VM) == 0)
+#else
+#define USERMODE(c, f) (ISPL(c) == SEL_UPL)
+#define KERNELMODE(c, f) (ISPL(c) == SEL_KPL)
+#endif
+
+#ifndef _LOCORE
+
+#if __GNUC__ == 2 && __GNUC_MINOR__ < 7
+#pragma pack(1)
+#endif
+
+/*
+ * Memory and System segment descriptors
+ */
+struct segment_descriptor {
+ unsigned sd_lolimit:16; /* segment extent (lsb) */
+ unsigned sd_lobase:24; /* segment base address (lsb) */
+ unsigned sd_type:5; /* segment type */
+ unsigned sd_dpl:2; /* segment descriptor priority level */
+ unsigned sd_p:1; /* segment descriptor present */
+ unsigned sd_hilimit:4; /* segment extent (msb) */
+ unsigned sd_xx:2; /* unused */
+ unsigned sd_def32:1; /* default 32 vs 16 bit size */
+ unsigned sd_gran:1; /* limit granularity (byte/page) */
+ unsigned sd_hibase:8; /* segment base address (msb) */
+} __packed;
+
+/*
+ * Gate descriptors (e.g. indirect descriptors)
+ */
+struct gate_descriptor {
+ unsigned gd_looffset:16; /* gate offset (lsb) */
+ unsigned gd_selector:16; /* gate segment selector */
+ unsigned gd_stkcpy:5; /* number of stack wds to cpy */
+ unsigned gd_xx:3; /* unused */
+ unsigned gd_type:5; /* segment type */
+ unsigned gd_dpl:2; /* segment descriptor priority level */
+ unsigned gd_p:1; /* segment descriptor present */
+ unsigned gd_hioffset:16; /* gate offset (msb) */
+} __packed;
+
+struct ldt_descriptor {
+ vaddr_t ld_base;
+ uint32_t ld_entries;
+} __packed;
+
+/*
+ * Generic descriptor
+ */
+union descriptor {
+ struct segment_descriptor sd;
+ struct gate_descriptor gd;
+ struct ldt_descriptor ld;
+ uint32_t raw[2];
+ uint64_t raw64;
+} __packed;
+
+/*
+ * region descriptors, used to load gdt/idt tables before segments yet exist.
+ */
+struct region_descriptor {
+ unsigned rd_limit:16; /* segment extent */
+ unsigned rd_base:32; /* base address */
+} __packed;
+
+#if __GNUC__ == 2 && __GNUC_MINOR__ < 7
+#pragma pack(4)
+#endif
+
+#ifdef _KERNEL
+extern union descriptor *gdt, *ldt;
+extern struct gate_descriptor *idt;
+
+void setgate(struct gate_descriptor *, void *, int, int, int, int);
+void setregion(struct region_descriptor *, void *, size_t);
+void setsegment(struct segment_descriptor *, const void *, size_t, int, int,
+ int, int);
+void setgdt(int, const void *, size_t, int, int, int, int);
+void unsetgate(struct gate_descriptor *);
+void cpu_init_idt(void);
+void update_descriptor(union descriptor *, union descriptor *);
+
+#if !defined(XEN)
+void idt_init(void);
+void idt_vec_reserve(int);
+int idt_vec_alloc(int, int);
+void idt_vec_set(int, void (*)(void));
+void idt_vec_free(int);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_LOCORE */
+
+/* system segments and gate types */
+#define SDT_SYSNULL 0 /* system null */
+#define SDT_SYS286TSS 1 /* system 286 TSS available */
+#define SDT_SYSLDT 2 /* system local descriptor table */
+#define SDT_SYS286BSY 3 /* system 286 TSS busy */
+#define SDT_SYS286CGT 4 /* system 286 call gate */
+#define SDT_SYSTASKGT 5 /* system task gate */
+#define SDT_SYS286IGT 6 /* system 286 interrupt gate */
+#define SDT_SYS286TGT 7 /* system 286 trap gate */
+#define SDT_SYSNULL2 8 /* system null again */
+#define SDT_SYS386TSS 9 /* system 386 TSS available */
+#define SDT_SYSNULL3 10 /* system null again */
+#define SDT_SYS386BSY 11 /* system 386 TSS busy */
+#define SDT_SYS386CGT 12 /* system 386 call gate */
+#define SDT_SYSNULL4 13 /* system null again */
+#define SDT_SYS386IGT 14 /* system 386 interrupt gate */
+#define SDT_SYS386TGT 15 /* system 386 trap gate */
+
+/* memory segment types */
+#define SDT_MEMRO 16 /* memory read only */
+#define SDT_MEMROA 17 /* memory read only accessed */
+#define SDT_MEMRW 18 /* memory read write */
+#define SDT_MEMRWA 19 /* memory read write accessed */
+#define SDT_MEMROD 20 /* memory read only expand dwn limit */
+#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */
+#define SDT_MEMRWD 22 /* memory read write expand dwn limit */
+#define SDT_MEMRWDA 23 /* memory read write expand dwn limit acessed */
+#define SDT_MEME 24 /* memory execute only */
+#define SDT_MEMEA 25 /* memory execute only accessed */
+#define SDT_MEMER 26 /* memory execute read */
+#define SDT_MEMERA 27 /* memory execute read accessed */
+#define SDT_MEMEC 28 /* memory execute only conforming */
+#define SDT_MEMEAC 29 /* memory execute only accessed conforming */
+#define SDT_MEMERC 30 /* memory execute read conforming */
+#define SDT_MEMERAC 31 /* memory execute read accessed conforming */
+
+#define SDTYPE(p) (((const struct segment_descriptor *)(p))->sd_type)
+/* is memory segment descriptor pointer ? */
+#define ISMEMSDP(s) (SDTYPE(s) >= SDT_MEMRO && \
+ SDTYPE(s) <= SDT_MEMERAC)
+
+/* is 286 gate descriptor pointer ? */
+#define IS286GDP(s) (SDTYPE(s) >= SDT_SYS286CGT && \
+ SDTYPE(s) < SDT_SYS286TGT)
+
+/* is 386 gate descriptor pointer ? */
+#define IS386GDP(s) (SDTYPE(s) >= SDT_SYS386CGT && \
+ SDTYPE(s) < SDT_SYS386TGT)
+
+/* is gate descriptor pointer ? */
+#define ISGDP(s) (IS286GDP(s) || IS386GDP(s))
+
+/* is segment descriptor pointer ? */
+#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s))
+
+/* is system segment descriptor pointer ? */
+#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s))
+
+/*
+ * Segment Protection Exception code bits
+ */
+#define SEGEX_EXT 0x01 /* recursive or externally induced */
+#define SEGEX_IDT 0x02 /* interrupt descriptor table */
+#define SEGEX_TI 0x04 /* local descriptor table */
+
+/*
+ * Entries in the Interrupt Descriptor Table (IDT)
+ */
+#define NIDT 256
+#define NRSVIDT 32 /* reserved entries for CPU exceptions */
+
+/*
+ * Entries in the Global Descriptor Table (GDT).
+ *
+ * NB: If you change GBIOSCODE/GBIOSDATA, you *must* rebuild arch/i386/
+ * bioscall/biostramp.inc, as that relies on GBIOSCODE/GBIOSDATA and a
+ * normal kernel build does not rebuild it (it's merely included whole-
+ * sale from i386/bioscall.s)
+ *
+ * Also, note that the GEXTBIOSDATA_SEL selector is special, as it maps
+ * to the value 0x0040 (when created as a KPL global selector). Some
+ * BIOSes reference the extended BIOS data area at segment 0040 in a non
+ * relocatable fashion (even when in protected mode); mapping the zero page
+ * via the GEXTBIOSDATA_SEL allows these buggy BIOSes to continue to work
+ * under NetBSD.
+ *
+ * The order if the first 5 descriptors is special; the sysenter/sysexit
+ * instructions depend on them.
+ */
+#define GNULL_SEL 0 /* Null descriptor */
+#define GCODE_SEL 1 /* Kernel code descriptor */
+#define GDATA_SEL 2 /* Kernel data descriptor */
+#define GUCODE_SEL 3 /* User code descriptor */
+#define GUDATA_SEL 4 /* User data descriptor */
+#define GLDT_SEL 5 /* Default LDT descriptor */
+#define GCPU_SEL 6 /* per-CPU segment */
+#define GEXTBIOSDATA_SEL 8 /* magic to catch BIOS refs to EBDA */
+#define GAPM32CODE_SEL 9 /* 3 APM segments must be consecutive */
+#define GAPM16CODE_SEL 10 /* and in the specified order: code32 */
+#define GAPMDATA_SEL 11 /* code16 and then data per APM spec */
+#define GBIOSCODE_SEL 12
+#define GBIOSDATA_SEL 13
+#define GPNPBIOSCODE_SEL 14
+#define GPNPBIOSDATA_SEL 15
+#define GPNPBIOSSCRATCH_SEL 16
+#define GPNPBIOSTRAMP_SEL 17
+#define GTRAPTSS_SEL 18
+#define GIPITSS_SEL 19
+#define GUCODEBIG_SEL 20 /* User code with executable stack */
+#define GUFS_SEL 21 /* Per-thread %fs */
+#define GUGS_SEL 22 /* Per-thread %gs */
+#define NGDT 23
+
+/*
+ * Entries in the Local Descriptor Table (LDT).
+ * DO NOT ADD KERNEL DATA/CODE SEGMENTS TO THIS TABLE.
+ */
+#define LSYS5CALLS_SEL 0 /* iBCS system call gate */
+#define LSYS5SIGR_SEL 1 /* iBCS sigreturn gate */
+#define LUCODE_SEL 2 /* User code descriptor */
+#define LUDATA_SEL 3 /* User data descriptor */
+#define LSOL26CALLS_SEL 4 /* Solaris 2.6 system call gate */
+#define LUCODEBIG_SEL 5 /* User code with executable stack */
+#define LBSDICALLS_SEL 16 /* BSDI system call gate */
+#define NLDT 17
+
+#endif /* _I386_SEGMENTS_H_ */
--- /dev/null
+/* $NetBSD: sysarch.h,v 1.18 2007/04/16 19:12:19 ad Exp $ */
+
+#include <x86/sysarch.h>
--- /dev/null
+/* $NetBSD: tss.h,v 1.10 2008/01/05 21:45:00 yamt Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tss.h 5.4 (Berkeley) 1/18/91
+ */
+
+#ifndef _I386_TSS_H_
+#define _I386_TSS_H_
+
+/*
+ * Intel 386 Context Data Type
+ */
+
+struct i386tss {
+ int __tss_link;
+ int tss_esp0; /* kernel stack pointer at privilege level 0 */
+ int tss_ss0; /* kernel stack segment at privilege level 0 */
+ int __tss_esp1;
+ int __tss_ss1;
+ int __tss_esp2;
+ int __tss_ss2;
+ int tss_cr3; /* page directory paddr */
+ int __tss_eip;
+ int __tss_eflags;
+ int __tss_eax;
+ int __tss_ecx;
+ int __tss_edx;
+ int __tss_ebx;
+ int tss_esp; /* saved stack pointer */
+ int tss_ebp; /* saved frame pointer */
+ int __tss_esi;
+ int __tss_edi;
+ int __tss_es;
+ int __tss_cs;
+ int __tss_ss;
+ int __tss_ds;
+ int tss_fs; /* saved segment register */
+ int tss_gs; /* saved segment register */
+ int tss_ldt; /* LDT selector */
+ int tss_iobase; /* options and I/O permission map offset */
+};
+
+/*
+ * I/O bitmap offset beyond TSS's segment limit means no bitmaps.
+ * (i.e. any I/O attempt generates an exception.)
+ */
+#define IOMAP_INVALOFF 0xffff
+
+#endif /* #ifndef _I386_TSS_H_ */
INCSDIR= /usr/include/sys
-INCS= ansi.h atomic.h \
- bitops.h bootblock.h bswap.h \
- cdefs.h cdefs_aout.h \
- cdefs_elf.h condvar.h \
- ctype_bits.h ctype_inline.h \
- \
- dirent.h \
- disk.h disklabel.h disklabel_acorn.h disklabel_gpt.h \
- dkbad.h dkio.h \
- endian.h errno.h exec.h \
- exec_elf.h extattr.h \
- fcntl.h fd_set.h featuretest.h file.h \
- float_ieee754.h fstypes.h gcq.h gmon.h hash.h \
- ieee754.h inttypes.h ioccom.h ioctl.h iostat.h ipc.h \
- \
- lwp.h \
- localedef.h lock.h \
- md4.h md5.h \
- mman.h mount.h mtio.h mutex.h \
- null.h \
- param.h poll.h \
- ptrace.h ptree.h \
- queue.h \
- ras.h rbtree.h reboot.h resource.h rmd160.h \
- rwlock.h \
- select.h sem.h sha1.h \
- sha2.h shm.h siginfo.h signal.h sigtypes.h \
- socket.h specificdata.h \
- stat.h \
- statvfs.h sysctl.h stdarg.h stdint.h \
- syslimits.h syslog.h \
- termios.h time.h times.h \
- tls.h tree.h ttycom.h \
- ttydefaults.h types.h \
- ucontext.h ucred.h uio.h un.h unistd.h utsname.h uuid.h \
- \
- wait.h
+INCS= acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
+ bitops.h bootblock.h bswap.h buf.h \
+ callback.h callout.h cdefs.h cdefs_aout.h \
+ cdefs_elf.h cdio.h chio.h clockctl.h condvar.h conf.h core.h \
+ cpufreq.h cpuio.h ctype_bits.h ctype_inline.h \
+ device.h device_if.h \
+ dir.h dirent.h \
+ disk.h disklabel.h disklabel_acorn.h disklabel_gpt.h disklabel_rdb.h \
+ dkbad.h dkio.h dkstat.h domain.h drvctlio.h dvdio.h \
+ endian.h envsys.h errno.h evcnt.h event.h exec.h exec_aout.h \
+ exec_coff.h exec_ecoff.h exec_elf.h exec_script.h extattr.h extent.h \
+ fcntl.h fd_set.h fdio.h featuretest.h file.h filedesc.h filio.h \
+ flashio.h float_ieee754.h fstypes.h gcq.h gmon.h gpio.h hash.h \
+ ieee754.h inttypes.h ioccom.h ioctl.h ioctl_compat.h iostat.h ipc.h \
+ joystick.h \
+ kcore.h kcpuset.h kgdb.h kmem.h ksem.h ksyms.h ktrace.h \
+ localedef.h lock.h lockf.h lwp.h lwpctl.h \
+ malloc.h mallocvar.h mbuf.h md4.h md5.h midiio.h \
+ mman.h module.h mount.h mqueue.h msg.h msgbuf.h mtio.h mutex.h \
+ namei.h null.h \
+ param.h pcu.h pipe.h pmc.h poll.h pool.h power.h proc.h \
+ protosw.h pset.h ptrace.h ptree.h \
+ queue.h quota.h quotactl.h \
+ ras.h rbtree.h reboot.h radioio.h resource.h resourcevar.h rmd160.h \
+ rnd.h rwlock.h \
+ scanio.h sched.h scsiio.h sdt.h select.h selinfo.h sem.h sha1.h \
+ sha2.h shm.h siginfo.h signal.h signalvar.h sigtypes.h simplelock.h \
+ sleepq.h socket.h \
+ socketvar.h sockio.h spawn.h specificdata.h stat.h \
+ statvfs.h syscall.h syscallargs.h sysctl.h stdarg.h stdint.h swap.h \
+ syncobj.h syslimits.h syslog.h \
+ tape.h termios.h time.h timeb.h timepps.h times.h \
+ timex.h tls.h trace.h tree.h tty.h ttychars.h ttycom.h \
+ ttydefaults.h ttydev.h types.h \
+ ucontext.h ucred.h uio.h un.h unistd.h unpcb.h user.h utsname.h uuid.h \
+ vadvise.h verified_exec.h videoio.h vmmeter.h vnode.h vnode_if.h \
+ wait.h wapbl.h wapbl_replay.h wdog.h xattr.h
INCSYMLINKS=\
sys/exec_elf.h /usr/include/elf.h \
sys/md4.h /usr/include/md4.h \
sys/md5.h /usr/include/md5.h
-#INCSYMLINKS+= ../soundcard.h ${INCSDIR}/soundcard.h
+INCSYMLINKS+= ../soundcard.h ${INCSDIR}/soundcard.h
namei: namei.src gennameih.awk
${TOOL_AWK} -f gennameih.awk < namei.src
--- /dev/null
+/* $NetBSD: acct.h,v 1.27 2009/01/11 02:45:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)acct.h 8.3 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_ACCT_H_
+#define _SYS_ACCT_H_
+
+/*
+ * Accounting structures; these use a comp_t type which is a 3 bits base 8
+ * exponent, 13 bit fraction ``floating point'' number. Units are 1/AHZ
+ * seconds.
+ */
+typedef uint16_t comp_t;
+
+struct acct {
+ char ac_comm[16]; /* command name */
+ comp_t ac_utime; /* user time */
+ comp_t ac_stime; /* system time */
+ comp_t ac_etime; /* elapsed time */
+ time_t ac_btime; /* starting time */
+ uid_t ac_uid; /* user id */
+ gid_t ac_gid; /* group id */
+ uint16_t ac_mem; /* average memory usage */
+ comp_t ac_io; /* count of IO blocks */
+ dev_t ac_tty; /* controlling tty */
+
+#define AFORK 0x01 /* fork'd but not exec'd */
+#define ASU 0x02 /* used super-user permissions */
+#define ACOMPAT 0x04 /* used compatibility mode */
+#define ACORE 0x08 /* dumped core */
+#define AXSIG 0x10 /* killed by a signal */
+ uint8_t ac_flag; /* accounting flags */
+};
+
+/*
+ * 1/AHZ is the granularity of the data encoded in the comp_t fields.
+ * This is not necessarily equal to hz.
+ */
+#define AHZ 64
+
+#ifdef _KERNEL
+void acct_init(void);
+int acct_process(struct lwp *);
+#endif
+
+#endif /* !_SYS_ACCT_H_ */
--- /dev/null
+/* $NetBSD: agpio.h,v 1.10 2011/02/15 08:57:01 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/agpio.h,v 1.1 2000/06/09 16:04:30 dfr Exp $
+ */
+
+#ifndef _SYS_AGPIO_H_
+#define _SYS_AGPIO_H_
+
+/*
+ * The AGP gatt uses 4k pages irrespective of the host page size.
+ */
+#define AGP_PAGE_SIZE 4096
+#define AGP_PAGE_SHIFT 12
+
+/*
+ * Macros to manipulate AGP mode words.
+ */
+#define AGP_MODE_GET_RQ(x) (((x) & 0xff000000U) >> 24)
+#define AGP_MODE_GET_ARQSZ(x) (((x) & 0x0000e000U) >> 13)
+#define AGP_MODE_GET_CAL(x) (((x) & 0x00001c00U) >> 10)
+#define AGP_MODE_GET_SBA(x) (((x) & 0x00000200U) >> 9)
+#define AGP_MODE_GET_AGP(x) (((x) & 0x00000100U) >> 8)
+#define AGP_MODE_GET_4G(x) (((x) & 0x00000020U) >> 5)
+#define AGP_MODE_GET_FW(x) (((x) & 0x00000010U) >> 4)
+#define AGP_MODE_GET_MODE_3(x) (((x) & 0x00000008U) >> 3)
+#define AGP_MODE_GET_RATE(x) ((x) & 0x00000007U)
+#define AGP_MODE_SET_RQ(x,v) (((x) & ~0xff000000U) | ((v) << 24))
+#define AGP_MODE_SET_ARQSZ(x,v) (((x) & ~0x0000e000U) | ((v) << 13))
+#define AGP_MODE_SET_CAL(x,v) (((x) & ~0x00001c00U) | ((v) << 10))
+#define AGP_MODE_SET_SBA(x,v) (((x) & ~0x00000200U) | ((v) << 9))
+#define AGP_MODE_SET_AGP(x,v) (((x) & ~0x00000100U) | ((v) << 8))
+#define AGP_MODE_SET_4G(x,v) (((x) & ~0x00000020U) | ((v) << 5))
+#define AGP_MODE_SET_FW(x,v) (((x) & ~0x00000010U) | ((v) << 4))
+#define AGP_MODE_SET_MODE_3(x,v) (((x) & ~0x00000008U) | ((v) << 3))
+#define AGP_MODE_SET_RATE(x,v) (((x) & ~0x00000007U) | (v))
+#define AGP_MODE_V2_RATE_1x 0x00000001
+#define AGP_MODE_V2_RATE_2x 0x00000002
+#define AGP_MODE_V2_RATE_4x 0x00000004
+#define AGP_MODE_V3_RATE_4x 0x00000001
+#define AGP_MODE_V3_RATE_8x 0x00000002
+#define AGP_MODE_V3_RATE_RSVD 0x00000004
+
+/* compat */
+#define AGP_MODE_RATE_1x AGP_MODE_V2_RATE_1x
+#define AGP_MODE_RATE_2x AGP_MODE_V2_RATE_2x
+#define AGP_MODE_RATE_4x AGP_MODE_V2_RATE_4x
+
+#define AGPIOC_BASE 'A'
+#define AGPIOC_INFO _IOR (AGPIOC_BASE, 0, agp_info)
+#define AGPIOC_ACQUIRE _IO (AGPIOC_BASE, 1)
+#define AGPIOC_RELEASE _IO (AGPIOC_BASE, 2)
+#define AGPIOC_SETUP _IOW (AGPIOC_BASE, 3, agp_setup)
+#if 0
+#define AGPIOC_RESERVE _IOW (AGPIOC_BASE, 4, agp_region)
+#define AGPIOC_PROTECT _IOW (AGPIOC_BASE, 5, agp_region)
+#endif
+#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 6, agp_allocate)
+#define AGPIOC_DEALLOCATE _IOW (AGPIOC_BASE, 7, int)
+#define AGPIOC_BIND _IOW (AGPIOC_BASE, 8, agp_bind)
+#define AGPIOC_UNBIND _IOW (AGPIOC_BASE, 9, agp_unbind)
+
+typedef struct _agp_version {
+ uint16_t major;
+ uint16_t minor;
+} agp_version;
+
+typedef struct _agp_info {
+ agp_version version; /* version of the driver */
+ uint32_t bridge_id; /* bridge vendor/device */
+ uint32_t agp_mode; /* mode info of bridge */
+ off_t aper_base; /* base of aperture */
+ size_t aper_size; /* size of aperture */
+ size_t pg_total; /* max pages (swap + system) */
+ size_t pg_system; /* max pages (system) */
+ size_t pg_used; /* current pages used */
+} agp_info;
+
+typedef struct _agp_setup {
+ uint32_t agp_mode; /* mode info of bridge */
+} agp_setup;
+
+#if 0
+/*
+ * The "prot" down below needs still a "sleep" flag somehow ...
+ */
+typedef struct _agp_segment {
+ off_t pg_start; /* starting page to populate */
+ size_t pg_count; /* number of pages */
+ int prot; /* prot flags for mmap */
+} agp_segment;
+
+typedef struct _agp_region {
+ pid_t pid; /* pid of process */
+ size_t seg_count; /* number of segments */
+ struct _agp_segment *seg_list;
+} agp_region;
+#endif
+
+typedef struct _agp_allocate {
+ int key; /* tag of allocation */
+ size_t pg_count; /* number of pages */
+ uint32_t type; /* 0 == normal, other devspec */
+ uint32_t physical; /* device specific (some devices
+ * need a phys address of the
+ * actual page behind the gatt
+ * table) */
+} agp_allocate;
+
+typedef struct _agp_bind {
+ int key; /* tag of allocation */
+ off_t pg_start; /* starting page to populate */
+} agp_bind;
+
+typedef struct _agp_unbind {
+ int key; /* tag of allocation */
+ uint32_t priority; /* priority for paging out */
+} agp_unbind;
+
+#endif /* !_SYS_AGPIO_H_ */
--- /dev/null
+/* $NetBSD: aio.h,v 1.12 2012/01/07 19:48:19 christos Exp $ */
+
+/*
+ * Copyright (c) 2007, Mindaugas Rasiukevicius <rmind at NetBSD org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_AIO_H_
+#define _SYS_AIO_H_
+
+#include <sys/types.h>
+#include <sys/signal.h>
+
+/* Returned by aio_cancel() */
+#define AIO_CANCELED 0x1
+#define AIO_NOTCANCELED 0x2
+#define AIO_ALLDONE 0x3
+
+/* LIO opcodes */
+#define LIO_NOP 0x0
+#define LIO_WRITE 0x1
+#define LIO_READ 0x2
+
+/* LIO modes */
+#define LIO_NOWAIT 0x0
+#define LIO_WAIT 0x1
+
+/*
+ * Asynchronous I/O structure.
+ * Defined in the Base Definitions volume of IEEE Std 1003.1-2001 .
+ */
+struct aiocb {
+ off_t aio_offset; /* File offset */
+ volatile void *aio_buf; /* I/O buffer in process space */
+ size_t aio_nbytes; /* Length of transfer */
+ int aio_fildes; /* File descriptor */
+ int aio_lio_opcode; /* LIO opcode */
+ int aio_reqprio; /* Request priority offset */
+ struct sigevent aio_sigevent; /* Signal to deliver */
+
+ /* Internal kernel variables */
+ int _state; /* State of the job */
+ int _errno; /* Error value */
+ ssize_t _retval; /* Return value */
+};
+
+/* Internal kernel data */
+#ifdef _KERNEL
+
+/* Default limits of allowed AIO operations */
+#define AIO_LISTIO_MAX 512
+#define AIO_MAX AIO_LISTIO_MAX * 16
+
+#include <sys/condvar.h>
+#include <sys/lwp.h>
+#include <sys/mutex.h>
+#include <sys/pool.h>
+#include <sys/queue.h>
+
+/* Operations (as flags) */
+#define AIO_LIO 0x00
+#define AIO_READ 0x01
+#define AIO_WRITE 0x02
+#define AIO_SYNC 0x04
+#define AIO_DSYNC 0x08
+
+/* Job states */
+#define JOB_NONE 0x0
+#define JOB_WIP 0x1
+#define JOB_DONE 0x2
+
+/* Structure of AIO job */
+struct aio_job {
+ int aio_op; /* Operation code */
+ struct aiocb aiocbp; /* AIO data structure */
+ void *aiocb_uptr; /* User-space pointer for identification of job */
+ TAILQ_ENTRY(aio_job) list;
+ struct lio_req *lio;
+};
+
+/* LIO structure */
+struct lio_req {
+ u_int refcnt; /* Reference counter */
+ struct sigevent sig; /* Signal of lio_listio() calls */
+};
+
+/* Structure of AIO data for process */
+struct aioproc {
+ kmutex_t aio_mtx; /* Protects the entire structure */
+ kcondvar_t aio_worker_cv; /* Signals on a new job */
+ kcondvar_t done_cv; /* Signals when the job is done */
+ struct aio_job *curjob; /* Currently processing AIO job */
+ unsigned int jobs_count; /* Count of the jobs */
+ TAILQ_HEAD(, aio_job) jobs_queue;/* Queue of the AIO jobs */
+ struct lwp *aio_worker; /* AIO worker thread */
+};
+
+extern u_int aio_listio_max;
+/* Prototypes */
+void aio_print_jobs(void (*)(const char *, ...) __printflike(1, 2));
+int aio_suspend1(struct lwp *, struct aiocb **, int, struct timespec *);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_AIO_H_ */
--- /dev/null
+/* $NetBSD: aout_mids.h,v 1.1 2009/08/20 22:07:49 he Exp $ */
+
+/*
+ * Copyright (c) 2009, The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MACHINE_IDS_H_
+#define _SYS_MACHINE_IDS_H_
+
+
+/*
+ * a_mid - keep sorted in numerical order for sanity's sake
+ * ensure that: 0 < mid < 0x3ff
+ */
+#define MID_ZERO 0 /* unknown - implementation dependent */
+#define MID_SUN010 1 /* sun 68010/68020 binary */
+#define MID_SUN020 2 /* sun 68020-only binary */
+#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */
+#define MID_HP200 200 /* hp200 (68010) BSD binary */
+#define MID_I386 134 /* i386 BSD binary */
+#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */
+#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */
+#define MID_NS32532 137 /* ns32532 */
+#define MID_SPARC 138 /* sparc */
+#define MID_PMAX 139 /* pmax */
+#define MID_VAX1K 140 /* VAX 1K page size binaries */
+#define MID_ALPHA 141 /* Alpha BSD binary */
+#define MID_MIPS 142 /* big-endian MIPS */
+#define MID_ARM6 143 /* ARM6 */
+#define MID_M680002K 144 /* m68000 with 2K page sizes */
+#define MID_SH3 145 /* SH3 */
+#define MID_POWERPC 149 /* big-endian PowerPC */
+#define MID_VAX 150 /* VAX */
+ /* 151 - MIPS1 */
+ /* 152 - MIPS2 */
+#define MID_M88K 153 /* m88k BSD */
+#define MID_HPPA 154 /* HP PARISC */
+#define MID_SH5_64 155 /* LP64 SH5 */
+#define MID_SPARC64 156 /* LP64 sparc */
+#define MID_X86_64 157 /* AMD x86-64 */
+#define MID_SH5_32 158 /* ILP32 SH5 */
+#define MID_HP200 200 /* hp200 (68010) BSD binary */
+#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
+#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
+#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
+
+#endif /* _SYS_MACHINE_IDS_H_ */
--- /dev/null
+/* $NetBSD: ataio.h,v 1.9 2012/01/24 20:04:07 jakllsch Exp $ */
+
+#ifndef _SYS_ATAIO_H_
+#define _SYS_ATAIO_H_
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+typedef struct atareq {
+ u_long flags; /* info about the request status and type */
+ u_char command; /* command code */
+ u_char features; /* feature modifier bits for command */
+ u_char sec_count; /* sector count */
+ u_char sec_num; /* sector number */
+ u_char head; /* head number */
+ u_short cylinder; /* cylinder/lba address */
+
+ void * databuf; /* Pointer to I/O data buffer */
+ u_long datalen; /* length of data buffer */
+ int timeout; /* Command timeout */
+ u_char retsts; /* the return status for the command */
+ u_char error; /* error bits */
+} atareq_t;
+
+/* bit definitions for flags */
+#define ATACMD_READ 0x00000001
+#define ATACMD_WRITE 0x00000002
+#define ATACMD_READREG 0x00000004
+#define ATACMD_LBA 0x00000008
+
+/* definitions for the return status (retsts) */
+#define ATACMD_OK 0x00
+#define ATACMD_TIMEOUT 0x01
+#define ATACMD_ERROR 0x02
+#define ATACMD_DF 0x03
+
+#define ATAIOCCOMMAND _IOWR('Q', 8, atareq_t)
+
+/*
+ * ATA bus IOCTL
+ */
+/* Scan bus for new devices. */
+struct atabusioscan_args {
+ int at_dev; /* device to scan, -1 for wildcard */
+};
+#define ATABUSIOSCAN _IOW('A', 50, struct atabusioscan_args)
+
+#define ATABUSIORESET _IO('A', 51) /* reset ATA bus */
+
+struct atabusiodetach_args {
+ int at_dev; /* device to detach; -1 for wildcard */
+};
+#define ATABUSIODETACH _IOW('A', 52, struct atabusiodetach_args)
+
+
+#endif /* _SYS_ATAIO_H_ */
--- /dev/null
+/* $NetBSD: audioio.h,v 1.34 2011/09/06 01:16:43 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 1991-1993 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _SYS_AUDIOIO_H_
+#define _SYS_AUDIOIO_H_
+
+#include <sys/types.h>
+#include <sys/ioccom.h>
+
+#ifndef _KERNEL
+#include <string.h> /* Required for memset(3) prototype (AUDIO_INITINFO) */
+#endif /* _KERNEL */
+
+/*
+ * Audio device
+ */
+struct audio_prinfo {
+ u_int sample_rate; /* sample rate in bit/s */
+ u_int channels; /* number of channels, usually 1 or 2 */
+ u_int precision; /* number of bits/sample */
+ u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */
+ u_int gain; /* volume level */
+ u_int port; /* selected I/O port */
+ u_int seek; /* BSD extension */
+ u_int avail_ports; /* available I/O ports */
+ u_int buffer_size; /* total size audio buffer */
+ u_int _ispare[1];
+ /* Current state of device: */
+ u_int samples; /* number of samples */
+ u_int eof; /* End Of File (zero-size writes) counter */
+ u_char pause; /* non-zero if paused, zero to resume */
+ u_char error; /* non-zero if underflow/overflow ocurred */
+ u_char waiting; /* non-zero if another process hangs in open */
+ u_char balance; /* stereo channel balance */
+ u_char cspare[2];
+ u_char open; /* non-zero if currently open */
+ u_char active; /* non-zero if I/O is currently active */
+};
+typedef struct audio_prinfo audio_prinfo_t;
+
+struct audio_info {
+ struct audio_prinfo play; /* Info for play (output) side */
+ struct audio_prinfo record; /* Info for record (input) side */
+
+ u_int monitor_gain; /* input to output mix */
+ /* BSD extensions */
+ u_int blocksize; /* H/W read/write block size */
+ u_int hiwat; /* output high water mark */
+ u_int lowat; /* output low water mark */
+ u_int _ispare1;
+ u_int mode; /* current device mode */
+#define AUMODE_PLAY 0x01
+#define AUMODE_RECORD 0x02
+#define AUMODE_PLAY_ALL 0x04 /* don't do real-time correction */
+};
+typedef struct audio_info audio_info_t;
+
+#define AUDIO_INITINFO(p) \
+ (void)memset((void *)(p), 0xff, sizeof(struct audio_info))
+
+/*
+ * Parameter for the AUDIO_GETDEV ioctl to determine current
+ * audio devices.
+ */
+#define MAX_AUDIO_DEV_LEN 16
+typedef struct audio_device {
+ char name[MAX_AUDIO_DEV_LEN];
+ char version[MAX_AUDIO_DEV_LEN];
+ char config[MAX_AUDIO_DEV_LEN];
+} audio_device_t;
+
+typedef struct audio_offset {
+ u_int samples; /* Total number of bytes transferred */
+ u_int deltablks; /* Blocks transferred since last checked */
+ u_int offset; /* Physical transfer offset in buffer */
+} audio_offset_t;
+
+/*
+ * Supported audio encodings
+ */
+/* Encoding ID's */
+#define AUDIO_ENCODING_NONE 0 /* no encoding assigned */
+#define AUDIO_ENCODING_ULAW 1 /* ITU G.711 mu-law */
+#define AUDIO_ENCODING_ALAW 2 /* ITU G.711 A-law */
+#define AUDIO_ENCODING_PCM16 3 /* signed linear PCM, obsolete */
+#define AUDIO_ENCODING_LINEAR AUDIO_ENCODING_PCM16 /* SunOS compat */
+#define AUDIO_ENCODING_PCM8 4 /* unsigned linear PCM, obsolete */
+#define AUDIO_ENCODING_LINEAR8 AUDIO_ENCODING_PCM8 /* SunOS compat */
+#define AUDIO_ENCODING_ADPCM 5 /* adaptive differential PCM */
+#define AUDIO_ENCODING_SLINEAR_LE 6
+#define AUDIO_ENCODING_SLINEAR_BE 7
+#define AUDIO_ENCODING_ULINEAR_LE 8
+#define AUDIO_ENCODING_ULINEAR_BE 9
+#define AUDIO_ENCODING_SLINEAR 10
+#define AUDIO_ENCODING_ULINEAR 11
+#define AUDIO_ENCODING_MPEG_L1_STREAM 12
+#define AUDIO_ENCODING_MPEG_L1_PACKETS 13
+#define AUDIO_ENCODING_MPEG_L1_SYSTEM 14
+#define AUDIO_ENCODING_MPEG_L2_STREAM 15
+#define AUDIO_ENCODING_MPEG_L2_PACKETS 16
+#define AUDIO_ENCODING_MPEG_L2_SYSTEM 17
+#define AUDIO_ENCODING_AC3 18
+
+typedef struct audio_encoding {
+ int index;
+ char name[MAX_AUDIO_DEV_LEN];
+ int encoding;
+ int precision;
+ int flags;
+#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
+} audio_encoding_t;
+
+/*
+ * Balance settings.
+ */
+#define AUDIO_LEFT_BALANCE 0 /* left channel only */
+#define AUDIO_MID_BALANCE 32 /* equal left/right channel */
+#define AUDIO_RIGHT_BALANCE 64 /* right channel only */
+#define AUDIO_BALANCE_SHIFT 3
+
+/*
+ * Output ports
+ */
+#define AUDIO_SPEAKER 0x01 /* built-in speaker */
+#define AUDIO_HEADPHONE 0x02 /* headphone jack */
+#define AUDIO_LINE_OUT 0x04 /* line out */
+
+/*
+ * Input ports
+ */
+#define AUDIO_MICROPHONE 0x01 /* microphone */
+#define AUDIO_LINE_IN 0x02 /* line in */
+#define AUDIO_CD 0x04 /* on-board CD inputs */
+#define AUDIO_INTERNAL_CD_IN AUDIO_CD /* internal CDROM */
+
+/*
+ * Audio device operations
+ */
+#define AUDIO_GETINFO _IOR('A', 21, struct audio_info)
+#define AUDIO_SETINFO _IOWR('A', 22, struct audio_info)
+#define AUDIO_DRAIN _IO('A', 23)
+#define AUDIO_FLUSH _IO('A', 24)
+#define AUDIO_WSEEK _IOR('A', 25, u_long)
+#define AUDIO_RERROR _IOR('A', 26, int)
+#define AUDIO_GETDEV _IOR('A', 27, struct audio_device)
+#define AUDIO_GETENC _IOWR('A', 28, struct audio_encoding)
+#define AUDIO_GETFD _IOR('A', 29, int)
+#define AUDIO_SETFD _IOWR('A', 30, int)
+#define AUDIO_PERROR _IOR('A', 31, int)
+#define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset)
+#define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset)
+#define AUDIO_GETPROPS _IOR('A', 34, int)
+#define AUDIO_PROP_FULLDUPLEX 0x01
+#define AUDIO_PROP_MMAP 0x02
+#define AUDIO_PROP_INDEPENDENT 0x04
+#define AUDIO_PROP_PLAYBACK 0x10
+#define AUDIO_PROP_CAPTURE 0x20
+#define AUDIO_GETBUFINFO _IOR('A', 35, struct audio_info)
+
+/*
+ * Mixer device
+ */
+#define AUDIO_MIN_GAIN 0
+#define AUDIO_MAX_GAIN 255
+
+typedef struct mixer_level {
+ int num_channels;
+ u_char level[8]; /* [num_channels] */
+} mixer_level_t;
+#define AUDIO_MIXER_LEVEL_MONO 0
+#define AUDIO_MIXER_LEVEL_LEFT 0
+#define AUDIO_MIXER_LEVEL_RIGHT 1
+
+/*
+ * Device operations
+ */
+
+typedef struct audio_mixer_name {
+ char name[MAX_AUDIO_DEV_LEN];
+ int msg_id;
+} audio_mixer_name_t;
+
+typedef struct mixer_devinfo {
+ int index;
+ audio_mixer_name_t label;
+ int type;
+#define AUDIO_MIXER_CLASS 0
+#define AUDIO_MIXER_ENUM 1
+#define AUDIO_MIXER_SET 2
+#define AUDIO_MIXER_VALUE 3
+ int mixer_class;
+ int next, prev;
+#define AUDIO_MIXER_LAST -1
+ union {
+ struct audio_mixer_enum {
+ int num_mem;
+ struct {
+ audio_mixer_name_t label;
+ int ord;
+ } member[32];
+ } e;
+ struct audio_mixer_set {
+ int num_mem;
+ struct {
+ audio_mixer_name_t label;
+ int mask;
+ } member[32];
+ } s;
+ struct audio_mixer_value {
+ audio_mixer_name_t units;
+ int num_channels;
+ int delta;
+ } v;
+ } un;
+} mixer_devinfo_t;
+
+
+typedef struct mixer_ctrl {
+ int dev;
+ int type;
+ union {
+ int ord; /* enum */
+ int mask; /* set */
+ mixer_level_t value; /* value */
+ } un;
+} mixer_ctrl_t;
+
+/*
+ * Mixer operations
+ */
+#define AUDIO_MIXER_READ _IOWR('M', 0, mixer_ctrl_t)
+#define AUDIO_MIXER_WRITE _IOWR('M', 1, mixer_ctrl_t)
+#define AUDIO_MIXER_DEVINFO _IOWR('M', 2, mixer_devinfo_t)
+
+/*
+ * Well known device names
+ */
+#define AudioNmicrophone "mic"
+#define AudioNline "line"
+#define AudioNcd "cd"
+#define AudioNdac "dac"
+#define AudioNaux "aux"
+#define AudioNrecord "record"
+#define AudioNvolume "volume"
+#define AudioNmonitor "monitor"
+#define AudioNtreble "treble"
+#define AudioNmid "mid"
+#define AudioNbass "bass"
+#define AudioNbassboost "bassboost"
+#define AudioNspeaker "speaker"
+#define AudioNheadphone "headphones"
+#define AudioNoutput "output"
+#define AudioNinput "input"
+#define AudioNmaster "master"
+#define AudioNstereo "stereo"
+#define AudioNmono "mono"
+#define AudioNloudness "loudness"
+#define AudioNspatial "spatial"
+#define AudioNsurround "surround"
+#define AudioNpseudo "pseudo"
+#define AudioNmute "mute"
+#define AudioNenhanced "enhanced"
+#define AudioNpreamp "preamp"
+#define AudioNon "on"
+#define AudioNoff "off"
+#define AudioNmode "mode"
+#define AudioNsource "source"
+#define AudioNfmsynth "fmsynth"
+#define AudioNwave "wave"
+#define AudioNmidi "midi"
+#define AudioNmixerout "mixerout"
+#define AudioNswap "swap" /* swap left and right channels */
+#define AudioNagc "agc"
+#define AudioNdelay "delay"
+#define AudioNselect "select" /* select destination */
+#define AudioNvideo "video"
+#define AudioNcenter "center"
+#define AudioNdepth "depth"
+#define AudioNlfe "lfe"
+
+#define AudioEmulaw "mulaw"
+#define AudioEalaw "alaw"
+#define AudioEadpcm "adpcm"
+#define AudioEslinear "slinear"
+#define AudioEslinear_le "slinear_le"
+#define AudioEslinear_be "slinear_be"
+#define AudioEulinear "ulinear"
+#define AudioEulinear_le "ulinear_le"
+#define AudioEulinear_be "ulinear_be"
+#define AudioEmpeg_l1_stream "mpeg_l1_stream"
+#define AudioEmpeg_l1_packets "mpeg_l1_packets"
+#define AudioEmpeg_l1_system "mpeg_l1_system"
+#define AudioEmpeg_l2_stream "mpeg_l2_stream"
+#define AudioEmpeg_l2_packets "mpeg_l2_packets"
+#define AudioEmpeg_l2_system "mpeg_l2_system"
+#define AudioEac3 "ac3"
+
+#define AudioCinputs "inputs"
+#define AudioCoutputs "outputs"
+#define AudioCrecord "record"
+#define AudioCmonitor "monitor"
+#define AudioCequalization "equalization"
+#define AudioCmodem "modem"
+
+#endif /* !_SYS_AUDIOIO_H_ */
--- /dev/null
+/* $NetBSD: blist.h,v 1.7 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 1998 Matthew Dillon. All Rights Reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Implements bitmap resource lists.
+ *
+ * Usage:
+ * blist = blist_create(blocks)
+ * (void) blist_destroy(blist)
+ * blkno = blist_alloc(blist, count)
+ * (void) blist_free(blist, blkno, count)
+ * nblks = blist_fill(blist, blkno, count)
+ * (void) blist_resize(&blist, count, freeextra)
+ *
+ *
+ * Notes:
+ * on creation, the entire list is marked reserved. You should
+ * first blist_free() the sections you want to make available
+ * for allocation before doing general blist_alloc()/free()
+ * ops.
+ *
+ * BLIST_NONE is returned on failure. This module is typically
+ * capable of managing up to (2^31) blocks per blist, though
+ * the memory utilization would be insane if you actually did
+ * that. Managing something like 512MB worth of 4K blocks
+ * eats around 32 KBytes of memory.
+ *
+ * $FreeBSD: src/sys/sys/blist.h,v 1.9 2005/01/07 02:29:23 imp Exp $
+ */
+
+#ifndef _SYS_BLIST_H_
+#define _SYS_BLIST_H_
+
+/*
+ * for space efficiency, sizeof(blist_bitmap_t) should be
+ * greater than or equal to sizeof(blist_blkno_t).
+ */
+
+typedef uint32_t blist_bitmap_t;
+typedef uint32_t blist_blkno_t;
+
+/*
+ * note: currently use BLIST_NONE as an absolute value rather then
+ * a flag bit.
+ */
+
+#define BLIST_NONE ((blist_blkno_t)-1)
+
+typedef struct blist *blist_t;
+
+#define BLIST_BMAP_RADIX (sizeof(blist_bitmap_t)*8)
+#define BLIST_MAX_ALLOC BLIST_BMAP_RADIX
+
+extern blist_t blist_create(blist_blkno_t blocks);
+extern void blist_destroy(blist_t blist);
+extern blist_blkno_t blist_alloc(blist_t blist, blist_blkno_t count);
+extern void blist_free(blist_t blist, blist_blkno_t blkno, blist_blkno_t count);
+extern blist_blkno_t blist_fill(blist_t bl, blist_blkno_t blkno,
+ blist_blkno_t count);
+extern void blist_print(blist_t blist);
+extern void blist_resize(blist_t *pblist, blist_blkno_t count, int freenew);
+
+#endif /* _SYS_BLIST_H_ */
+
--- /dev/null
+/* $NetBSD: buf.h,v 1.119 2012/02/17 08:45:11 yamt Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)buf.h 8.9 (Berkeley) 3/30/95
+ */
+
+#ifndef _SYS_BUF_H_
+#define _SYS_BUF_H_
+
+#include <sys/pool.h>
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/rbtree.h>
+#if defined(_KERNEL)
+#include <sys/workqueue.h>
+#endif /* defined(_KERNEL) */
+
+struct buf;
+struct mount;
+struct vnode;
+struct kauth_cred;
+
+#define NOLIST ((struct buf *)0x87654321)
+
+extern kmutex_t bufcache_lock;
+extern kmutex_t buffer_lock;
+
+/*
+ * The buffer header describes an I/O operation in the kernel.
+ *
+ * Field markings and the corresponding locks:
+ *
+ * b thread of execution that holds BC_BUSY, does not correspond
+ * directly to any particular LWP
+ * c bufcache_lock
+ * o b_objlock
+ *
+ * For buffers associated with a vnode, b_objlock points to vp->v_interlock.
+ * If not associated with a vnode, it points to the generic buffer_lock.
+ */
+struct buf {
+ union {
+ TAILQ_ENTRY(buf) u_actq;
+ rb_node_t u_rbnode;
+#if defined(_KERNEL) /* u_work is smaller than u_actq. XXX */
+ struct work u_work;
+#endif /* defined(_KERNEL) */
+ } b_u; /* b: device driver queue */
+#define b_actq b_u.u_actq
+#define b_work b_u.u_work
+ void (*b_iodone)(struct buf *);/* b: call when done */
+ int b_error; /* b: errno value. */
+ int b_resid; /* b: remaining I/O. */
+ u_int b_flags; /* b: B_* flags */
+ int b_prio; /* b: priority for queue */
+ int b_bufsize; /* b: allocated size */
+ int b_bcount; /* b: valid bytes in buffer */
+ dev_t b_dev; /* b: associated device */
+ void *b_data; /* b: fs private data */
+ daddr_t b_blkno; /* b: physical block number
+ (partition relative) */
+ daddr_t b_rawblkno; /* b: raw physical block number
+ (volume relative) */
+ struct proc *b_proc; /* b: proc if BB_PHYS */
+ void *b_saveaddr; /* b: saved b_data for physio */
+
+ /*
+ * b: private data for owner.
+ * - buffer cache buffers are owned by corresponding filesystem.
+ * - non-buffer cache buffers are owned by subsystem which
+ * allocated them. (filesystem, disk driver, etc)
+ */
+ void *b_private;
+ off_t b_dcookie; /* NFS: Offset cookie if dir block */
+
+ kcondvar_t b_busy; /* c: threads waiting on buf */
+ u_int b_refcnt; /* c: refcount for b_busy */
+ void *b_unused; /* : unused */
+ LIST_ENTRY(buf) b_hash; /* c: hash chain */
+ LIST_ENTRY(buf) b_vnbufs; /* c: associated vnode */
+ TAILQ_ENTRY(buf) b_freelist; /* c: position if not active */
+ LIST_ENTRY(buf) b_wapbllist; /* c: transaction buffer list */
+ daddr_t b_lblkno; /* c: logical block number */
+ int b_freelistindex;/* c: free list index (BQ_) */
+ u_int b_cflags; /* c: BC_* flags */
+ struct vnode *b_vp; /* c: file vnode */
+
+ kcondvar_t b_done; /* o: waiting on completion */
+ u_int b_oflags; /* o: BO_* flags */
+ kmutex_t *b_objlock; /* o: completion lock */
+};
+
+/*
+ * For portability with historic industry practice, the cylinder number has
+ * to be maintained in the `b_resid' field.
+ */
+#define b_cylinder b_resid /* Cylinder number for disksort(). */
+
+/*
+ * These flags are kept in b_cflags (owned by buffer cache).
+ */
+#define BC_AGE 0x00000001 /* Move to age queue when I/O done. */
+#define BC_BUSY 0x00000010 /* I/O in progress. */
+#define BC_INVAL 0x00002000 /* Does not contain valid info. */
+#define BC_NOCACHE 0x00008000 /* Do not cache block after use. */
+#define BC_WANTED 0x00800000 /* Process wants this buffer. */
+#define BC_VFLUSH 0x04000000 /* Buffer is being synced. */
+
+/*
+ * These flags are kept in b_oflags (owned by associated object).
+ */
+#define BO_DELWRI 0x00000080 /* Delay I/O until buffer reused. */
+#define BO_DONE 0x00000200 /* I/O completed. */
+
+/*
+ * These flags are kept in b_flags (owned by buffer holder).
+ */
+#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */
+#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
+#define B_COWDONE 0x00000400 /* Copy-on-write already done. */
+#define B_GATHERED 0x00001000 /* LFS: already in a segment. */
+#define B_LOCKED 0x00004000 /* Locked in core (not reusable). */
+#define B_PHYS 0x00040000 /* I/O to user memory. */
+#define B_RAW 0x00080000 /* Set by physio for raw transfers. */
+#define B_READ 0x00100000 /* Read buffer. */
+#define B_DEVPRIVATE 0x02000000 /* Device driver private flag. */
+
+#define BUF_FLAGBITS \
+ "\20\1AGE\3ASYNC\4BAD\5BUSY\10DELWRI" \
+ "\12DONE\13COWDONE\15GATHERED\16INVAL\17LOCKED\20NOCACHE" \
+ "\23PHYS\24RAW\25READ\32DEVPRIVATE\33VFLUSH"
+
+/* Avoid weird code due to B_WRITE being a "pseudo flag" */
+#define BUF_ISREAD(bp) (((bp)->b_flags & B_READ) == B_READ)
+#define BUF_ISWRITE(bp) (((bp)->b_flags & B_READ) == B_WRITE)
+
+/*
+ * This structure describes a clustered I/O. It is stored in the b_saveaddr
+ * field of the buffer on which I/O is done. At I/O completion, cluster
+ * callback uses the structure to parcel I/O's to individual buffers, and
+ * then free's this structure.
+ */
+struct cluster_save {
+ long bs_bcount; /* Saved b_bcount. */
+ long bs_bufsize; /* Saved b_bufsize. */
+ void *bs_saveaddr; /* Saved b_addr. */
+ int bs_nchildren; /* Number of associated buffers. */
+ struct buf *bs_children; /* List of associated buffers. */
+};
+
+/*
+ * Zero out the buffer's data area.
+ */
+#define clrbuf(bp) \
+do { \
+ memset((bp)->b_data, 0, (u_int)(bp)->b_bcount); \
+ (bp)->b_resid = 0; \
+} while (/* CONSTCOND */ 0)
+
+/* Flags to low-level allocation routines. */
+#define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */
+#define B_SYNC 0x02 /* Do all allocations synchronously. */
+#define B_METAONLY 0x04 /* Return indirect block buffer. */
+#define B_CONTIG 0x08 /* Allocate file contiguously. */
+
+/* Flags to bread() and breadn(). */
+#define B_MODIFY 0x01 /* Hint: caller might modify buffer */
+
+#ifdef _KERNEL
+
+#define BIO_GETPRIO(bp) ((bp)->b_prio)
+#define BIO_SETPRIO(bp, prio) (bp)->b_prio = (prio)
+#define BIO_COPYPRIO(bp1, bp2) BIO_SETPRIO(bp1, BIO_GETPRIO(bp2))
+
+#define BPRIO_NPRIO 3
+#define BPRIO_TIMECRITICAL 2
+#define BPRIO_TIMELIMITED 1
+#define BPRIO_TIMENONCRITICAL 0
+#define BPRIO_DEFAULT BPRIO_TIMELIMITED
+
+extern u_int nbuf; /* The number of buffer headers */
+
+/*
+ * Definitions for the buffer free lists.
+ */
+#define BQUEUES 4 /* number of free buffer queues */
+
+#define BQ_LOCKED 0 /* super-blocks &c */
+#define BQ_LRU 1 /* lru, useful buffers */
+#define BQ_AGE 2 /* rubbish */
+#define BQ_EMPTY 3 /* buffer headers with no memory */
+
+struct bqueue {
+ TAILQ_HEAD(, buf) bq_queue;
+ uint64_t bq_bytes;
+ buf_t *bq_marker;
+};
+
+extern struct bqueue bufqueues[BQUEUES];
+
+__BEGIN_DECLS
+int allocbuf(buf_t *, int, int);
+void bawrite(buf_t *);
+void bdwrite(buf_t *);
+void biodone(buf_t *);
+int biowait(buf_t *);
+int bread(struct vnode *, daddr_t, int, struct kauth_cred *, int, buf_t **);
+int breadn(struct vnode *, daddr_t, int, daddr_t *, int *, int,
+ struct kauth_cred *, int, buf_t **);
+void brelsel(buf_t *, int);
+void brelse(buf_t *, int);
+void bremfree(buf_t *);
+void bufinit(void);
+void bufinit2(void);
+int bwrite(buf_t *);
+buf_t *getblk(struct vnode *, daddr_t, int, int, int);
+buf_t *geteblk(int);
+buf_t *incore(struct vnode *, daddr_t);
+
+void minphys(buf_t *);
+int physio(void (*)(buf_t *), buf_t *, dev_t, int,
+ void (*)(buf_t *), struct uio *);
+
+void brelvp(buf_t *);
+void reassignbuf(buf_t *, struct vnode *);
+void bgetvp(struct vnode *, buf_t *);
+int buf_syncwait(void);
+u_long buf_memcalc(void);
+int buf_drain(int);
+int buf_setvalimit(vsize_t);
+#if defined(DDB) || defined(DEBUGPRINT)
+void vfs_buf_print(buf_t *, int, void (*)(const char *, ...)
+ __printflike(1, 2));
+#endif
+buf_t *getiobuf(struct vnode *, bool);
+void putiobuf(buf_t *);
+void buf_init(buf_t *);
+void buf_destroy(buf_t *);
+int bbusy(buf_t *, bool, int, kmutex_t *);
+
+void nestiobuf_iodone(buf_t *);
+void nestiobuf_setup(buf_t *, buf_t *, int, size_t);
+void nestiobuf_done(buf_t *, int, int);
+
+__END_DECLS
+#endif /* _KERNEL */
+#endif /* !_SYS_BUF_H_ */
--- /dev/null
+/* $NetBSD: bufq.h,v 1.10 2009/01/13 13:35:54 yamt Exp $ */
+/* NetBSD: buf.h,v 1.75 2004/09/18 16:40:11 yamt Exp */
+
+/*-
+ * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)buf.h 8.9 (Berkeley) 3/30/95
+ */
+
+#if !defined(_KERNEL)
+#error not supposed to be exposed to userland.
+#endif
+
+struct buf;
+struct bufq_state;
+
+/*
+ * Special strategies for bufq_alloc.
+ */
+#define BUFQ_STRAT_ANY NULL /* let bufq_alloc select one. */
+#define BUFQ_DISK_DEFAULT_STRAT BUFQ_STRAT_ANY /* default for disks. */
+
+/*
+ * Flags for bufq_alloc.
+ */
+#define BUFQ_SORT_RAWBLOCK 0x0001 /* Sort by b_rawblkno */
+#define BUFQ_SORT_CYLINDER 0x0002 /* Sort by b_cylinder, b_rawblkno */
+
+#define BUFQ_SORT_MASK 0x000f
+
+#define BUFQ_EXACT 0x0010 /* Don't fall back to other strategy */
+
+int bufq_alloc(struct bufq_state **, const char *, int);
+void bufq_drain(struct bufq_state *);
+void bufq_free(struct bufq_state *);
+/* Put buffer in queue */
+void bufq_put(struct bufq_state *, struct buf *);
+/* Get and remove buffer from queue */
+struct buf *bufq_get(struct bufq_state *);
+/* Get buffer from queue */
+struct buf *bufq_peek(struct bufq_state *);
+/* Remove specified buffer from queue */
+struct buf *bufq_cancel(struct bufq_state *, struct buf *);
+const char *bufq_getstrategyname(struct bufq_state *);
+void bufq_move(struct bufq_state *, struct bufq_state *);
--- /dev/null
+/* $NetBSD: bufq_impl.h,v 1.9 2011/11/02 13:52:34 yamt Exp $ */
+/* NetBSD: bufq.h,v 1.3 2005/03/31 11:28:53 yamt Exp */
+/* NetBSD: buf.h,v 1.75 2004/09/18 16:40:11 yamt Exp */
+
+/*-
+ * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)buf.h 8.9 (Berkeley) 3/30/95
+ */
+
+#if !defined(_KERNEL)
+#error not supposed to be exposed to userland.
+#endif
+
+struct bufq_strat;
+
+/*
+ * Device driver buffer queue.
+ */
+struct bufq_state {
+ void (*bq_put)(struct bufq_state *, struct buf *);
+ struct buf *(*bq_get)(struct bufq_state *, int);
+ struct buf *(*bq_cancel)(struct bufq_state *, struct buf *);
+ void (*bq_fini)(struct bufq_state *);
+ void *bq_private;
+ int bq_flags; /* Flags from bufq_alloc() */
+ const struct bufq_strat *bq_strat;
+};
+
+static __inline void *bufq_private(const struct bufq_state *) __unused;
+static __inline bool buf_inorder(const struct buf *, const struct buf *, int)
+ __unused;
+
+#include <sys/null.h> /* for NULL */
+
+static __inline void *
+bufq_private(const struct bufq_state *bufq)
+{
+
+ return bufq->bq_private;
+}
+
+/*
+ * Check if two buf's are in ascending order.
+ *
+ * this function consider a NULL buf is after any non-NULL buf.
+ *
+ * this function returns false if two are "same".
+ */
+static __inline bool
+buf_inorder(const struct buf *bp, const struct buf *bq, int sortby)
+{
+
+ KASSERT(bp != NULL || bq != NULL);
+ if (bp == NULL || bq == NULL)
+ return (bq == NULL);
+
+ if (sortby == BUFQ_SORT_CYLINDER) {
+ if (bp->b_cylinder != bq->b_cylinder)
+ return bp->b_cylinder < bq->b_cylinder;
+ else
+ return bp->b_rawblkno < bq->b_rawblkno;
+ } else
+ return bp->b_rawblkno < bq->b_rawblkno;
+}
+
+struct bufq_strat {
+ const char *bs_name;
+ void (*bs_initfn)(struct bufq_state *);
+ int bs_prio;
+};
+
+#define BUFQ_DEFINE(name, prio, initfn) \
+static const struct bufq_strat bufq_strat_##name = { \
+ .bs_name = #name, \
+ .bs_prio = prio, \
+ .bs_initfn = initfn \
+}; \
+__link_set_add_rodata(bufq_strats, bufq_strat_##name)
--- /dev/null
+/* $NetBSD: bus.h,v 1.11 2012/05/07 18:16:38 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_BUS_H_
+#define _SYS_BUS_H_
+
+#include <sys/types.h>
+
+#ifdef __HAVE_NEW_STYLE_BUS_H
+
+#include <machine/bus_defs.h>
+
+struct bus_space_reservation {
+ bus_addr_t _bsr_start;
+ bus_size_t _bsr_size;
+};
+
+typedef struct bus_space_reservation bus_space_reservation_t;
+
+static inline bus_size_t
+bus_space_reservation_size(bus_space_reservation_t *bsr)
+{
+ return bsr->_bsr_size;
+}
+
+static inline bus_space_reservation_t *
+bus_space_reservation_init(bus_space_reservation_t *bsr,
+ bus_addr_t addr, bus_size_t size)
+{
+ bsr->_bsr_start = addr;
+ bsr->_bsr_size = size;
+ return bsr;
+}
+
+static inline bus_addr_t
+bus_space_reservation_addr(bus_space_reservation_t *bsr)
+{
+ return bsr->_bsr_start;
+}
+
+enum bus_space_override_idx {
+ BUS_SPACE_OVERRIDE_MAP = __BIT(0)
+ , BUS_SPACE_OVERRIDE_UNMAP = __BIT(1)
+ , BUS_SPACE_OVERRIDE_ALLOC = __BIT(2)
+ , BUS_SPACE_OVERRIDE_FREE = __BIT(3)
+ , BUS_SPACE_OVERRIDE_RESERVE = __BIT(4)
+ , BUS_SPACE_OVERRIDE_RELEASE = __BIT(5)
+ , BUS_SPACE_OVERRIDE_RESERVATION_MAP = __BIT(6)
+ , BUS_SPACE_OVERRIDE_RESERVATION_UNMAP = __BIT(7)
+ , BUS_SPACE_OVERRIDE_RESERVE_SUBREGION = __BIT(8)
+#if 0
+ , BUS_SPACE_OVERRIDE_EXTEND = __BIT(9)
+ , BUS_SPACE_OVERRIDE_TRIM = __BIT(10)
+#endif
+};
+
+enum bus_dma_override_idx {
+ BUS_DMAMAP_OVERRIDE_CREATE = __BIT(0)
+ , BUS_DMAMAP_OVERRIDE_DESTROY = __BIT(1)
+ , BUS_DMAMAP_OVERRIDE_LOAD = __BIT(2)
+ , BUS_DMAMAP_OVERRIDE_LOAD_MBUF = __BIT(3)
+ , BUS_DMAMAP_OVERRIDE_LOAD_UIO = __BIT(4)
+ , BUS_DMAMAP_OVERRIDE_LOAD_RAW = __BIT(5)
+ , BUS_DMAMAP_OVERRIDE_UNLOAD = __BIT(6)
+ , BUS_DMAMAP_OVERRIDE_SYNC = __BIT(7)
+ , BUS_DMAMEM_OVERRIDE_ALLOC = __BIT(8)
+ , BUS_DMAMEM_OVERRIDE_FREE = __BIT(9)
+ , BUS_DMAMEM_OVERRIDE_MAP = __BIT(10)
+ , BUS_DMAMEM_OVERRIDE_UNMAP = __BIT(11)
+ , BUS_DMAMEM_OVERRIDE_MMAP = __BIT(12)
+ , BUS_DMATAG_OVERRIDE_SUBREGION = __BIT(13)
+ , BUS_DMATAG_OVERRIDE_DESTROY = __BIT(14)
+};
+
+/* Only add new members at the end of this struct! */
+struct bus_space_overrides {
+ int (*ov_space_map)(void *, bus_space_tag_t, bus_addr_t, bus_size_t,
+ int, bus_space_handle_t *);
+
+ void (*ov_space_unmap)(void *, bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+ int (*ov_space_alloc)(void *, bus_space_tag_t, bus_addr_t, bus_addr_t,
+ bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
+ bus_space_handle_t *);
+
+ void (*ov_space_free)(void *, bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+ int (*ov_space_reserve)(void *, bus_space_tag_t, bus_addr_t, bus_size_t,
+ int, bus_space_reservation_t *);
+
+ void (*ov_space_release)(void *, bus_space_tag_t,
+ bus_space_reservation_t *);
+
+ int (*ov_space_reservation_map)(void *, bus_space_tag_t,
+ bus_space_reservation_t *, int, bus_space_handle_t *);
+
+ void (*ov_space_reservation_unmap)(void *, bus_space_tag_t,
+ bus_space_handle_t, bus_size_t);
+
+ int (*ov_space_reserve_subregion)(void *, bus_space_tag_t,
+ bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, bus_size_t,
+ int, bus_space_reservation_t *);
+
+#if 0
+ int (*ov_space_extend)(void *, bus_space_tag_t,
+ bus_space_reservation_t *, bus_size_t, bus_size_t);
+
+ void (*ov_space_trim)(void *, bus_space_tag_t,
+ bus_space_reservation_t *, bus_size_t, bus_size_t);
+#endif
+};
+
+struct mbuf;
+struct uio;
+
+/* Only add new members at the end of this struct! */
+struct bus_dma_overrides {
+ int (*ov_dmamap_create)(void *, bus_dma_tag_t, bus_size_t, int,
+ bus_size_t, bus_size_t, int, bus_dmamap_t *);
+ void (*ov_dmamap_destroy)(void *, bus_dma_tag_t, bus_dmamap_t);
+ int (*ov_dmamap_load)(void *, bus_dma_tag_t, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int);
+ int (*ov_dmamap_load_mbuf)(void *, bus_dma_tag_t, bus_dmamap_t,
+ struct mbuf *, int);
+ int (*ov_dmamap_load_uio)(void *, bus_dma_tag_t, bus_dmamap_t,
+ struct uio *, int);
+ int (*ov_dmamap_load_raw)(void *, bus_dma_tag_t, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int);
+ void (*ov_dmamap_unload)(void *, bus_dma_tag_t, bus_dmamap_t);
+ void (*ov_dmamap_sync)(void *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+ bus_size_t, int);
+ int (*ov_dmamem_alloc)(void *, bus_dma_tag_t, bus_size_t, bus_size_t,
+ bus_size_t, bus_dma_segment_t *, int, int *, int);
+ void (*ov_dmamem_free)(void *, bus_dma_tag_t, bus_dma_segment_t *, int);
+ int (*ov_dmamem_map)(void *, bus_dma_tag_t, bus_dma_segment_t *, int,
+ size_t, void **, int);
+ void (*ov_dmamem_unmap)(void *, bus_dma_tag_t, void *, size_t);
+ paddr_t (*ov_dmamem_mmap)(void *, bus_dma_tag_t, bus_dma_segment_t *,
+ int, off_t, int, int);
+ int (*ov_dmatag_subregion)(void *, bus_dma_tag_t, bus_addr_t,
+ bus_addr_t, bus_dma_tag_t *, int);
+ void (*ov_dmatag_destroy)(void *, bus_dma_tag_t);
+};
+
+int bus_space_tag_create(bus_space_tag_t, uint64_t, uint64_t,
+ const struct bus_space_overrides *, void *,
+ bus_space_tag_t *);
+void bus_space_tag_destroy(bus_space_tag_t);
+
+int bus_dma_tag_create(bus_dma_tag_t, uint64_t,
+ const struct bus_dma_overrides *, void *, bus_dma_tag_t *);
+void bus_dma_tag_destroy(bus_dma_tag_t);
+
+/* Reserve a region of bus space. Reserved bus space cannot be allocated
+ * with bus_space_alloc(). Reserved space has not been bus_space_map()'d.
+ */
+int bus_space_reserve(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ bus_space_reservation_t *);
+
+int
+bus_space_reserve_subregion(bus_space_tag_t,
+ bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, bus_size_t,
+ int, bus_space_reservation_t *);
+
+/* Cancel a reservation. */
+void bus_space_release(bus_space_tag_t, bus_space_reservation_t *);
+
+int bus_space_reservation_map(bus_space_tag_t, bus_space_reservation_t *,
+ int, bus_space_handle_t *);
+
+void bus_space_reservation_unmap(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+#if 0
+/* Extend a reservation to the left and/or to the right. The extension
+ * has not been bus_space_map()'d.
+ */
+int bus_space_extend(bus_space_tag_t, bus_space_reservation_t *, bus_size_t,
+ bus_size_t);
+
+/* Trim bus space from a reservation on the left and/or on the right. */
+void bus_space_trim(bus_space_tag_t, bus_space_reservation_t *, bus_size_t,
+ bus_size_t);
+#endif
+
+#include <sys/bus_proto.h>
+
+#include <machine/bus_funcs.h>
+
+#else /* !__HAVE_NEW_STYLE_BUS_H */
+
+#include <machine/bus.h>
+
+bool bus_space_is_equal(bus_space_tag_t, bus_space_tag_t);
+bool bus_space_handle_is_equal(bus_space_tag_t, bus_space_handle_t,
+ bus_space_handle_t);
+
+#endif /* __HAVE_NEW_STYLE_BUS_H */
+
+#ifdef __HAVE_NO_BUS_DMA
+/*
+ * XXX
+ * Dummy bus_dma(9) stuff for ports which don't bother to have
+ * unnecessary bus_dma(9) implementation to appease MI driver modules etc.
+ */
+typedef void *bus_dma_tag_t;
+
+typedef struct bus_dma_segment {
+ bus_addr_t ds_addr;
+ bus_size_t ds_len;
+} bus_dma_segment_t;
+
+typedef struct bus_dmamap {
+ bus_size_t dm_maxsegsz;
+ bus_size_t dm_mapsize;
+ int dm_nsegs;
+ bus_dma_segment_t *dm_segs;
+} *bus_dmamap_t;
+#endif /* __HAVE_NO_BUS_DMA */
+
+#endif /* _SYS_BUS_H_ */
--- /dev/null
+/* $NetBSD: bus_proto.h,v 1.6 2011/08/17 10:46:38 martin Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997, 1998, 2001, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_BUS_PROTO_H_
+#define _SYS_BUS_PROTO_H_
+
+/*
+ * Forwards needed by prototypes below.
+ */
+struct mbuf;
+struct uio;
+
+/*
+ * bus_space(9)
+ */
+
+/* Map types. */
+#define BUS_SPACE_MAP_CACHEABLE 0x01
+#define BUS_SPACE_MAP_LINEAR 0x02
+#define BUS_SPACE_MAP_PREFETCHABLE 0x04
+
+/* Bus read/write barrier methods. */
+#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
+#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
+
+int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ bus_space_handle_t *);
+
+void bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+
+int bus_space_subregion(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_size_t, bus_space_handle_t *);
+
+int bus_space_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t,
+ bus_size_t, bus_size_t, bus_size_t,
+ int, bus_addr_t *, bus_space_handle_t *);
+
+void bus_space_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+
+paddr_t bus_space_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
+
+void *bus_space_vaddr(bus_space_tag_t, bus_space_handle_t);
+
+void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
+ bus_size_t offset, bus_size_t len, int flags);
+
+/*
+ * bus_space(9) accessors
+ */
+
+uint8_t bus_space_read_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+uint8_t bus_space_read_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+uint16_t bus_space_read_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+uint16_t bus_space_read_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+uint32_t bus_space_read_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+uint32_t bus_space_read_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+uint64_t bus_space_read_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+uint64_t bus_space_read_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+void bus_space_read_multi_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t *, bus_size_t);
+void bus_space_read_multi_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t *, bus_size_t);
+void bus_space_read_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t *, bus_size_t);
+void bus_space_read_region_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t *, bus_size_t);
+
+void bus_space_read_multi_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t *, bus_size_t);
+void bus_space_read_multi_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t *, bus_size_t);
+void bus_space_read_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t *, bus_size_t);
+void bus_space_read_region_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t *, bus_size_t);
+
+void bus_space_read_multi_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t *, bus_size_t);
+void bus_space_read_multi_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t *, bus_size_t);
+void bus_space_read_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t *, bus_size_t);
+void bus_space_read_region_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t *, bus_size_t);
+
+void bus_space_read_multi_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t *, bus_size_t);
+void bus_space_read_multi_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t *, bus_size_t);
+void bus_space_read_region_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t *, bus_size_t);
+void bus_space_read_region_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t *, bus_size_t);
+
+void bus_space_write_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t);
+void bus_space_write_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint8_t);
+
+void bus_space_write_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t);
+void bus_space_write_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint16_t);
+
+void bus_space_write_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t);
+void bus_space_write_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint32_t);
+
+void bus_space_write_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t);
+void bus_space_write_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, uint64_t);
+
+void bus_space_write_multi_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint8_t *,
+ bus_size_t);
+void bus_space_write_multi_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint8_t *,
+ bus_size_t);
+void bus_space_write_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint8_t *,
+ bus_size_t);
+void bus_space_write_region_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint8_t *,
+ bus_size_t);
+
+void bus_space_write_multi_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint16_t *,
+ bus_size_t);
+void bus_space_write_multi_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint16_t *,
+ bus_size_t);
+void bus_space_write_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint16_t *,
+ bus_size_t);
+void bus_space_write_region_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint16_t *,
+ bus_size_t);
+
+void bus_space_write_multi_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint32_t *,
+ bus_size_t);
+void bus_space_write_multi_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint32_t *,
+ bus_size_t);
+void bus_space_write_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint32_t *,
+ bus_size_t);
+void bus_space_write_region_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint32_t *,
+ bus_size_t);
+
+void bus_space_write_multi_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint64_t *,
+ bus_size_t);
+void bus_space_write_multi_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint64_t *,
+ bus_size_t);
+void bus_space_write_region_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint64_t *,
+ bus_size_t);
+void bus_space_write_region_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const uint64_t *,
+ bus_size_t);
+
+void bus_space_set_multi_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, bus_size_t);
+void bus_space_set_multi_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, bus_size_t);
+void bus_space_set_multi_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, bus_size_t);
+void bus_space_set_multi_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t, bus_size_t);
+
+void bus_space_set_multi_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, bus_size_t);
+void bus_space_set_multi_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, bus_size_t);
+void bus_space_set_multi_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, bus_size_t);
+void bus_space_set_multi_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t, bus_size_t);
+
+void bus_space_set_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, bus_size_t);
+void bus_space_set_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, bus_size_t);
+void bus_space_set_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, bus_size_t);
+void bus_space_set_region_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t, bus_size_t);
+
+void bus_space_set_region_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, bus_size_t);
+void bus_space_set_region_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, bus_size_t);
+void bus_space_set_region_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, bus_size_t);
+void bus_space_set_region_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t, bus_size_t);
+
+void bus_space_copy_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+
+void bus_space_copy_region_stream_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_stream_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_stream_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+void bus_space_copy_region_stream_8(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t,
+ bus_size_t, bus_size_t);
+
+bool bus_space_is_equal(bus_space_tag_t, bus_space_tag_t);
+bool bus_space_handle_is_equal(bus_space_tag_t, bus_space_handle_t,
+ bus_space_handle_t);
+
+/*
+ * bus_dma(9)
+ */
+
+/* Flags used in various bus DMA methods. */
+#define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
+#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
+#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
+#define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
+#define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
+#define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
+#define BUS_DMA_BUS2 0x020
+#define BUS_DMA_BUS3 0x040
+#define BUS_DMA_BUS4 0x080
+#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
+#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
+
+/* Operations performed by bus_dmamap_sync(). */
+#define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
+#define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
+#define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
+#define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
+
+int bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
+ bus_size_t, int, bus_dmamap_t *);
+void bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
+int bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
+ struct proc *, int);
+int bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
+ struct mbuf *, int);
+int bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
+ struct uio *, int);
+int bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int);
+void bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
+void bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+ bus_size_t, int);
+
+int bus_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t,
+ bus_size_t, bus_dma_segment_t *,
+ int, int *, int);
+void bus_dmamem_free(bus_dma_tag_t, bus_dma_segment_t *, int);
+int bus_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *, int,
+ size_t, void **, int);
+void bus_dmamem_unmap(bus_dma_tag_t, void *, size_t);
+paddr_t bus_dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *, int,
+ off_t, int, int);
+
+int bus_dmatag_subregion(bus_dma_tag_t, bus_addr_t, bus_addr_t,
+ bus_dma_tag_t *, int);
+void bus_dmatag_destroy(bus_dma_tag_t);
+
+#endif /* _SYS_BUS_PROTO_H_ */
--- /dev/null
+/* $NetBSD: callback.h,v 1.3 2007/07/09 21:11:32 ad Exp $ */
+
+/*-
+ * Copyright (c)2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CALLBACK_H_
+#define _SYS_CALLBACK_H_
+
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+
+struct callback_entry {
+ TAILQ_ENTRY(callback_entry) ce_q;
+ int (*ce_func)(struct callback_entry *, void *, void *);
+ void *ce_obj;
+};
+
+struct callback_head {
+ kmutex_t ch_lock;
+ kcondvar_t ch_cv;
+ TAILQ_HEAD(, callback_entry) ch_q;
+ struct callback_entry *ch_next;
+ int ch_nentries;
+ int ch_running;
+ int ch_flags;
+};
+
+/* return values of ce_func */
+#define CALLBACK_CHAIN_CONTINUE 0
+#define CALLBACK_CHAIN_ABORT 1
+
+int callback_run_roundrobin(struct callback_head *, void *);
+void callback_register(struct callback_head *, struct callback_entry *,
+ void *, int (*)(struct callback_entry *, void *, void *));
+void callback_unregister(struct callback_head *, struct callback_entry *);
+void callback_head_init(struct callback_head *, int);
+void callback_head_destroy(struct callback_head *);
+
+#endif /* !_SYS_CALLBACK_H_ */
--- /dev/null
+/* $NetBSD: callout.h,v 1.31 2008/04/28 20:24:10 martin Exp $ */
+
+/*-
+ * Copyright (c) 2000, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CALLOUT_H_
+#define _SYS_CALLOUT_H_
+
+#include <sys/types.h>
+
+/*
+ * The callout implementation is private to kern_timeout.c yet uses
+ * caller-supplied storage, as lightweight callout operations are
+ * critical to system performance.
+ *
+ * The size of callout_t must remain constant in order to ensure ABI
+ * compatibility for kernel modules: it may become smaller, but must
+ * not grow. If more space is required, rearrange the members of
+ * callout_impl_t.
+ */
+typedef struct callout {
+ void *_c_store[10];
+} callout_t;
+
+/* Internal flags. */
+#define CALLOUT_BOUND 0x0001 /* bound to a specific CPU */
+#define CALLOUT_PENDING 0x0002 /* callout is on the queue */
+#define CALLOUT_FIRED 0x0004 /* callout has fired */
+#define CALLOUT_INVOKING 0x0008 /* callout function is being invoked */
+
+/* End-user flags. */
+#define CALLOUT_MPSAFE 0x0100 /* does not need kernel_lock */
+#define CALLOUT_FLAGMASK 0xff00
+
+#ifdef _CALLOUT_PRIVATE
+
+/* The following funkyness is to appease gcc3's strict aliasing. */
+struct callout_circq {
+ /* next element */
+ union {
+ struct callout_impl *elem;
+ struct callout_circq *list;
+ } cq_next;
+ /* previous element */
+ union {
+ struct callout_impl *elem;
+ struct callout_circq *list;
+ } cq_prev;
+};
+#define cq_next_e cq_next.elem
+#define cq_prev_e cq_prev.elem
+#define cq_next_l cq_next.list
+#define cq_prev_l cq_prev.list
+
+struct callout_cpu;
+
+typedef struct callout_impl {
+ struct callout_circq c_list; /* linkage on queue */
+ void (*c_func)(void *); /* function to call */
+ void *c_arg; /* function argument */
+ struct callout_cpu * volatile c_cpu; /* associated CPU */
+ int c_time; /* when callout fires */
+ u_int c_flags; /* state of this entry */
+ u_int c_magic; /* magic number */
+} callout_impl_t;
+#define CALLOUT_MAGIC 0x11deeba1
+
+#endif /* _CALLOUT_PRIVATE */
+
+#ifdef _KERNEL
+struct cpu_info;
+
+void callout_startup(void);
+void callout_init_cpu(struct cpu_info *);
+void callout_hardclock(void);
+
+void callout_init(callout_t *, u_int);
+void callout_destroy(callout_t *);
+void callout_setfunc(callout_t *, void (*)(void *), void *);
+void callout_reset(callout_t *, int, void (*)(void *), void *);
+void callout_schedule(callout_t *, int);
+bool callout_stop(callout_t *);
+bool callout_halt(callout_t *, void *);
+bool callout_pending(callout_t *);
+bool callout_expired(callout_t *);
+bool callout_active(callout_t *);
+bool callout_invoking(callout_t *);
+void callout_ack(callout_t *);
+void callout_bind(callout_t *, struct cpu_info *);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_CALLOUT_H_ */
--- /dev/null
+/* $NetBSD: cctr.h,v 1.3 2008/04/28 20:24:10 martin Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CCTR_H_
+#define _SYS_CCTR_H_
+
+#include <sys/timetc.h>
+
+/*
+ * Variables used by cycle counter in kern_cctr.c.
+ */
+struct cctr_state {
+ volatile u_int cc_gen; /* generation number for this data set */
+ volatile int64_t cc_val; /* reference CC value at calibration time */
+ volatile int64_t cc_cc; /* local CC value at calibration time */
+ volatile int64_t cc_delta; /* reference CC difference for
+ last calibration period */
+ volatile int64_t cc_denom; /* local CC difference for
+ last calibration period */
+};
+
+struct cpu_info;
+
+void cc_calibrate_cpu(struct cpu_info *);
+struct timecounter *cc_init(timecounter_get_t, uint64_t, const char *, int);
+u_int cc_get_timecount(struct timecounter *);
+
+#endif /* _SYS_CCTR_H_ */
--- /dev/null
+/* $NetBSD: cdio.h,v 1.33 2009/01/29 19:36:28 reinoud Exp $ */
+
+#ifndef _SYS_CDIO_H_
+#define _SYS_CDIO_H_
+
+/* Shared between kernel & process */
+
+union msf_lba {
+ struct {
+ u_char unused;
+ u_char minute;
+ u_char second;
+ u_char frame;
+ } msf;
+ uint32_t lba;
+ u_char addr[4];
+};
+
+struct cd_toc_entry {
+ u_char nothing1;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t control:4;
+ uint32_t addr_type:4;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t addr_type:4;
+ uint32_t control:4;
+#endif
+ u_char track;
+ u_char nothing2;
+ union msf_lba addr;
+};
+
+struct cd_sub_channel_header {
+ u_char nothing1;
+ u_char audio_status;
+#define CD_AS_AUDIO_INVALID 0x00
+#define CD_AS_PLAY_IN_PROGRESS 0x11
+#define CD_AS_PLAY_PAUSED 0x12
+#define CD_AS_PLAY_COMPLETED 0x13
+#define CD_AS_PLAY_ERROR 0x14
+#define CD_AS_NO_STATUS 0x15
+ u_char data_len[2];
+};
+
+struct cd_sub_channel_q_data {
+ u_char data_format;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t control:4;
+ uint32_t addr_type:4;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t addr_type:4;
+ uint32_t control:4;
+#endif
+ u_char track_number;
+ u_char index_number;
+ u_char absaddr[4];
+ u_char reladdr[4];
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t :7;
+ uint32_t mc_valid:1;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t mc_valid:1;
+ uint32_t :7;
+#endif
+ u_char mc_number[15];
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t :7;
+ uint32_t ti_valid:1;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t ti_valid:1;
+ uint32_t :7;
+#endif
+ u_char ti_number[15];
+};
+
+struct cd_sub_channel_position_data {
+ u_char data_format;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t control:4;
+ uint32_t addr_type:4;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t addr_type:4;
+ uint32_t control:4;
+#endif
+ u_char track_number;
+ u_char index_number;
+ union msf_lba absaddr;
+ union msf_lba reladdr;
+};
+
+struct cd_sub_channel_media_catalog {
+ u_char data_format;
+ u_char nothing1;
+ u_char nothing2;
+ u_char nothing3;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t :7;
+ uint32_t mc_valid:1;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t mc_valid:1;
+ uint32_t :7;
+#endif
+ u_char mc_number[15];
+};
+
+struct cd_sub_channel_track_info {
+ u_char data_format;
+ u_char nothing1;
+ u_char track_number;
+ u_char nothing2;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t :7;
+ uint32_t ti_valid:1;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint32_t ti_valid:1;
+ uint32_t :7;
+#endif
+ u_char ti_number[15];
+};
+
+struct cd_sub_channel_info {
+ struct cd_sub_channel_header header;
+ union {
+ struct cd_sub_channel_q_data q_data;
+ struct cd_sub_channel_position_data position;
+ struct cd_sub_channel_media_catalog media_catalog;
+ struct cd_sub_channel_track_info track_info;
+ } what;
+};
+
+/*
+ * Ioctls for the CD drive
+ */
+struct ioc_play_track {
+ u_char start_track;
+ u_char start_index;
+ u_char end_track;
+ u_char end_index;
+};
+
+#define CDIOCPLAYTRACKS _IOW('c', 1, struct ioc_play_track)
+struct ioc_play_blocks {
+ int blk;
+ int len;
+};
+#define CDIOCPLAYBLOCKS _IOW('c', 2, struct ioc_play_blocks)
+
+struct ioc_read_subchannel {
+ u_char address_format;
+#define CD_LBA_FORMAT 1
+#define CD_MSF_FORMAT 2
+ u_char data_format;
+#define CD_SUBQ_DATA 0
+#define CD_CURRENT_POSITION 1
+#define CD_MEDIA_CATALOG 2
+#define CD_TRACK_INFO 3
+ u_char track;
+ int data_len;
+ struct cd_sub_channel_info *data;
+};
+#define CDIOCREADSUBCHANNEL _IOWR('c', 3, struct ioc_read_subchannel )
+
+#ifdef _KERNEL
+/* As above, but with the buffer following the request for in-kernel users. */
+struct ioc_read_subchannel_buf {
+ struct ioc_read_subchannel req;
+ struct cd_sub_channel_info info;
+};
+#define CDIOCREADSUBCHANNEL_BUF _IOWR('c', 3, struct ioc_read_subchannel_buf)
+#endif
+
+struct ioc_toc_header {
+ u_short len;
+ u_char starting_track;
+ u_char ending_track;
+};
+
+#define CDIOREADTOCHEADER _IOR('c', 4, struct ioc_toc_header)
+
+struct ioc_read_toc_entry {
+ u_char address_format;
+ u_char starting_track;
+ u_short data_len;
+ struct cd_toc_entry *data;
+};
+#define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry)
+#define CDIOREADTOCENTRYS CDIOREADTOCENTRIES
+
+#ifdef _KERNEL
+/* As above, but with the buffer following the request for in-kernel users. */
+struct ioc_read_toc_entry_buf {
+ struct ioc_read_toc_entry req;
+ struct cd_toc_entry entry[100]; /* NB: 8 bytes each */
+};
+#define CDIOREADTOCENTRIES_BUF _IOWR('c', 5, struct ioc_read_toc_entry_buf)
+#endif
+
+/* read LBA start of a given session; 0=last, others not yet supported */
+#define CDIOREADMSADDR _IOWR('c', 6, int)
+
+struct ioc_patch {
+ u_char patch[4]; /* one for each channel */
+};
+#define CDIOCSETPATCH _IOW('c', 9, struct ioc_patch)
+
+struct ioc_vol {
+ u_char vol[4]; /* one for each channel */
+};
+#define CDIOCGETVOL _IOR('c', 10, struct ioc_vol)
+#define CDIOCSETVOL _IOW('c', 11, struct ioc_vol)
+#define CDIOCSETMONO _IO('c', 12)
+#define CDIOCSETSTEREO _IO('c', 13)
+#define CDIOCSETMUTE _IO('c', 14)
+#define CDIOCSETLEFT _IO('c', 15)
+#define CDIOCSETRIGHT _IO('c', 16)
+#define CDIOCSETDEBUG _IO('c', 17)
+#define CDIOCCLRDEBUG _IO('c', 18)
+#define CDIOCPAUSE _IO('c', 19)
+#define CDIOCRESUME _IO('c', 20)
+#define CDIOCRESET _IO('c', 21)
+#define CDIOCSTART _IO('c', 22)
+#define CDIOCSTOP _IO('c', 23)
+#define CDIOCEJECT _IO('c', 24)
+#define CDIOCALLOW _IO('c', 25)
+#define CDIOCPREVENT _IO('c', 26)
+#define CDIOCCLOSE _IO('c', 27)
+
+struct ioc_play_msf {
+ u_char start_m;
+ u_char start_s;
+ u_char start_f;
+ u_char end_m;
+ u_char end_s;
+ u_char end_f;
+};
+#define CDIOCPLAYMSF _IOW('c', 25, struct ioc_play_msf)
+
+struct ioc_load_unload {
+ u_char options;
+#define CD_LU_ABORT 0x1 /* NOTE: These are the same as the ATAPI */
+#define CD_LU_UNLOAD 0x2 /* op values for the LOAD_UNLOAD command */
+#define CD_LU_LOAD 0x3
+ u_char slot;
+};
+#define CDIOCLOADUNLOAD _IOW('c', 26, struct ioc_load_unload)
+
+
+#if defined(_KERNEL) || defined(_EXPOSE_MMC)
+/* not exposed to userland yet until its completely mature */
+/*
+ * MMC device abstraction interface.
+ *
+ * It gathers information from GET_CONFIGURATION, READ_DISCINFO,
+ * READ_TRACKINFO, READ_TOC2, READ_CD_CAPACITY and GET_CONFIGURATION
+ * SCSI/ATAPI calls regardless if its a legacy CD-ROM/DVD-ROM device or a MMC
+ * standard recordable device.
+ */
+struct mmc_discinfo {
+ uint16_t mmc_profile;
+ uint16_t mmc_class;
+
+ uint8_t disc_state;
+ uint8_t last_session_state;
+ uint8_t bg_format_state;
+ uint8_t link_block_penalty; /* in sectors */
+
+ uint64_t mmc_cur; /* current MMC_CAPs */
+ uint64_t mmc_cap; /* possible MMC_CAPs */
+
+ uint32_t disc_flags; /* misc flags */
+
+ uint32_t disc_id;
+ uint64_t disc_barcode;
+ uint8_t application_code; /* 8 bit really */
+
+ uint8_t unused1[3]; /* padding */
+
+ uint32_t last_possible_lba; /* last leadout start adr. */
+ uint32_t sector_size;
+
+ uint16_t num_sessions;
+ uint16_t num_tracks; /* derived */
+
+ uint16_t first_track;
+ uint16_t first_track_last_session;
+ uint16_t last_track_last_session;
+
+ uint16_t unused2; /* padding/misc info resv. */
+
+ uint16_t reserved1[4]; /* MMC-5 track resources */
+ uint32_t reserved2[3]; /* MMC-5 POW resources */
+
+ uint32_t reserved3[8]; /* MMC-5+ */
+};
+#define MMCGETDISCINFO _IOR('c', 28, struct mmc_discinfo)
+
+#define MMC_CLASS_UNKN 0
+#define MMC_CLASS_DISC 1
+#define MMC_CLASS_CD 2
+#define MMC_CLASS_DVD 3
+#define MMC_CLASS_MO 4
+#define MMC_CLASS_BD 5
+#define MMC_CLASS_FILE 0xffff /* emulation mode */
+
+#define MMC_DFLAGS_BARCODEVALID (1 << 0) /* barcode is present and valid */
+#define MMC_DFLAGS_DISCIDVALID (1 << 1) /* discid is present and valid */
+#define MMC_DFLAGS_APPCODEVALID (1 << 2) /* application code valid */
+#define MMC_DFLAGS_UNRESTRICTED (1 << 3) /* restricted, then set app. code */
+
+#define MMC_DFLAGS_FLAGBITS \
+ "\10\1BARCODEVALID\2DISCIDVALID\3APPCODEVALID\4UNRESTRICTED"
+
+#define MMC_CAP_SEQUENTIAL (1 << 0) /* sequential writable only */
+#define MMC_CAP_RECORDABLE (1 << 1) /* record-able; i.e. not static */
+#define MMC_CAP_ERASABLE (1 << 2) /* drive can erase sectors */
+#define MMC_CAP_BLANKABLE (1 << 3) /* media can be blanked */
+#define MMC_CAP_FORMATTABLE (1 << 4) /* media can be formatted */
+#define MMC_CAP_REWRITABLE (1 << 5) /* media can be rewritten */
+#define MMC_CAP_MRW (1 << 6) /* Mount Rainier formatted */
+#define MMC_CAP_PACKET (1 << 7) /* using packet recording */
+#define MMC_CAP_STRICTOVERWRITE (1 << 8) /* only writes a packet at a time */
+#define MMC_CAP_PSEUDOOVERWRITE (1 << 9) /* overwrite through replacement */
+#define MMC_CAP_ZEROLINKBLK (1 << 10) /* zero link block length capable */
+#define MMC_CAP_HW_DEFECTFREE (1 << 11) /* hardware defect management */
+
+#define MMC_CAP_FLAGBITS \
+ "\10\1SEQUENTIAL\2RECORDABLE\3ERASABLE\4BLANKABLE\5FORMATTABLE" \
+ "\6REWRITABLE\7MRW\10PACKET\11STRICTOVERWRITE\12PSEUDOOVERWRITE" \
+ "\13ZEROLINKBLK\14HW_DEFECTFREE"
+
+#define MMC_STATE_EMPTY 0
+#define MMC_STATE_INCOMPLETE 1
+#define MMC_STATE_FULL 2
+#define MMC_STATE_CLOSED 3
+
+#define MMC_BGFSTATE_UNFORM 0
+#define MMC_BGFSTATE_STOPPED 1
+#define MMC_BGFSTATE_RUNNING 2
+#define MMC_BGFSTATE_COMPLETED 3
+
+
+struct mmc_trackinfo {
+ uint16_t tracknr; /* IN/OUT */
+ uint16_t sessionnr;
+
+ uint8_t track_mode;
+ uint8_t data_mode;
+
+ uint16_t flags;
+
+ uint32_t track_start;
+ uint32_t next_writable;
+ uint32_t free_blocks;
+ uint32_t packet_size;
+ uint32_t track_size;
+ uint32_t last_recorded;
+};
+#define MMCGETTRACKINFO _IOWR('c', 29, struct mmc_trackinfo)
+
+#define MMC_TRACKINFO_COPY (1 << 0)
+#define MMC_TRACKINFO_DAMAGED (1 << 1)
+#define MMC_TRACKINFO_FIXED_PACKET (1 << 2)
+#define MMC_TRACKINFO_INCREMENTAL (1 << 3)
+#define MMC_TRACKINFO_BLANK (1 << 4)
+#define MMC_TRACKINFO_RESERVED (1 << 5)
+#define MMC_TRACKINFO_NWA_VALID (1 << 6)
+#define MMC_TRACKINFO_LRA_VALID (1 << 7)
+#define MMC_TRACKINFO_DATA (1 << 8)
+#define MMC_TRACKINFO_AUDIO (1 << 9)
+#define MMC_TRACKINFO_AUDIO_4CHAN (1 << 10)
+#define MMC_TRACKINFO_PRE_EMPH (1 << 11)
+
+#define MMC_TRACKINFO_FLAGBITS \
+ "\10\1COPY\2DAMAGED\3FIXEDPACKET\4INCREMENTAL\5BLANK" \
+ "\6RESERVED\7NWA_VALID\10LRA_VALID\11DATA\12AUDIO" \
+ "\13AUDIO_4CHAN\14PRE_EMPH"
+
+struct mmc_op {
+ uint16_t operation; /* IN */
+ uint16_t mmc_profile; /* IN */
+
+ /* parameters to operation */
+ uint16_t tracknr; /* IN */
+ uint16_t sessionnr; /* IN */
+ uint32_t extent; /* IN */
+
+ uint32_t reserved[4];
+};
+#define MMCOP _IOWR('c', 30, struct mmc_op)
+
+#define MMC_OP_SYNCHRONISECACHE 1
+#define MMC_OP_CLOSETRACK 2
+#define MMC_OP_CLOSESESSION 3
+#define MMC_OP_FINALISEDISC 4
+#define MMC_OP_RESERVETRACK 5
+#define MMC_OP_RESERVETRACK_NWA 6
+#define MMC_OP_UNRESERVETRACK 7
+#define MMC_OP_REPAIRTRACK 8
+#define MMC_OP_UNCLOSELASTSESSION 9
+#define MMC_OP_MAX 9
+
+struct mmc_writeparams {
+ uint16_t tracknr; /* IN */
+ uint16_t mmc_class; /* IN */
+ uint32_t mmc_cur; /* IN */
+ uint32_t blockingnr; /* IN */
+
+ /* when tracknr == 0 */
+ uint8_t track_mode; /* IN; normally 5 */
+ uint8_t data_mode; /* IN; normally 2 */
+};
+#define MMC_TRACKMODE_DEFAULT 5 /* data, incremental recording */
+#define MMC_DATAMODE_DEFAULT 2 /* CDROM XA disc */
+#define MMCSETUPWRITEPARAMS _IOW('c', 31, struct mmc_writeparams)
+
+#endif /* _KERNEL || _EXPOSE_MMC */
+
+#endif /* !_SYS_CDIO_H_ */
--- /dev/null
+/* $NetBSD: chio.h,v 1.12 2008/04/28 20:24:10 martin Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CHIO_H_
+#define _SYS_CHIO_H_
+
+/*
+ * Element types. Used as "to" and "from" type indicators in move
+ * and exchange operations.
+ *
+ * Note that code in sys/dev/scsipi/ch.c relies on these values (uses
+ * them as offsets in an array, and other evil), so don't muck with them
+ * unless you know what you're doing.
+ */
+#define CHET_MT 0 /* medium transport (picker) */
+#define CHET_ST 1 /* storage transport (slot) */
+#define CHET_IE 2 /* import/export (portal) */
+#define CHET_DT 3 /* data transfer (drive) */
+
+/*
+ * Structure used to execute a MOVE MEDIUM command.
+ */
+struct changer_move_request {
+ int cm_fromtype; /* element type to move from */
+ int cm_fromunit; /* logical unit of from element */
+ int cm_totype; /* element type to move to */
+ int cm_tounit; /* logical unit of to element */
+ int cm_flags; /* misc. flags */
+};
+
+/* cm_flags */
+#define CM_INVERT 0x01 /* invert media */
+
+/*
+ * Structure used to execute an EXCHANGE MEDIUM command. In an
+ * exchange operation, the following steps occur:
+ *
+ * - media from source is moved to first destination.
+ *
+ * - media previously occupying first destination is moved
+ * to the second destination.
+ *
+ * The second destination may or may not be the same as the source.
+ * In the case of a simple exchange, the source and second destination
+ * are the same.
+ */
+struct changer_exchange_request {
+ int ce_srctype; /* element type of source */
+ int ce_srcunit; /* logical unit of source */
+ int ce_fdsttype; /* element type of first destination */
+ int ce_fdstunit; /* logical unit of first destination */
+ int ce_sdsttype; /* element type of second destination */
+ int ce_sdstunit; /* logical unit of second destination */
+ int ce_flags; /* misc. flags */
+};
+
+/* ce_flags */
+#define CE_INVERT1 0x01 /* invert media 1 */
+#define CE_INVERT2 0x02 /* invert media 2 */
+
+/*
+ * Structure used to execute a POSITION TO ELEMENT command. This
+ * moves the current picker in front of the specified element.
+ */
+struct changer_position_request {
+ int cp_type; /* element type */
+ int cp_unit; /* logical unit of element */
+ int cp_flags; /* misc. flags */
+};
+
+/* cp_flags */
+#define CP_INVERT 0x01 /* invert picker */
+
+/*
+ * Data returned by CHIOGPARAMS.
+ */
+struct changer_params {
+ int cp_curpicker; /* current picker */
+ int cp_npickers; /* number of pickers */
+ int cp_nslots; /* number of slots */
+ int cp_nportals; /* number of import/export portals */
+ int cp_ndrives; /* number of drives */
+};
+
+/*
+ * Old-style command used to get element status.
+ */
+struct ochanger_element_status_request {
+ int cesr_type; /* element type */
+ uint8_t *cesr_data; /* pre-allocated data storage */
+};
+
+/*
+ * Structure of a changer volume tag.
+ */
+#define CHANGER_VOLTAG_SIZE 32 /* same as SCSI voltag size */
+struct changer_voltag {
+ char cv_tag[CHANGER_VOLTAG_SIZE + 1]; /* ASCII tag */
+ uint16_t cv_serial; /* serial number */
+};
+
+/*
+ * Data returned by CHIOGSTATUS.
+ */
+struct changer_element_status {
+ int ces_flags; /* CESTATUS_* flags; see below */
+
+ /*
+ * The following is only valid on Data Transport elements (drives).
+ */
+ char ces_xname[16]; /* external name of drive device */
+
+ /*
+ * The following fieds indicate the element the medium was
+ * moved from in order to arrive in this element.
+ */
+ int ces_from_type; /* type of element */
+ int ces_from_unit; /* logical unit of element */
+
+ /*
+ * Volume tag information.
+ */
+ struct changer_voltag ces_pvoltag; /* primary volume tag */
+ struct changer_voltag ces_avoltag; /* alternate volume tag */
+
+ size_t ces_vendor_len; /* length of any vendor-specific data */
+
+ /*
+ * These two fields are only valid if CESTATUS_EXCEPT is
+ * set in ces_flags, and are only valid on SCSI changers.
+ */
+ uint8_t ces_asc; /* Additional Sense Code */
+ uint8_t ces_ascq; /* Additional Sense Code Qualifier */
+
+ /*
+ * These two fields may be useful if ces_xname is not valid.
+ * They indicate the target and lun of a drive element. These
+ * are only valid on SCSI changers.
+ */
+ uint8_t ces_target; /* SCSI target of drive */
+ uint8_t ces_lun; /* SCSI LUN of drive */
+};
+
+/*
+ * Flags for changer_element_status. These are flags that are returned
+ * by hardware. Not all flags have meaning for all element types.
+ */
+#define CESTATUS_FULL 0x0001 /* element is full */
+#define CESTATUS_IMPEXP 0x0002 /* media deposited by operator */
+#define CESTATUS_EXCEPT 0x0004 /* element in abnormal state */
+#define CESTATUS_ACCESS 0x0008 /* media accessible by picker */
+#define CESTATUS_EXENAB 0x0010 /* element supports exporting */
+#define CESTATUS_INENAB 0x0020 /* element supports importing */
+
+#define CESTATUS_PICKER_MASK 0x0005 /* flags valid for pickers */
+#define CESTATUS_SLOT_MASK 0x000c /* flags valid for slots */
+#define CESTATUS_PORTAL_MASK 0x003f /* flags valid for portals */
+#define CESTATUS_DRIVE_MASK 0x000c /* flags valid for drives */
+
+#define CESTATUS_INVERTED 0x0040 /* medium inverted from storage */
+#define CESTATUS_NOTBUS 0x0080 /* drive not on same bus as changer */
+
+/*
+ * These changer_element_status flags indicate the validity of fields
+ * in the returned data.
+ */
+#define CESTATUS_STATUS_VALID 0x0100 /* entire structure valid */
+#define CESTATUS_XNAME_VALID 0x0200 /* ces_xname valid */
+#define CESTATUS_FROM_VALID 0x0400 /* ces_from_* valid */
+#define CESTATUS_PVOL_VALID 0x0800 /* ces_pvoltag valid */
+#define CESTATUS_AVOL_VALID 0x1000 /* ces_avoltag valid */
+#define CESTATUS_TARGET_VALID 0x2000 /* ces_target valid */
+#define CESTATUS_LUN_VALID 0x4000 /* ces_lun valid */
+
+#define CESTATUS_BITS \
+ "\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
+
+/*
+ * Command used to get element status.
+ */
+struct changer_element_status_request {
+ int cesr_type; /* element type */
+ int cesr_unit; /* start at this unit */
+ int cesr_count; /* for this many units */
+ int cesr_flags; /* flags; see below */
+ /* pre-allocated data storage */
+ /*
+ * These fields point to the data to be returned to the
+ * user:
+ *
+ * cesr_deta: pointer to array of cesr_count status descriptors
+ *
+ * cesr_vendor_data: pointer to array of void *'s which point
+ * to pre-allocated areas for vendor-specific data. Optional.
+ */
+ struct changer_element_status *cesr_data;
+ void **cesr_vendor_data;
+};
+
+#define CESR_VOLTAGS 0x01 /* request volume tags */
+
+/*
+ * Command used to modify a media element's volume tag.
+ */
+struct changer_set_voltag_request {
+ int csvr_type; /* element type */
+ int csvr_unit; /* unit to modify */
+ int csvr_flags; /* flags; see below */
+ /* the actual volume tag; ignored if clearing
+ the tag */
+ struct changer_voltag csvr_voltag;
+};
+
+#define CSVR_MODE_SET 0x00 /* set volume tag if not set */
+#define CSVR_MODE_REPLACE 0x01 /* unconditionally replace volume tag */
+#define CSVR_MODE_CLEAR 0x02 /* clear volume tag */
+#define CSVR_MODE_MASK 0x0f
+#define CSVR_ALTERNATE 0x10 /* modify alternate volume tag */
+
+/*
+ * Changer events.
+ *
+ * When certain events occur, the kernel can indicate this by setting
+ * a bit in a bitmask.
+ *
+ * When a read is issued to the changer, the kernel returns this event
+ * bitmask. The read never blocks; if no events are pending, the bitmask
+ * will be all-clear.
+ *
+ * A process may select for read to wait for an event to occur.
+ *
+ * The event mask is cleared when the changer is closed.
+ */
+#define CHANGER_EVENT_SIZE sizeof(u_int)
+#define CHEV_ELEMENT_STATUS_CHANGED 0x00000001
+
+/*
+ * ioctls applicable to changers.
+ */
+#define CHIOMOVE _IOW('c', 0x01, struct changer_move_request)
+#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange_request)
+#define CHIOPOSITION _IOW('c', 0x03, struct changer_position_request)
+#define CHIOGPICKER _IOR('c', 0x04, int)
+#define CHIOSPICKER _IOW('c', 0x05, int)
+#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params)
+#define CHIOIELEM _IO('c', 0x07)
+#define OCHIOGSTATUS _IOW('c', 0x08, struct ochanger_element_status_request)
+#define CHIOGSTATUS _IOW('c', 0x09, struct changer_element_status_request)
+#define CHIOSVOLTAG _IOW('c', 0x0a, struct changer_set_voltag_request)
+
+#endif /* _SYS_CHIO_H_ */
--- /dev/null
+/* $NetBSD: clockctl.h,v 1.15 2009/01/11 02:45:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Emmanuel Dreyfus.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#ifndef _SYS_CLOCKCTL_H_
+#define _SYS_CLOCKCTL_H_
+
+#include <sys/time.h>
+#include <sys/timex.h>
+
+struct clockctl_settimeofday {
+ const struct timeval *tv;
+ const void *tzp;
+};
+
+#define CLOCKCTL_SETTIMEOFDAY _IOW('C', 0x5, struct clockctl_settimeofday)
+
+struct clockctl_adjtime {
+ const struct timeval *delta;
+ struct timeval *olddelta;
+};
+
+#define CLOCKCTL_ADJTIME _IOWR('C', 0x6, struct clockctl_adjtime)
+
+struct clockctl_clock_settime {
+ clockid_t clock_id;
+ const struct timespec *tp;
+};
+
+#define CLOCKCTL_CLOCK_SETTIME _IOW('C', 0x7, struct clockctl_clock_settime)
+
+struct clockctl_ntp_adjtime {
+ struct timex *tp;
+ register_t retval;
+};
+
+#define CLOCKCTL_NTP_ADJTIME _IOWR('C', 0x8, struct clockctl_ntp_adjtime)
+
+#ifdef _KERNEL
+void clockctlattach(int);
+int clockctlopen(dev_t, int, int, struct lwp *);
+int clockctlclose(dev_t, int, int, struct lwp *);
+int clockctlioctl(dev_t, u_long, void *, int, struct lwp *);
+#endif
+
+#endif /* _SYS_CLOCKCTL_H_ */
--- /dev/null
+/* $NetBSD: conf.h,v 1.143 2012/07/29 18:05:48 mlelstv Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)conf.h 8.5 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_CONF_H_
+#define _SYS_CONF_H_
+
+/*
+ * Definitions of device driver entry switches
+ */
+
+#include <sys/queue.h>
+
+struct buf;
+struct knote;
+struct lwp;
+struct tty;
+struct uio;
+struct vnode;
+
+/*
+ * Types for d_flag
+ */
+#define D_OTHER 0x0000
+#define D_TAPE 0x0001
+#define D_DISK 0x0002
+#define D_TTY 0x0003
+#define D_TYPEMASK 0x00ff
+#define D_MPSAFE 0x0100
+#define D_NEGOFFSAFE 0x0200
+
+/*
+ * Block device switch table
+ */
+struct bdevsw {
+ int (*d_open)(dev_t, int, int, struct lwp *);
+ int (*d_close)(dev_t, int, int, struct lwp *);
+ void (*d_strategy)(struct buf *);
+ int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
+ int (*d_dump)(dev_t, daddr_t, void *, size_t);
+ int (*d_psize)(dev_t);
+ int d_flag;
+};
+
+/*
+ * Character device switch table
+ */
+struct cdevsw {
+ int (*d_open)(dev_t, int, int, struct lwp *);
+ int (*d_close)(dev_t, int, int, struct lwp *);
+ int (*d_read)(dev_t, struct uio *, int);
+ int (*d_write)(dev_t, struct uio *, int);
+ int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
+ void (*d_stop)(struct tty *, int);
+ struct tty * (*d_tty)(dev_t);
+ int (*d_poll)(dev_t, int, struct lwp *);
+ paddr_t (*d_mmap)(dev_t, off_t, int);
+ int (*d_kqfilter)(dev_t, struct knote *);
+ int d_flag;
+};
+
+#ifdef _KERNEL
+
+#include <sys/mutex.h>
+extern kmutex_t device_lock;
+
+int devsw_attach(const char *, const struct bdevsw *, devmajor_t *,
+ const struct cdevsw *, devmajor_t *);
+int devsw_detach(const struct bdevsw *, const struct cdevsw *);
+const struct bdevsw *bdevsw_lookup(dev_t);
+const struct cdevsw *cdevsw_lookup(dev_t);
+devmajor_t bdevsw_lookup_major(const struct bdevsw *);
+devmajor_t cdevsw_lookup_major(const struct cdevsw *);
+
+#define dev_type_open(n) int n (dev_t, int, int, struct lwp *)
+#define dev_type_close(n) int n (dev_t, int, int, struct lwp *)
+#define dev_type_read(n) int n (dev_t, struct uio *, int)
+#define dev_type_write(n) int n (dev_t, struct uio *, int)
+#define dev_type_ioctl(n) \
+ int n (dev_t, u_long, void *, int, struct lwp *)
+#define dev_type_stop(n) void n (struct tty *, int)
+#define dev_type_tty(n) struct tty * n (dev_t)
+#define dev_type_poll(n) int n (dev_t, int, struct lwp *)
+#define dev_type_mmap(n) paddr_t n (dev_t, off_t, int)
+#define dev_type_strategy(n) void n (struct buf *)
+#define dev_type_dump(n) int n (dev_t, daddr_t, void *, size_t)
+#define dev_type_size(n) int n (dev_t)
+#define dev_type_kqfilter(n) int n (dev_t, struct knote *)
+
+#define noopen ((dev_type_open((*)))enodev)
+#define noclose ((dev_type_close((*)))enodev)
+#define noread ((dev_type_read((*)))enodev)
+#define nowrite ((dev_type_write((*)))enodev)
+#define noioctl ((dev_type_ioctl((*)))enodev)
+#define nostop ((dev_type_stop((*)))enodev)
+#define notty NULL
+#define nopoll seltrue
+#define nommap ((dev_type_mmap((*)))enodev)
+#define nodump ((dev_type_dump((*)))enodev)
+#define nosize NULL
+#define nokqfilter seltrue_kqfilter
+
+#define nullopen ((dev_type_open((*)))nullop)
+#define nullclose ((dev_type_close((*)))nullop)
+#define nullread ((dev_type_read((*)))nullop)
+#define nullwrite ((dev_type_write((*)))nullop)
+#define nullioctl ((dev_type_ioctl((*)))nullop)
+#define nullstop ((dev_type_stop((*)))nullop)
+#define nullpoll ((dev_type_poll((*)))nullop)
+#define nullmmap ((dev_type_mmap((*)))nullop)
+#define nulldump ((dev_type_dump((*)))nullop)
+#define nullkqfilter ((dev_type_kqfilter((*)))eopnotsupp)
+
+/* device access wrappers. */
+
+dev_type_open(bdev_open);
+dev_type_close(bdev_close);
+dev_type_strategy(bdev_strategy);
+dev_type_ioctl(bdev_ioctl);
+dev_type_dump(bdev_dump);
+dev_type_size(bdev_size);
+
+dev_type_open(cdev_open);
+dev_type_close(cdev_close);
+dev_type_read(cdev_read);
+dev_type_write(cdev_write);
+dev_type_ioctl(cdev_ioctl);
+dev_type_stop(cdev_stop);
+dev_type_tty(cdev_tty);
+dev_type_poll(cdev_poll);
+dev_type_mmap(cdev_mmap);
+dev_type_kqfilter(cdev_kqfilter);
+
+int cdev_type(dev_t);
+int bdev_type(dev_t);
+
+/* symbolic sleep message strings */
+extern const char devopn[], devio[], devwait[], devin[], devout[];
+extern const char devioc[], devcls[];
+
+#endif /* _KERNEL */
+
+/*
+ * Line discipline switch table
+ */
+struct linesw {
+ const char *l_name; /* Linesw name */
+
+ LIST_ENTRY(linesw) l_list;
+ u_int l_refcnt; /* locked by ttyldisc_list_slock */
+ int l_no; /* legacy discipline number (for TIOCGETD) */
+
+ int (*l_open) (dev_t, struct tty *);
+ int (*l_close) (struct tty *, int);
+ int (*l_read) (struct tty *, struct uio *, int);
+ int (*l_write) (struct tty *, struct uio *, int);
+ int (*l_ioctl) (struct tty *, u_long, void *, int,
+ struct lwp *);
+ int (*l_rint) (int, struct tty *);
+ int (*l_start) (struct tty *);
+ int (*l_modem) (struct tty *, int);
+ int (*l_poll) (struct tty *, int, struct lwp *);
+};
+
+#ifdef _KERNEL
+void ttyldisc_init(void);
+int ttyldisc_attach(struct linesw *);
+int ttyldisc_detach(struct linesw *);
+struct linesw *ttyldisc_lookup(const char *);
+struct linesw *ttyldisc_lookup_bynum(int);
+struct linesw *ttyldisc_default(void);
+void ttyldisc_release(struct linesw *);
+
+/* For those defining their own line disciplines: */
+#define ttynodisc ((int (*)(dev_t, struct tty *))enodev)
+#define ttyerrclose ((int (*)(struct tty *, int))enodev)
+#define ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
+#define ttyerrinput ((int (*)(int, struct tty *))enodev)
+#define ttyerrstart ((int (*)(struct tty *))enodev)
+
+int ttyerrpoll (struct tty *, int, struct lwp *);
+int ttynullioctl(struct tty *, u_long, void *, int, struct lwp *);
+
+int iskmemdev(dev_t);
+int seltrue_kqfilter(dev_t, struct knote *);
+#endif
+
+#ifdef _KERNEL
+
+#define DEV_MEM 0 /* minor device 0 is physical memory */
+#define DEV_KMEM 1 /* minor device 1 is kernel memory */
+#define DEV_NULL 2 /* minor device 2 is EOF/rathole */
+#ifdef COMPAT_16
+#define _DEV_ZERO_oARM 3 /* reserved: old ARM /dev/zero minor */
+#endif
+#define DEV_ZERO 12 /* minor device 12 is '\0'/rathole */
+
+enum devnode_class {
+ DEVNODE_DONTBOTHER,
+ DEVNODE_SINGLE,
+ DEVNODE_VECTOR,
+};
+#define DEVNODE_FLAG_LINKZERO 0x01 /* create name -> name0 link */
+#define DEVNODE_FLAG_ISMINOR0 0x02 /* vector[0] specifies minor */
+#ifdef notyet
+#define DEVNODE_FLAG_ISMINOR1 0x04 /* vector[1] specifies starting minor */
+#endif
+
+struct devsw_conv {
+ const char *d_name;
+ devmajor_t d_bmajor;
+ devmajor_t d_cmajor;
+
+ /* information about /dev nodes related to the device */
+ enum devnode_class d_class;
+ int d_flags;
+ int d_vectdim[2];
+};
+
+void devsw_init(void);
+const char *devsw_blk2name(devmajor_t);
+const char *cdevsw_getname(devmajor_t);
+const char *bdevsw_getname(devmajor_t);
+devmajor_t devsw_name2blk(const char *, char *, size_t);
+devmajor_t devsw_name2chr(const char *, char *, size_t);
+dev_t devsw_chr2blk(dev_t);
+dev_t devsw_blk2chr(dev_t);
+
+void mm_init(void);
+#endif /* _KERNEL */
+
+#ifdef _KERNEL
+struct device;
+void setroot(struct device *, int);
+void rootconf(void);
+void swapconf(void);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_CONF_H_ */
--- /dev/null
+/* $NetBSD: core.h,v 1.12 2009/08/20 22:07:49 he Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CORE_H_
+#define _SYS_CORE_H_
+
+#define COREMAGIC 0507
+#define CORESEGMAGIC 0510
+
+/*
+ * The core structure's c_midmag field (like exec's a_midmag) is a
+ * network-byteorder encoding of this int
+ * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
+ * Where `F' is 6 bits of flag (currently unused),
+ * `m' is 10 bits of machine-id, and
+ * `M' is 16 bits worth of magic number, ie. COREMAGIC.
+ * The macros below will set/get the needed fields.
+ */
+#define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff )
+#define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff )
+#define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f )
+#define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \
+ ( ((flag) & 0x3f) << 26) | \
+ ( ((mid) & 0x03ff) << 16) | \
+ ( ((mag) & 0xffff) ) ) )
+
+/* Flag definitions */
+#define CORE_CPU 1
+#define CORE_DATA 2
+#define CORE_STACK 4
+
+#include <sys/aout_mids.h>
+
+/*
+ * A core file consists of a header followed by a number of segments.
+ * Each segment is preceded by a `coreseg' structure giving the
+ * segment's type, the virtual address where the bits resided in
+ * process address space and the size of the segment.
+ *
+ * The core header specifies the lengths of the core header itself and
+ * each of the following core segment headers to allow for any machine
+ * dependent alignment requirements.
+ */
+
+struct core {
+ uint32_t c_midmag; /* magic, id, flags */
+ uint16_t c_hdrsize; /* Size of this header (machdep algn) */
+ uint16_t c_seghdrsize; /* Size of a segment header */
+ uint32_t c_nseg; /* # of core segments */
+ char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
+ uint32_t c_signo; /* Killing signal */
+ u_long c_ucode; /* Hmm ? */
+ u_long c_cpusize; /* Size of machine dependent segment */
+ u_long c_tsize; /* Size of traditional text segment */
+ u_long c_dsize; /* Size of traditional data segment */
+ u_long c_ssize; /* Size of traditional stack segment */
+};
+
+struct coreseg {
+ uint32_t c_midmag; /* magic, id, flags */
+ u_long c_addr; /* Virtual address of segment */
+ u_long c_size; /* Size of this segment */
+};
+
+/*
+ * 32-bit versions of the above.
+ */
+struct core32 {
+ uint32_t c_midmag; /* magic, id, flags */
+ uint16_t c_hdrsize; /* Size of this header (machdep algn) */
+ uint16_t c_seghdrsize; /* Size of a segment header */
+ uint32_t c_nseg; /* # of core segments */
+ char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
+ uint32_t c_signo; /* Killing signal */
+ u_int c_ucode; /* Hmm ? */
+ u_int c_cpusize; /* Size of machine dependent segment */
+ u_int c_tsize; /* Size of traditional text segment */
+ u_int c_dsize; /* Size of traditional data segment */
+ u_int c_ssize; /* Size of traditional stack segment */
+};
+
+struct coreseg32 {
+ uint32_t c_midmag; /* magic, id, flags */
+ u_int c_addr; /* Virtual address of segment */
+ u_int c_size; /* Size of this segment */
+};
+
+#endif /* !_SYS_CORE_H_ */
--- /dev/null
+/* $NetBSD: cprng.h,v 1.5 2012/04/17 02:50:39 tls Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Thor Lancelot Simon.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _CPRNG_H
+#define _CPRNG_H
+
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <lib/libkern/libkern.h>
+#include <sys/rnd.h>
+#include <crypto/nist_ctr_drbg/nist_ctr_drbg.h>
+#include <sys/condvar.h>
+#include <sys/select.h>
+
+/*
+ * NIST SP800-90 says 2^19 bytes per request for the CTR_DRBG.
+ */
+#define CPRNG_MAX_LEN 524288
+
+#if !defined(_RUMPKERNEL) && !defined(_RUMP_NATIVE_ABI)
+/*
+ * We do not want an arc4random() prototype available to anyone.
+ */
+void _arc4randbytes(void *, size_t);
+uint32_t _arc4random(void);
+
+static inline size_t
+cprng_fast(void *p, size_t len)
+{
+ _arc4randbytes(p, len);
+ return len;
+}
+
+static inline uint32_t
+cprng_fast32(void)
+{
+ return _arc4random();
+}
+
+static inline uint64_t
+cprng_fast64(void)
+{
+ uint64_t r;
+ _arc4randbytes(&r, sizeof(r));
+ return r;
+}
+#else
+size_t cprng_fast(void *, size_t);
+uint32_t cprng_fast32(void);
+uint64_t cprng_fast64(void);
+#endif
+
+typedef struct _cprng_strong {
+ kmutex_t mtx;
+ kcondvar_t cv;
+ struct selinfo selq;
+ NIST_CTR_DRBG drbg;
+ int flags;
+ char name[16];
+ int reseed_pending;
+ int entropy_serial;
+ rndsink_t reseed;
+} cprng_strong_t;
+
+#define CPRNG_INIT_ANY 0x00000001
+#define CPRNG_REKEY_ANY 0x00000002
+#define CPRNG_USE_CV 0x00000004
+
+cprng_strong_t *cprng_strong_create(const char *const, int, int);
+
+size_t cprng_strong(cprng_strong_t *const, void *const, size_t, int);
+
+void cprng_strong_destroy(cprng_strong_t *);
+
+extern cprng_strong_t * kern_cprng;
+
+static inline uint32_t
+cprng_strong32(void)
+{
+ uint32_t r;
+ cprng_strong(kern_cprng, &r, sizeof(r), 0);
+ return r;
+}
+
+static inline uint64_t
+cprng_strong64(void)
+{
+ uint64_t r;
+ cprng_strong(kern_cprng, &r, sizeof(r), 0);
+ return r;
+}
+
+static inline int
+cprng_strong_ready(cprng_strong_t *c)
+{
+ int ret = 0;
+
+ mutex_enter(&c->mtx);
+ if (c->drbg.reseed_counter < NIST_CTR_DRBG_RESEED_INTERVAL) {
+ ret = 1;
+ }
+ mutex_exit(&c->mtx);
+ return ret;
+}
+
+static inline void
+cprng_strong_deplete(cprng_strong_t *c)
+{
+ mutex_enter(&c->mtx);
+ c->drbg.reseed_counter = NIST_CTR_DRBG_RESEED_INTERVAL + 1;
+ mutex_exit(&c->mtx);
+}
+
+static inline int
+cprng_strong_strength(cprng_strong_t *c)
+{
+ return NIST_BLOCK_KEYLEN_BYTES;
+}
+
+void cprng_init(void);
+int cprng_strong_getflags(cprng_strong_t *const);
+void cprng_strong_setflags(cprng_strong_t *const, int);
+
+#endif
--- /dev/null
+/* $NetBSD: cpu.h,v 1.36 2012/08/29 17:13:22 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CPU_H_
+#define _SYS_CPU_H_
+
+#ifndef _LOCORE
+
+#include <machine/cpu.h>
+
+#include <sys/lwp.h>
+
+struct cpu_info;
+
+#ifdef _KERNEL
+#ifndef cpu_idle
+void cpu_idle(void);
+#endif
+
+#ifdef CPU_UCODE
+#include <sys/cpuio.h>
+#include <dev/firmload.h>
+
+/* XXX ifdef COMPAT */
+#include <compat/sys/cpuio.h>
+#endif
+
+/*
+ * cpu_need_resched() must always be called with the target CPU
+ * locked (via spc_lock() or another route), unless called locally.
+ * If called locally, the caller need only be at IPL_SCHED.
+ */
+#ifndef cpu_need_resched
+void cpu_need_resched(struct cpu_info *, int);
+#endif
+
+#ifndef cpu_did_resched
+#define cpu_did_resched(l) /* nothing */
+#endif
+
+#ifndef CPU_INFO_ITERATOR
+#define CPU_INFO_ITERATOR int
+#define CPU_INFO_FOREACH(cii, ci) \
+ (void)cii, ci = curcpu(); ci != NULL; ci = NULL
+#endif
+
+#ifndef CPU_IS_PRIMARY
+#define CPU_IS_PRIMARY(ci) ((void)ci, 1)
+#endif
+
+#ifdef __HAVE_MD_CPU_OFFLINE
+void cpu_offline_md(void);
+#endif
+
+struct lwp *cpu_switchto(struct lwp *, struct lwp *, bool);
+struct cpu_info *cpu_lookup(u_int);
+int cpu_setstate(struct cpu_info *, bool);
+int cpu_setintr(struct cpu_info *, bool);
+bool cpu_intr_p(void);
+bool cpu_softintr_p(void);
+bool cpu_kpreempt_enter(uintptr_t, int);
+void cpu_kpreempt_exit(uintptr_t);
+bool cpu_kpreempt_disabled(void);
+int cpu_lwp_setprivate(struct lwp *, void *);
+void cpu_intr_redistribute(void);
+u_int cpu_intr_count(struct cpu_info *);
+#endif
+
+CIRCLEQ_HEAD(cpuqueue, cpu_info);
+
+#ifdef _KERNEL
+extern kmutex_t cpu_lock;
+extern u_int maxcpus;
+extern struct cpuqueue cpu_queue;
+extern kcpuset_t *kcpuset_attached;
+extern kcpuset_t *kcpuset_running;
+
+static inline u_int
+cpu_index(struct cpu_info *ci)
+{
+ return ci->ci_index;
+}
+
+static inline char *
+cpu_name(struct cpu_info *ci)
+{
+ return ci->ci_data.cpu_name;
+}
+
+#ifdef CPU_UCODE
+struct cpu_ucode_softc {
+ int loader_version;
+ char *sc_blob;
+ off_t sc_blobsize;
+};
+
+int cpu_ucode_get_version(struct cpu_ucode_version *);
+/* XXX ifdef COMPAT */
+int compat6_cpu_ucode_get_version(struct compat6_cpu_ucode *);
+int cpu_ucode_apply(const struct cpu_ucode *);
+/* XXX ifdef COMPAT */
+int compat6_cpu_ucode_apply(const struct compat6_cpu_ucode *);
+int cpu_ucode_load(struct cpu_ucode_softc *, const char *);
+int cpu_ucode_md_open(firmware_handle_t *, int, const char *);
+#endif
+
+#endif
+#endif /* !_LOCORE */
+
+/* flags for cpu_need_resched */
+#define RESCHED_LAZY 0x01 /* request a ctx switch */
+#define RESCHED_IMMED 0x02 /* request an immediate ctx switch */
+#define RESCHED_KPREEMPT 0x04 /* request in-kernel preemption */
+
+#endif /* !_SYS_CPU_H_ */
--- /dev/null
+/* $NetBSD: cpu_data.h,v 1.35 2012/09/01 00:24:44 matt Exp $ */
+
+/*-
+ * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * based on arch/i386/include/cpu.h:
+ * NetBSD: cpu.h,v 1.115 2004/05/16 12:32:53 yamt Exp
+ */
+
+#ifndef _SYS_CPU_DATA_H_
+#define _SYS_CPU_DATA_H_
+
+struct callout;
+struct lwp;
+
+#include <sys/sched.h> /* for schedstate_percpu */
+#include <sys/condvar.h>
+#include <sys/pcu.h>
+#include <sys/percpu_types.h>
+#include <sys/queue.h>
+#include <sys/kcpuset.h>
+
+/*
+ * MI per-cpu data
+ *
+ * this structure is intended to be included in MD cpu_info structure.
+ * struct cpu_info {
+ * struct cpu_data ci_data;
+ * }
+ *
+ * note that cpu_data is not expected to contain much data,
+ * as cpu_info is size-limited on most ports.
+ */
+
+struct lockdebug;
+
+struct cpu_data {
+ /*
+ * The first section is likely to be touched by other CPUs -
+ * it is cache hot.
+ */
+ lwp_t *cpu_biglock_wanted; /* LWP spinning on biglock */
+ void *cpu_callout; /* per-CPU callout state */
+ void *cpu_unused1; /* unused */
+ u_int cpu_unused2; /* unused */
+ struct schedstate_percpu cpu_schedstate; /* scheduler state */
+ kcondvar_t cpu_xcall; /* cross-call support */
+ int cpu_xcall_pending; /* cross-call support */
+ lwp_t *cpu_onproc; /* bottom level LWP */
+ CIRCLEQ_ENTRY(cpu_info) cpu_qchain; /* circleq of all CPUs */
+
+ cpuid_t cpu_package_id;
+ cpuid_t cpu_core_id;
+ cpuid_t cpu_smt_id;
+
+ struct lwp * volatile cpu_pcu_curlwp[PCU_UNIT_COUNT];
+
+ /*
+ * This section is mostly CPU-private.
+ */
+ lwp_t *cpu_idlelwp; /* idle lwp */
+ void *cpu_lockstat; /* lockstat private tables */
+ u_int cpu_index; /* CPU index */
+ u_int cpu_biglock_count; /* # recursive holds */
+ u_int cpu_spin_locks; /* # of spinlockmgr locks */
+ u_int cpu_simple_locks; /* # of simple locks held */
+ u_int cpu_spin_locks2; /* # of spin locks held XXX */
+ u_int cpu_lkdebug_recurse; /* LOCKDEBUG recursion */
+ u_int cpu_softints; /* pending (slow) softints */
+ uint64_t cpu_nsyscall; /* syscall counter */
+ uint64_t cpu_ntrap; /* trap counter */
+ uint64_t cpu_nswtch; /* context switch counter */
+ uint64_t cpu_nintr; /* interrupt count */
+ uint64_t cpu_nsoft; /* soft interrupt count */
+ uint64_t cpu_nfault; /* pagefault counter */
+ void *cpu_uvm; /* uvm per-cpu data */
+ void *cpu_softcpu; /* soft interrupt table */
+ TAILQ_HEAD(,buf) cpu_biodone; /* finished block xfers */
+ percpu_cpu_t cpu_percpu; /* per-cpu data */
+ struct selcluster *cpu_selcluster; /* per-CPU select() info */
+ void *cpu_nch; /* per-cpu vfs_cache data */
+ _TAILQ_HEAD(,struct lockdebug,volatile) cpu_ld_locks;/* !: lockdebug */
+ __cpu_simple_lock_t cpu_ld_lock; /* lockdebug */
+ uint64_t cpu_cc_freq; /* cycle counter frequency */
+ int64_t cpu_cc_skew; /* counter skew vs cpu0 */
+ char cpu_name[8]; /* eg, "cpu4" */
+ kcpuset_t *cpu_kcpuset; /* kcpuset_t of this cpu only */
+};
+
+/* compat definitions */
+#define ci_schedstate ci_data.cpu_schedstate
+#define ci_index ci_data.cpu_index
+#define ci_biglock_count ci_data.cpu_biglock_count
+#define ci_biglock_wanted ci_data.cpu_biglock_wanted
+#define ci_cpuname ci_data.cpu_name
+#define ci_spin_locks ci_data.cpu_spin_locks
+#define ci_simple_locks ci_data.cpu_simple_locks
+#define ci_lockstat ci_data.cpu_lockstat
+#define ci_spin_locks2 ci_data.cpu_spin_locks2
+#define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse
+#define ci_pcu_curlwp ci_data.cpu_pcu_curlwp
+#define ci_kcpuset ci_data.cpu_kcpuset
+
+#define ci_package_id ci_data.cpu_package_id
+#define ci_core_id ci_data.cpu_core_id
+#define ci_smt_id ci_data.cpu_smt_id
+
+void mi_cpu_init(void);
+int mi_cpu_attach(struct cpu_info *);
+
+#endif /* _SYS_CPU_DATA_H_ */
--- /dev/null
+/* $NetBSD: cpufreq.h,v 1.5 2011/10/27 05:13:04 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_CPUFREQ_H_
+#define _SYS_CPUFREQ_H_
+
+#ifndef _KERNEL
+#include <stdbool.h>
+#endif
+
+#ifdef _KERNEL
+#ifndef _SYS_XCALL_H_
+#include <sys/xcall.h>
+#endif
+#endif
+
+#define CPUFREQ_NAME_MAX 16
+#define CPUFREQ_STATE_MAX 32
+#define CPUFREQ_LATENCY_MAX UINT32_MAX
+
+#define CPUFREQ_STATE_ENABLED UINT32_MAX
+#define CPUFREQ_STATE_DISABLED UINT32_MAX - 1
+
+struct cpufreq_state {
+ uint32_t cfs_freq; /* MHz */
+ uint32_t cfs_power; /* mW */
+ uint32_t cfs_latency; /* usec */
+ uint32_t cfs_index;
+ uint32_t cfs_reserved[5];
+};
+
+struct cpufreq {
+ char cf_name[CPUFREQ_NAME_MAX];
+ uint32_t cf_state_count;
+ uint32_t cf_state_target;
+ uint32_t cf_state_current;
+ uint32_t cf_reserved[5];
+ u_int cf_index;
+
+#ifdef _KERNEL
+ bool cf_mp;
+ bool cf_init;
+ void *cf_cookie;
+ xcfunc_t cf_get_freq;
+ xcfunc_t cf_set_freq;
+ uint32_t cf_state_saved;
+ struct cpufreq_state cf_state[CPUFREQ_STATE_MAX];
+#endif /* _KERNEL */
+};
+
+#ifdef _KERNEL
+void cpufreq_init(void);
+int cpufreq_register(struct cpufreq *);
+void cpufreq_deregister(void);
+void cpufreq_suspend(struct cpu_info *);
+void cpufreq_resume(struct cpu_info *);
+uint32_t cpufreq_get(struct cpu_info *);
+int cpufreq_get_backend(struct cpufreq *);
+int cpufreq_get_state(uint32_t, struct cpufreq_state *);
+int cpufreq_get_state_index(uint32_t, struct cpufreq_state *);
+void cpufreq_set(struct cpu_info *, uint32_t);
+void cpufreq_set_all(uint32_t);
+#endif /* _KERNEL */
+
+#endif /* _SYS_CPUFREQ_H_ */
--- /dev/null
+/* $NetBSD: cpuio.h,v 1.8 2012/08/29 17:13:22 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007, 2009, 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_CPUIO_H_)
+#define _SYS_CPUIO_H_
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioccom.h>
+
+#ifndef _KERNEL
+#include <limits.h>
+#include <stdbool.h>
+#endif
+
+/*
+ * This is not a great place to describe CPU properties, those
+ * are better returned via autoconf.
+ */
+typedef struct cpustate {
+ u_int cs_id; /* matching ci_cpuid */
+ bool cs_online; /* running unbound LWPs */
+ bool cs_intr; /* fielding interrupts */
+ bool cs_unused[2]; /* reserved */
+ int32_t cs_lastmod; /* time of last state change */
+ char cs_name[16]; /* reserved */
+ int32_t cs_lastmodhi; /* time of last state change */
+ uint32_t cs_intrcnt; /* count of interrupt handlers + 1 */
+ uint32_t cs_hwid; /* hardware id */
+ uint32_t cs_reserved; /* reserved */
+} cpustate_t;
+
+#define IOC_CPU_SETSTATE _IOW('c', 0, cpustate_t)
+#define IOC_CPU_GETSTATE _IOWR('c', 1, cpustate_t)
+#define IOC_CPU_GETCOUNT _IOR('c', 2, int)
+#define IOC_CPU_MAPID _IOWR('c', 3, int)
+/* 4 and 5 reserved for compat nb6 x86 amd ucode loader */
+
+struct cpu_ucode_version {
+ int loader_version; /* IN: md version number */
+ void *data; /* OUT: CPU ID data */
+};
+
+struct cpu_ucode {
+ int loader_version; /* md version number */
+ int cpu_nr; /* CPU index or special value below */
+#define CPU_UCODE_ALL_CPUS (-1)
+#define CPU_UCODE_CURRENT_CPU (-2)
+ char fwname[PATH_MAX];
+};
+
+#define IOC_CPU_UCODE_GET_VERSION _IOWR('c', 6, struct cpu_ucode_version)
+#define IOC_CPU_UCODE_APPLY _IOW('c', 7, struct cpu_ucode)
+
+#endif /* !_SYS_CPUIO_H_ */
--- /dev/null
+/* $NetBSD: debug.h,v 1.4 2012/04/15 19:07:40 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SYS_DEBUG_H__
+#define __SYS_DEBUG_H__
+
+#ifndef _KERNEL
+#error "Sorry, nothing of interest to user level programs here."
+#endif
+
+void debug_init(void);
+
+void freecheck_out(void **, void *);
+void freecheck_in(void **, void *);
+
+#if defined(DEBUG) && defined(_HARDKERNEL)
+#define FREECHECK_OUT(h, a) freecheck_out((h), (a))
+#define FREECHECK_IN(h, a) freecheck_in((h), (a))
+#else
+#define FREECHECK_OUT(h, a) /* nothing */
+#define FREECHECK_IN(h, a) /* nothing */
+#endif
+
+#endif /* __SYS_DEBUG_H__ */
--- /dev/null
+/* $NetBSD: device.h,v 1.142 2012/07/07 16:15:21 tsutsui Exp $ */
+
+/*
+ * Copyright (c) 1996, 2000 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the
+ * NetBSD Project. See http://www.NetBSD.org/ for
+ * information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )--
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratories.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)device.h 8.2 (Berkeley) 2/17/94
+ */
+
+#ifndef _SYS_DEVICE_H_
+#define _SYS_DEVICE_H_
+
+#include <sys/device_if.h>
+#include <sys/evcnt.h>
+#include <sys/queue.h>
+
+#ifdef _KERNEL
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/pmf.h>
+#endif
+
+#include <prop/proplib.h>
+
+/*
+ * Minimal device structures.
+ * Note that all ``system'' device types are listed here.
+ */
+typedef enum devclass {
+ DV_DULL, /* generic, no special info */
+ DV_CPU, /* CPU (carries resource utilization) */
+ DV_DISK, /* disk drive (label, etc) */
+ DV_IFNET, /* network interface */
+ DV_TAPE, /* tape device */
+ DV_TTY, /* serial line interface (?) */
+ DV_AUDIODEV, /* audio device */
+ DV_DISPLAYDEV, /* display device */
+ DV_BUS, /* bus device */
+ DV_VIRTUAL, /* unbacked virtual device */
+} devclass_t;
+
+/*
+ * Actions for ca_activate.
+ */
+typedef enum devact {
+ DVACT_DEACTIVATE /* deactivate the device */
+} devact_t;
+
+typedef enum {
+ DVA_SYSTEM,
+ DVA_HARDWARE
+} devactive_t;
+
+typedef struct cfdata *cfdata_t;
+typedef struct cfdriver *cfdriver_t;
+typedef struct cfattach *cfattach_t;
+
+#ifdef _KERNEL
+struct device_lock {
+ int dvl_nwait;
+ int dvl_nlock;
+ lwp_t *dvl_holder;
+ kmutex_t dvl_mtx;
+ kcondvar_t dvl_cv;
+};
+
+struct device_suspensor {
+ const device_suspensor_t *ds_delegator;
+ char ds_name[32];
+};
+
+#define DEVICE_SUSPENSORS_MAX 16
+
+struct device {
+ devclass_t dv_class; /* this device's classification */
+ TAILQ_ENTRY(device) dv_list; /* entry on list of all devices */
+ cfdata_t dv_cfdata; /* config data that found us
+ (NULL if pseudo-device) */
+ cfdriver_t dv_cfdriver; /* our cfdriver */
+ cfattach_t dv_cfattach; /* our cfattach */
+ int dv_unit; /* device unit number */
+ char dv_xname[16]; /* external name (name + unit) */
+ device_t dv_parent; /* pointer to parent device
+ (NULL if pseudo- or root node) */
+ int dv_depth; /* number of parents until root */
+ int dv_flags; /* misc. flags; see below */
+ void *dv_private; /* this device's private storage */
+ int *dv_locators; /* our actual locators (optional) */
+ prop_dictionary_t dv_properties;/* properties dictionary */
+
+ size_t dv_activity_count;
+ void (**dv_activity_handlers)(device_t, devactive_t);
+
+ bool (*dv_driver_suspend)(device_t, const pmf_qual_t *);
+ bool (*dv_driver_resume)(device_t, const pmf_qual_t *);
+ bool (*dv_driver_shutdown)(device_t, int);
+ bool (*dv_driver_child_register)(device_t);
+
+ void *dv_bus_private;
+ bool (*dv_bus_suspend)(device_t, const pmf_qual_t *);
+ bool (*dv_bus_resume)(device_t, const pmf_qual_t *);
+ bool (*dv_bus_shutdown)(device_t, int);
+ void (*dv_bus_deregister)(device_t);
+
+ void *dv_class_private;
+ bool (*dv_class_suspend)(device_t, const pmf_qual_t *);
+ bool (*dv_class_resume)(device_t, const pmf_qual_t *);
+ void (*dv_class_deregister)(device_t);
+
+ devgen_t dv_add_gen,
+ dv_del_gen;
+
+ struct device_lock dv_lock;
+ const device_suspensor_t
+ *dv_bus_suspensors[DEVICE_SUSPENSORS_MAX],
+ *dv_driver_suspensors[DEVICE_SUSPENSORS_MAX],
+ *dv_class_suspensors[DEVICE_SUSPENSORS_MAX];
+ struct device_garbage {
+ device_t *dg_devs;
+ int dg_ndevs;
+ } dv_garbage;
+};
+
+/* dv_flags */
+#define DVF_ACTIVE 0x0001 /* device is activated */
+#define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */
+#define DVF_POWER_HANDLERS 0x0004 /* device has suspend/resume support */
+#define DVF_CLASS_SUSPENDED 0x0008 /* device class suspend was called */
+#define DVF_DRIVER_SUSPENDED 0x0010 /* device driver suspend was called */
+#define DVF_BUS_SUSPENDED 0x0020 /* device bus suspend was called */
+#define DVF_DETACH_SHUTDOWN 0x0080 /* device detaches safely at shutdown */
+
+TAILQ_HEAD(devicelist, device);
+
+enum deviter_flags {
+ DEVITER_F_RW = 0x1
+ , DEVITER_F_SHUTDOWN = 0x2
+ , DEVITER_F_LEAVES_FIRST = 0x4
+ , DEVITER_F_ROOT_FIRST = 0x8
+};
+
+typedef enum deviter_flags deviter_flags_t;
+
+struct deviter {
+ device_t di_prev;
+ deviter_flags_t di_flags;
+ int di_curdepth;
+ int di_maxdepth;
+ devgen_t di_gen;
+};
+
+typedef struct deviter deviter_t;
+
+struct shutdown_state {
+ bool initialized;
+ deviter_t di;
+};
+#endif
+
+/*
+ * Description of a locator, as part of interface attribute definitions.
+ */
+struct cflocdesc {
+ const char *cld_name;
+ const char *cld_defaultstr; /* NULL if no default */
+ int cld_default;
+};
+
+/*
+ * Description of an interface attribute, provided by potential
+ * parent device drivers, referred to by child device configuration data.
+ */
+struct cfiattrdata {
+ const char *ci_name;
+ int ci_loclen;
+ const struct cflocdesc ci_locdesc[
+#if defined(__GNUC__) && __GNUC__ <= 2
+ 0
+#endif
+ ];
+};
+
+/*
+ * Description of a configuration parent. Each device attachment attaches
+ * to an "interface attribute", which is given in this structure. The parent
+ * *must* carry this attribute. Optionally, an individual device instance
+ * may also specify a specific parent device instance.
+ */
+struct cfparent {
+ const char *cfp_iattr; /* interface attribute */
+ const char *cfp_parent; /* optional specific parent */
+ int cfp_unit; /* optional specific unit
+ (DVUNIT_ANY to wildcard) */
+};
+
+/*
+ * Configuration data (i.e., data placed in ioconf.c).
+ */
+struct cfdata {
+ const char *cf_name; /* driver name */
+ const char *cf_atname; /* attachment name */
+ short cf_unit; /* unit number */
+ short cf_fstate; /* finding state (below) */
+ int *cf_loc; /* locators (machine dependent) */
+ int cf_flags; /* flags from config */
+ const struct cfparent *cf_pspec;/* parent specification */
+};
+#define FSTATE_NOTFOUND 0 /* has not been found */
+#define FSTATE_FOUND 1 /* has been found */
+#define FSTATE_STAR 2 /* duplicable */
+#define FSTATE_DSTAR 3 /* has not been found, and disabled */
+#define FSTATE_DNOTFOUND 4 /* duplicate, and disabled */
+
+/*
+ * Multiple configuration data tables may be maintained. This structure
+ * provides the linkage.
+ */
+struct cftable {
+ cfdata_t ct_cfdata; /* pointer to cfdata table */
+ TAILQ_ENTRY(cftable) ct_list; /* list linkage */
+};
+TAILQ_HEAD(cftablelist, cftable);
+
+typedef int (*cfsubmatch_t)(device_t, cfdata_t, const int *, void *);
+
+/*
+ * `configuration' attachment and driver (what the machine-independent
+ * autoconf uses). As devices are found, they are applied against all
+ * the potential matches. The one with the best match is taken, and a
+ * device structure (plus any other data desired) is allocated. Pointers
+ * to these are placed into an array of pointers. The array itself must
+ * be dynamic since devices can be found long after the machine is up
+ * and running.
+ *
+ * Devices can have multiple configuration attachments if they attach
+ * to different attributes (busses, or whatever), to allow specification
+ * of multiple match and attach functions. There is only one configuration
+ * driver per driver, so that things like unit numbers and the device
+ * structure array will be shared.
+ */
+struct cfattach {
+ const char *ca_name; /* name of attachment */
+ LIST_ENTRY(cfattach) ca_list; /* link on cfdriver's list */
+ size_t ca_devsize; /* size of dev data (for alloc) */
+ int ca_flags; /* flags for driver allocation etc */
+ int (*ca_match)(device_t, cfdata_t, void *);
+ void (*ca_attach)(device_t, device_t, void *);
+ int (*ca_detach)(device_t, int);
+ int (*ca_activate)(device_t, devact_t);
+ /* technically, the next 2 belong into "struct cfdriver" */
+ int (*ca_rescan)(device_t, const char *,
+ const int *); /* scan for new children */
+ void (*ca_childdetached)(device_t, device_t);
+};
+LIST_HEAD(cfattachlist, cfattach);
+
+#define CFATTACH_DECL(name, ddsize, matfn, attfn, detfn, actfn) \
+struct cfattach __CONCAT(name,_ca) = { \
+ .ca_name = ___STRING(name), \
+ .ca_devsize = ddsize, \
+ .ca_flags = 0, \
+ .ca_match = matfn, \
+ .ca_attach = attfn, \
+ .ca_detach = detfn, \
+ .ca_activate = actfn, \
+ .ca_rescan = NULL, \
+ .ca_childdetached = NULL, \
+}
+
+#define CFATTACH_DECL3_NEW(name, ddsize, matfn, attfn, detfn, actfn, \
+ rescanfn, chdetfn, __flags) \
+struct cfattach __CONCAT(name,_ca) = { \
+ .ca_name = ___STRING(name), \
+ .ca_devsize = ddsize, \
+ .ca_flags = (__flags) | DVF_PRIV_ALLOC, \
+ .ca_match = matfn, \
+ .ca_attach = attfn, \
+ .ca_detach = detfn, \
+ .ca_activate = actfn, \
+ .ca_rescan = rescanfn, \
+ .ca_childdetached = chdetfn, \
+}
+
+#define CFATTACH_DECL2_NEW(name, ddsize, matfn, attfn, detfn, actfn, \
+ rescanfn, chdetfn) \
+ CFATTACH_DECL3_NEW(name, ddsize, matfn, attfn, detfn, actfn, \
+ rescanfn, chdetfn, 0)
+
+#define CFATTACH_DECL_NEW(name, ddsize, matfn, attfn, detfn, actfn) \
+ CFATTACH_DECL2_NEW(name, ddsize, matfn, attfn, detfn, actfn, NULL, NULL)
+
+/* Flags given to config_detach(), and the ca_detach function. */
+#define DETACH_FORCE 0x01 /* force detachment; hardware gone */
+#define DETACH_QUIET 0x02 /* don't print a notice */
+#define DETACH_SHUTDOWN 0x04 /* detach because of system shutdown */
+
+struct cfdriver {
+ LIST_ENTRY(cfdriver) cd_list; /* link on allcfdrivers */
+ struct cfattachlist cd_attach; /* list of all attachments */
+ device_t *cd_devs; /* devices found */
+ const char *cd_name; /* device name */
+ enum devclass cd_class; /* device classification */
+ int cd_ndevs; /* size of cd_devs array */
+ const struct cfiattrdata * const *cd_attrs; /* attributes provided */
+};
+LIST_HEAD(cfdriverlist, cfdriver);
+
+#define CFDRIVER_DECL(name, class, attrs) \
+struct cfdriver __CONCAT(name,_cd) = { \
+ .cd_name = ___STRING(name), \
+ .cd_class = class, \
+ .cd_attrs = attrs, \
+}
+
+/*
+ * The cfattachinit is a data structure used to associate a list of
+ * cfattach's with cfdrivers as found in the static kernel configuration.
+ */
+struct cfattachinit {
+ const char *cfai_name; /* driver name */
+ struct cfattach * const *cfai_list;/* list of attachments */
+};
+/*
+ * the same, but with a non-constant list so it can be modified
+ * for module bookkeeping
+ */
+struct cfattachlkminit {
+ const char *cfai_name; /* driver name */
+ struct cfattach **cfai_list; /* list of attachments */
+};
+
+/*
+ * Configuration printing functions, and their return codes. The second
+ * argument is NULL if the device was configured; otherwise it is the name
+ * of the parent device. The return value is ignored if the device was
+ * configured, so most functions can return UNCONF unconditionally.
+ */
+typedef int (*cfprint_t)(void *, const char *); /* XXX const char * */
+#define QUIET 0 /* print nothing */
+#define UNCONF 1 /* print " not configured\n" */
+#define UNSUPP 2 /* print " not supported\n" */
+
+/*
+ * Pseudo-device attach information (function + number of pseudo-devs).
+ */
+struct pdevinit {
+ void (*pdev_attach)(int);
+ int pdev_count;
+};
+
+/* This allows us to wildcard a device unit. */
+#define DVUNIT_ANY -1
+
+#ifdef _KERNEL
+
+extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */
+extern struct cftablelist allcftables; /* list of all cfdata tables */
+extern device_t booted_device; /* the device we booted from */
+extern int booted_partition; /* the partition on that device */
+extern daddr_t booted_startblk; /* or the start of a wedge */
+extern uint64_t booted_nblks; /* and the size of that wedge */
+
+struct vnode *opendisk(struct device *);
+int getdisksize(struct vnode *, uint64_t *, unsigned int *);
+struct dkwedge_info;
+int getdiskinfo(struct vnode *, struct dkwedge_info *);
+
+void config_init(void);
+int config_init_component(struct cfdriver *const*,
+ const struct cfattachinit *, struct cfdata *);
+int config_fini_component(struct cfdriver *const*,
+ const struct cfattachinit *, struct cfdata *);
+void config_init_mi(void);
+void drvctl_init(void);
+
+int config_cfdriver_attach(struct cfdriver *);
+int config_cfdriver_detach(struct cfdriver *);
+
+int config_cfattach_attach(const char *, struct cfattach *);
+int config_cfattach_detach(const char *, struct cfattach *);
+
+int config_cfdata_attach(cfdata_t, int);
+int config_cfdata_detach(cfdata_t);
+
+struct cfdriver *config_cfdriver_lookup(const char *);
+struct cfattach *config_cfattach_lookup(const char *, const char *);
+const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *);
+
+const char *cfdata_ifattr(const struct cfdata *);
+
+int config_stdsubmatch(device_t, cfdata_t, const int *, void *);
+cfdata_t config_search_loc(cfsubmatch_t, device_t,
+ const char *, const int *, void *);
+cfdata_t config_search_ia(cfsubmatch_t, device_t,
+ const char *, void *);
+cfdata_t config_rootsearch(cfsubmatch_t, const char *, void *);
+device_t config_found_sm_loc(device_t, const char *, const int *,
+ void *, cfprint_t, cfsubmatch_t);
+device_t config_found_ia(device_t, const char *, void *, cfprint_t);
+device_t config_found(device_t, void *, cfprint_t);
+device_t config_rootfound(const char *, void *);
+device_t config_attach_loc(device_t, cfdata_t, const int *, void *, cfprint_t);
+device_t config_attach(device_t, cfdata_t, void *, cfprint_t);
+int config_match(device_t, cfdata_t, void *);
+
+bool ifattr_match(const char *, const char *);
+
+device_t config_attach_pseudo(cfdata_t);
+
+int config_detach(device_t, int);
+int config_detach_children(device_t, int flags);
+bool config_detach_all(int);
+int config_deactivate(device_t);
+void config_defer(device_t, void (*)(device_t));
+void config_deferred(device_t);
+void config_interrupts(device_t, void (*)(device_t));
+void config_mountroot(device_t, void (*)(device_t));
+void config_pending_incr(void);
+void config_pending_decr(void);
+void config_create_interruptthreads(void);
+void config_create_mountrootthreads(void);
+
+int config_finalize_register(device_t, int (*)(device_t));
+void config_finalize(void);
+
+void config_twiddle_init(void);
+void config_twiddle_fn(void *);
+
+void null_childdetached(device_t, device_t);
+
+device_t device_lookup(cfdriver_t, int);
+void *device_lookup_private(cfdriver_t, int);
+void device_register(device_t, void *);
+void device_register_post_config(device_t, void *);
+
+devclass_t device_class(device_t);
+cfdata_t device_cfdata(device_t);
+cfdriver_t device_cfdriver(device_t);
+cfattach_t device_cfattach(device_t);
+int device_unit(device_t);
+const char *device_xname(device_t);
+device_t device_parent(device_t);
+bool device_is_active(device_t);
+bool device_activation(device_t, devact_level_t);
+bool device_is_enabled(device_t);
+bool device_has_power(device_t);
+int device_locator(device_t, u_int);
+void *device_private(device_t);
+prop_dictionary_t device_properties(device_t);
+
+device_t deviter_first(deviter_t *, deviter_flags_t);
+void deviter_init(deviter_t *, deviter_flags_t);
+device_t deviter_next(deviter_t *);
+void deviter_release(deviter_t *);
+
+bool device_active(device_t, devactive_t);
+bool device_active_register(device_t,
+ void (*)(device_t, devactive_t));
+void device_active_deregister(device_t,
+ void (*)(device_t, devactive_t));
+
+bool device_is_a(device_t, const char *);
+
+device_t device_find_by_xname(const char *);
+device_t device_find_by_driver_unit(const char *, int);
+
+bool device_pmf_is_registered(device_t);
+
+bool device_pmf_driver_suspend(device_t, const pmf_qual_t *);
+bool device_pmf_driver_resume(device_t, const pmf_qual_t *);
+bool device_pmf_driver_shutdown(device_t, int);
+
+bool device_pmf_driver_register(device_t,
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, int));
+void device_pmf_driver_deregister(device_t);
+
+bool device_pmf_driver_child_register(device_t);
+void device_pmf_driver_set_child_register(device_t,
+ bool (*)(device_t));
+
+void *device_pmf_bus_private(device_t);
+bool device_pmf_bus_suspend(device_t, const pmf_qual_t *);
+bool device_pmf_bus_resume(device_t, const pmf_qual_t *);
+bool device_pmf_bus_shutdown(device_t, int);
+
+device_lock_t device_getlock(device_t);
+void device_pmf_unlock(device_t);
+bool device_pmf_lock(device_t);
+
+bool device_is_self_suspended(device_t);
+void device_pmf_self_suspend(device_t, const pmf_qual_t *);
+void device_pmf_self_resume(device_t, const pmf_qual_t *);
+bool device_pmf_self_wait(device_t, const pmf_qual_t *);
+
+void device_pmf_bus_register(device_t, void *,
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, int),
+ void (*)(device_t));
+void device_pmf_bus_deregister(device_t);
+
+void *device_pmf_class_private(device_t);
+bool device_pmf_class_suspend(device_t, const pmf_qual_t *);
+bool device_pmf_class_resume(device_t, const pmf_qual_t *);
+
+void device_pmf_class_register(device_t, void *,
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, const pmf_qual_t *),
+ void (*)(device_t));
+void device_pmf_class_deregister(device_t);
+
+device_t shutdown_first(struct shutdown_state *);
+device_t shutdown_next(struct shutdown_state *);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_DEVICE_H_ */
--- /dev/null
+/* $NetBSD: device_if.h,v 1.5 2010/02/24 22:38:10 dyoung Exp $ */
+
+#ifndef _SYS_DEVICE_IF_H
+#define _SYS_DEVICE_IF_H
+
+struct device;
+typedef struct device *device_t;
+
+#ifdef _KERNEL
+typedef enum devact_level {
+ DEVACT_LEVEL_CLASS = 0
+ , DEVACT_LEVEL_DRIVER = 1
+ , DEVACT_LEVEL_BUS = 2
+} devact_level_t;
+
+#define DEVACT_LEVEL_FULL DEVACT_LEVEL_CLASS
+
+struct device_lock;
+struct device_suspensor;
+
+typedef uint64_t devgen_t;
+
+typedef struct device_lock *device_lock_t;
+typedef struct device_suspensor device_suspensor_t;
+#endif
+
+#endif /* _SYS_DEVICE_IF_H */
--- /dev/null
+/* $NetBSD: devmon.h,v 1.1 2008/05/25 12:30:40 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 2007
+ * Jachym Holecek <freza@NetBSD.org>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <prop/proplib.h>
+
+#ifndef _SYS_DEVMON_H_
+#define _SYS_DEVMON_H_
+
+void devmon_insert(const char *, prop_dictionary_t);
+
+#endif /*_SYS_DEVMON_H_*/
--- /dev/null
+/* $NetBSD: dir.h,v 1.11 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dir.h 8.2 (Berkeley) 1/4/94
+ */
+
+/*
+ * The information in this file should be obtained from <dirent.h>
+ * and is provided solely (and temporarily) for backward compatibility.
+ */
+
+#ifndef _SYS_DIR_H_
+#define _SYS_DIR_H_
+
+#ifdef _KERNEL
+/* This file should only be used by old user-level code. */
+#error "Please use <sys/dirent.h> instead"
+#endif
+
+#include <dirent.h>
+
+/*
+ * Backwards compatibility.
+ */
+#define direct dirent
+
+/*
+ * The DIRSIZ macro gives the minimum record length which will hold
+ * the directory entry. This requires the amount of space in struct direct
+ * without the d_name field, plus enough space for the name with a terminating
+ * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ */
+#undef DIRSIZ
+#define DIRSIZ(dp) \
+ ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+
+#endif /* !_SYS_DIR_H_ */
+/* $NetBSD: dirent.h,v 1.28 2011/09/27 01:40:32 christos Exp $ */
+
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dirent.h 8.3 (Berkeley) 8/10/94
+ */
+
#ifndef _SYS_DIRENT_H_
#define _SYS_DIRENT_H_
-#include <sys/cdefs.h>
#include <sys/featuretest.h>
-#include <minix/dirent.h>
/*
* The dirent structure defines the format of directory entries returned by
* the getdents(2) system call.
+ *
+ * A directory entry has a struct dirent at the front of it, containing its
+ * inode number, the length of the entry, and the length of the name
+ * contained in the entry. These are followed by the name padded to
+ * _DIRENT_ALIGN() byte boundary with null bytes. All names are guaranteed
+ * NUL terminated. The maximum length of a name in a directory is MAXNAMLEN.
*/
-
-struct dirent { /* Largest entry (8 slots) */
- ino_t d_ino; /* I-node number */
- off_t d_off; /* Offset in directory */
- unsigned short d_reclen; /* Length of this record */
- char d_name[1]; /* Null terminated name */
+struct dirent {
+ ino_t d_fileno; /* file number of entry */
+ uint16_t d_reclen; /* length of this record */
+ uint16_t d_namlen; /* length of string in d_name */
+ uint8_t d_type; /* file type, see below */
+#if defined(_NETBSD_SOURCE)
+#define MAXNAMLEN 511 /* must be kept in sync with NAME_MAX */
+ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
+#else
+ char d_name[511 + 1]; /* name must be no longer than this */
+#endif
};
#if defined(_NETBSD_SOURCE)
-#define MAXNAMLEN 511
-#define d_fileno d_ino
-#endif
+/*
+ * File types
+ */
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+/*
+ * Caution: the following macros are used by the ufs/ffs code on ffs's
+ * struct direct as well as the exposed struct dirent. The two
+ * structures are not the same, so it's important (until ufs is fixed,
+ * XXX) that the macro definitions remain type-polymorphic.
+ */
/*
- * The _DIRENT_ALIGN macro returns the alignment of struct dirent. It
- * is used to check for bogus pointers and to calculate in advance the
- * memory required to store a dirent.
- * Unfortunately Minix doesn't use any standard alignment in dirents
- * at the moment, so, in order to calculate a safe dirent size, we add
- * an arbitrary number of bytes to the structure (_DIRENT_PAD), and we
- * set _DIRENT_ALIGN to zero to pass the pointers checks.
- * Please, FIXME.
- */
-#define _DIRENT_ALIGN(dp) 0
-#define _DIRENT_PAD 64
+ * The _DIRENT_ALIGN macro returns the alignment of struct dirent.
+ * struct direct and struct dirent12 used 4 byte alignment but
+ * struct dirent uses 8.
+ */
+#define _DIRENT_ALIGN(dp) (sizeof((dp)->d_fileno) - 1)
/*
* The _DIRENT_NAMEOFF macro returns the offset of the d_name field in
* struct dirent
*/
+#if __GNUC_PREREQ__(4, 0)
+#define _DIRENT_NAMEOFF(dp) __builtin_offsetof(__typeof__(*dp), d_name)
+#else
#define _DIRENT_NAMEOFF(dp) \
((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
+#endif
/*
* The _DIRENT_RECLEN macro gives the minimum record length which will hold
- * a name of size "namlen".
+ * a name of size "namlen". This requires the amount of space in struct dirent
+ * without the d_name field, plus enough space for the name with a terminating
+ * null byte (namlen+1), rounded up to a the appropriate byte boundary.
*/
#define _DIRENT_RECLEN(dp, namlen) \
- ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_PAD + _DIRENT_ALIGN(dp)) & \
+ ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \
~_DIRENT_ALIGN(dp))
/*
* The _DIRENT_SIZE macro returns the minimum record length required for
* name name stored in the current record.
*/
-#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, strlen(dp->d_name))
+#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, (dp)->d_namlen)
/*
* The _DIRENT_NEXT macro advances to the next dirent record.
*/
*/
#define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0)
+/*
+ * Convert between stat structure types and directory types.
+ */
+#define IFTODT(mode) (((mode) & 0170000) >> 12)
+#define DTTOIF(dirtype) ((dirtype) << 12)
+#endif
+
#endif /* !_SYS_DIRENT_H_ */
--- /dev/null
+/* $NetBSD: dirhash.h,v 1.5 2009/09/27 21:50:48 reinoud Exp $ */
+
+/*
+ * Copyright (c) 2008 Reinoud Zandijk
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_DIRHASH_H_
+#define _SYS_DIRHASH_H_
+
+#include <sys/queue.h>
+#include <sys/dirent.h>
+
+#ifndef DIRHASH_SIZE
+#define DIRHASH_SIZE (1024*1024)
+#endif
+
+#define DIRHASH_HASHBITS 5
+#define DIRHASH_HASHSIZE (1 << DIRHASH_HASHBITS)
+#define DIRHASH_HASHMASK (DIRHASH_HASHSIZE - 1)
+
+/* dirent's d_namlen is to avoid useless costly fid->dirent translations */
+struct dirhash_entry {
+ uint32_t hashvalue;
+ uint64_t offset;
+ uint32_t d_namlen;
+ uint32_t entry_size;
+ LIST_ENTRY(dirhash_entry) next;
+};
+
+struct dirhash {
+ uint32_t flags;
+ uint32_t size; /* in bytes */
+ uint32_t refcnt;
+ LIST_HEAD(, dirhash_entry) entries[DIRHASH_HASHSIZE];
+ LIST_HEAD(, dirhash_entry) free_entries;
+ TAILQ_ENTRY(dirhash) next;
+};
+
+#define DIRH_PURGED 0x0001 /* dirhash has been purged */
+#define DIRH_COMPLETE 0x0002 /* dirhash is complete */
+#define DIRH_BROKEN 0x0004 /* dirhash is broken on readin */
+#define DIRH_COMPACTABLE 0x0008 /* free space can be compacted */
+#define DIRH_FLAGBITS "\10\1PURGED\2COMPLETE\3BROKEN\4COMPACTABLE"
+
+void dirhash_init(void);
+/* void dirhash_finish(void); */
+
+void dirhash_purge(struct dirhash **);
+void dirhash_purge_entries(struct dirhash *);
+void dirhash_get(struct dirhash **);
+void dirhash_put(struct dirhash *);
+void dirhash_enter(struct dirhash *, struct dirent *, uint64_t,
+ uint32_t, int);
+void dirhash_enter_freed(struct dirhash *, uint64_t, uint32_t);
+void dirhash_remove(struct dirhash *, struct dirent *dirent,
+ uint64_t, uint32_t);
+int dirhash_lookup(struct dirhash *, const char *, int,
+ struct dirhash_entry **);
+int dirhash_lookup_freed(struct dirhash *, uint32_t,
+ struct dirhash_entry **);
+
+#endif /* _SYS_DIRHASH_H_ */
--- /dev/null
+/* $NetBSD: disklabel_rdb.h,v 1.2 2010/06/19 08:45:25 kiyohara Exp $ */
+
+/*
+ * Copyright (c) 1994 Christian E. Hopps
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christian E. Hopps.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_DISKLABEL_RDB_H_
+#define _SYS_DISKLABEL_RDB_H_
+
+/*
+ * describes ados Rigid Disk Blocks
+ * which are used to partition a drive
+ */
+#define RDBNULL ((u_long)0xffffffff)
+
+/*
+ * you will find rdblock somewhere in [0, RDBMAXBLOCKS)
+ */
+#define RDB_MAXBLOCKS 16
+
+struct rdblock {
+ u_long id; /* 'RDSK' */
+ u_long nsumlong; /* number of longs in check sum */
+ u_long chksum; /* simple additive with wrap checksum */
+ u_long hostid; /* scsi target of host */
+ u_long nbytes; /* size of disk blocks */
+ u_long flags;
+ u_long badbhead; /* linked list of badblocks */
+ u_long partbhead; /* linked list of partblocks */
+ u_long fsbhead; /* " " of fsblocks */
+ u_long driveinit;
+ u_long resv1[6]; /* RDBNULL */
+ u_long ncylinders; /* number of cylinders on drive */
+ u_long nsectors; /* number of sectors per track */
+ u_long nheads; /* number of tracks per cylinder */
+ u_long interleave;
+ u_long park; /* only used with st506 i.e. not */
+ u_long resv2[3];
+ u_long wprecomp; /* start cyl for write precomp */
+ u_long reducedwrite; /* start cyl for reduced write current */
+ u_long steprate; /* driver step rate in ?s */
+ u_long resv3[5];
+ u_long rdblowb; /* lowblock of range for rdb's */
+ u_long rdbhighb; /* high block of range for rdb's */
+ u_long lowcyl; /* low cylinder of partition area */
+ u_long highcyl; /* upper cylinder of partition area */
+ u_long secpercyl; /* number of sectors per cylinder */
+ u_long parkseconds; /* zero if no park needed */
+ u_long resv4[2];
+ char diskvendor[8]; /* inquiry stuff */
+ char diskproduct[16]; /* inquiry stuff */
+ char diskrevision[4]; /* inquiry stuff */
+ char contvendor[8]; /* inquiry stuff */
+ char contproduct[16]; /* inquiry stuff */
+ char contrevision[4]; /* inquiry stuff */
+#if never_use_secsize
+ u_long resv5[0];
+#endif
+};
+
+
+#define RDBF_LAST 0x1 /* last drive available */
+#define RDBF_LASTLUN 0x2 /* last LUN available */
+#define RDBF_LASTUNIT 0x4 /* last target available */
+#define RDBF_NORESELECT 0x8 /* do not use reselect */
+#define RDBF_DISKID 0x10 /* disk id is valid ?? */
+#define RDBF_CTRLID 0x20 /* ctrl id is valid ?? */
+#define RDBF_SYNC 0x40 /* drive supports SCSI synchronous mode */
+
+struct ados_environ {
+ u_long tabsize; /* 0: environ table size */
+ u_long sizeblock; /* 1: n long words in a block */
+ u_long secorg; /* 2: not used must be zero */
+ u_long numheads; /* 3: number of surfaces */
+ u_long secperblk; /* 4: must be 1 */
+ u_long secpertrk; /* 5: blocks per track */
+ u_long resvblocks; /* 6: reserved blocks at start */
+ u_long prefac; /* 7: must be 0 */
+ u_long interleave; /* 8: normally 1 */
+ u_long lowcyl; /* 9: low cylinder of partition */
+ u_long highcyl; /* 10: upper cylinder of partition */
+ u_long numbufs; /* 11: ados: number of buffers */
+ u_long membuftype; /* 12: ados: type of bufmem */
+ u_long maxtrans; /* 13: maxtrans the ctrlr supports */
+ u_long mask; /* 14: mask for valid address */
+ u_long bootpri; /* 15: boot priority for autoboot */
+ u_long dostype; /* 16: filesystem type */
+ u_long baud; /* 17: serial handler baud rate */
+ u_long control; /* 18: control word for fs */
+ u_long bootblocks; /* 19: blocks containing boot code */
+ u_long fsize; /* 20: file system block size */
+ u_long frag; /* 21: allowable frags per block */
+ u_long cpg; /* 22: cylinders per group */
+};
+
+struct partblock {
+ u_long id; /* 'PART' */
+ u_long nsumlong; /* number of longs in check sum */
+ u_long chksum; /* simple additive with wrap checksum */
+ u_long hostid; /* scsi target of host */
+ u_long next; /* next in chain */
+ u_long flags; /* see below */
+ u_long resv1[3];
+ u_char partname[32]; /* (BCPL) part name (may not be unique) */
+ u_long resv2[15];
+ struct ados_environ e;
+#if never_use_secsize
+ u_long extra[9]; /* 8 for extra added to environ */
+#endif
+};
+
+#define PBF_BOOTABLE 0x1 /* partition is bootable */
+#define PBF_NOMOUNT 0x2 /* partition should be mounted */
+
+struct badblock {
+ u_long id; /* 'BADB' */
+ u_long nsumlong; /* number of longs in check sum */
+ u_long chksum; /* simple additive with wrap checksum */
+ u_long hostid; /* scsi target of host */
+ u_long next; /* next in chain */
+ u_long resv;
+ struct badblockent {
+ u_long badblock;
+ u_long goodblock;
+ } badtab[0]; /* 61 for secsize == 512 */
+};
+
+struct fsblock {
+ u_long id; /* 'FSHD' */
+ u_long nsumlong; /* number of longs in check sum */
+ u_long chksum; /* simple additive with wrap checksum */
+ u_long hostid; /* scsi target of host */
+ u_long next; /* next in chain */
+ u_long flags;
+ u_long resv1[2];
+ u_long dostype; /* this is a file system for this type */
+ u_long version; /* version of this fs */
+ u_long patchflags; /* describes which functions to replace */
+ u_long type; /* zero */
+ u_long task; /* zero */
+ u_long lock; /* zero */
+ u_long handler; /* zero */
+ u_long stacksize; /* to use when loading handler */
+ u_long priority; /* to run the fs at. */
+ u_long startup; /* zero */
+ u_long lsegblocks; /* linked list of lsegblocks of fs code */
+ u_long globalvec; /* bcpl vector not used mostly */
+#if never_use_secsize
+ u_long resv2[44];
+#endif
+};
+
+struct lsegblock {
+ u_long id; /* 'LSEG' */
+ u_long nsumlong; /* number of longs in check sum */
+ u_long chksum; /* simple additive with wrap checksum */
+ u_long hostid; /* scsi target of host */
+ u_long next; /* next in chain */
+ u_long loaddata[0]; /* load segment data, 123 for secsize == 512 */
+};
+
+#define RDBLOCK_ID 0x5244534b /* 'RDSK' */
+#define PARTBLOCK_ID 0x50415254 /* 'PART' */
+#define BADBLOCK_ID 0x42414442 /* 'BADB' */
+#define FSBLOCK_ID 0x46534844 /* 'FSHD' */
+#define LSEGBLOCK_ID 0x4c534547 /* 'LSEG' */
+
+/*
+ * Dos types for identifying file systems
+ * bsd file systems will be 'N','B',x,y where y is the fstype found in
+ * disklabel.h (for DOST_DOS it will be the version number)
+ */
+#define DOST_XXXBSD 0x42534400 /* Old type back compat*/
+#define DOST_NBR 0x4e425200 /* 'NBRx' NetBSD root partition */
+#define DOST_NBS 0x4e425300 /* 'NBS0' NetBSD swap partition */
+#define DOST_NBU 0x4e425500 /* 'NBUx' NetBSD user partition */
+#define DOST_DOS 0x444f5300 /* 'DOSx' AmigaDos partition */
+#define DOST_AMIX 0x554e4900 /* 'UNIx' AmigaDos partition */
+#define DOST_MUFS 0x6d754600 /* 'muFx' AmigaDos partition (muFS) */
+#define DOST_EXT2 0x4c4e5800 /* 'LNX0' Linux fs partition (ext2fs) */
+#define DOST_LNXSWP 0x53575000 /* 'SWP0' Linux swap partition */
+#define DOST_RAID 0x52414900 /* 'RAID' Raidframe partition */
+#define DOST_MSD 0x4d534400 /* 'MSDx' MSDOS partition */
+#define DOST_SFS 0x53465300 /* 'SFSx' Smart fs partition */
+
+struct adostype {
+ u_char archtype; /* see ADT_xxx below */
+ u_char fstype; /* byte 3 from amiga dostype */
+};
+
+/* archtypes */
+#define ADT_UNKNOWN 0
+#define ADT_AMIGADOS 1
+#define ADT_NETBSDROOT 2
+#define ADT_NETBSDSWAP 3
+#define ADT_NETBSDUSER 4
+#define ADT_AMIX 5
+#define ADT_EXT2 6
+#define ADT_RAID 7
+#define ADT_MSD 8
+#define ADT_SFS 9
+
+#define ISFSARCH_NETBSD(adt) \
+ ((adt).archtype >= ADT_NETBSDROOT && (adt).archtype <= ADT_NETBSDUSER)
+
+#endif /* _SYS_DISKLABEL_RDB_H_ */
--- /dev/null
+/* $NetBSD: dkstat.h,v 1.17 2005/12/26 18:41:36 perry Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dkstat.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_DKSTAT_H_
+#define _SYS_DKSTAT_H_
+
+#ifdef _KERNEL
+extern uint64_t tk_cancc;
+extern uint64_t tk_nin;
+extern uint64_t tk_nout;
+extern uint64_t tk_rawcc;
+#endif
+
+#endif /* _SYS_DKSTAT_H_ */
--- /dev/null
+/* $NetBSD: domain.h,v 1.31 2011/06/26 16:43:12 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)domain.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_DOMAIN_H_
+#define _SYS_DOMAIN_H_
+
+/*
+ * Structure per communications domain.
+ */
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <net/route.h>
+
+/*
+ * Forward structure declarations for function prototypes [sic].
+ */
+struct lwp;
+struct mbuf;
+struct ifnet;
+struct ifqueue;
+struct sockaddr;
+
+LIST_HEAD(dom_rtlist, route);
+
+struct domain {
+ int dom_family; /* AF_xxx */
+ const char *dom_name;
+ void (*dom_init) /* initialize domain data structures */
+ (void);
+ int (*dom_externalize) /* externalize access rights */
+ (struct mbuf *, struct lwp *, int);
+ void (*dom_dispose) /* dispose of internalized rights */
+ (struct mbuf *);
+ const struct protosw *dom_protosw, *dom_protoswNPROTOSW;
+ int (*dom_rtattach) /* initialize routing table */
+ (rtbl_t **, int);
+ int dom_rtoffset; /* an arg to rtattach, in bits */
+ int dom_maxrtkey; /* for routing layer */
+ void *(*dom_ifattach) /* attach af-dependent data on ifnet */
+ (struct ifnet *);
+ void (*dom_ifdetach) /* detach af-dependent data on ifnet */
+ (struct ifnet *, void *);
+ const void *(*dom_sockaddr_const_addr)(const struct sockaddr *,
+ socklen_t *);
+ void *(*dom_sockaddr_addr)(struct sockaddr *, socklen_t *);
+ int (*dom_sockaddr_cmp)(const struct sockaddr *,
+ const struct sockaddr *);
+ struct sockaddr *(*dom_sockaddr_externalize)(struct sockaddr *,
+ socklen_t,
+ const struct sockaddr *);
+ const struct sockaddr *dom_sa_any;
+ struct ifqueue *dom_ifqueues[2]; /* ifqueue for domain */
+ STAILQ_ENTRY(domain) dom_link;
+ struct mowner dom_mowner;
+ uint_fast8_t dom_sa_cmpofs;
+ uint_fast8_t dom_sa_cmplen;
+ struct dom_rtlist dom_rtcache;
+};
+
+STAILQ_HEAD(domainhead,domain);
+
+#ifdef _KERNEL
+#define DOMAIN_DEFINE(name) \
+ extern struct domain name; \
+ __link_set_add_data(domains, name)
+
+#define DOMAIN_FOREACH(dom) STAILQ_FOREACH(dom, &domains, dom_link)
+extern struct domainhead domains;
+void domain_attach(struct domain *);
+void domaininit(bool);
+#endif
+
+#endif /* !_SYS_DOMAIN_H_ */
--- /dev/null
+/* $NetBSD: drvctlio.h,v 1.7 2008/05/31 13:24:57 freza Exp $ */
+
+/*-
+ * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* This interface is experimental and may change. */
+
+#ifndef _SYS_DRVCTLIO_H_
+#define _SYS_DRVCTLIO_H_
+
+#include <prop/proplib.h>
+#include <sys/ioccom.h>
+
+#define DRVCTLDEV "/dev/drvctl"
+
+struct devdetachargs {
+ char devname[16];
+};
+
+struct devlistargs {
+ char l_devname[16];
+ char (*l_childname)[16];
+ size_t l_children;
+};
+
+enum devpmflags {
+ DEVPM_F_SUBTREE = 0x1
+};
+
+struct devpmargs {
+ char devname[16];
+ uint32_t flags;
+};
+
+struct devrescanargs {
+ char busname[16];
+ char ifattr[16];
+ unsigned int numlocators;
+ int *locators;
+};
+
+#define DRVDETACHDEV _IOW('D', 123, struct devdetachargs)
+#define DRVRESCANBUS _IOW('D', 124, struct devrescanargs)
+#define DRVCTLCOMMAND _IOWR('D', 125, struct plistref)
+#define DRVRESUMEDEV _IOW('D', 126, struct devpmargs)
+#define DRVLISTDEV _IOWR('D', 127, struct devlistargs)
+#define DRVGETEVENT _IOR('D', 128, struct plistref)
+#define DRVSUSPENDDEV _IOW('D', 129, struct devpmargs)
+
+/*
+ * DRVCTLCOMMAND documentation
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * Generic ioctl that takes a dictionary as an argument (specifies the
+ * command and arguments) and returns a dictionary with the results.
+ *
+ * Command arguments are structured like so:
+ *
+ * <dict>
+ * <key>drvctl-command</key>
+ * <string>...</string>
+ * <!-- optional arguments -->
+ * <key>drvctl-arguments</key>
+ * <dict>
+ * <!-- arguments vary with command -->
+ * </dict>
+ * </dict>
+ *
+ * Results are returned like so:
+ *
+ * <dict>
+ * <key>drvctl-error</key>
+ * <!-- 0 == success, otherwise an errno value -->
+ * <integer>...</integer>
+ * <!-- optional additional error message -->
+ * <key>drvctl-error-message</key>
+ * <string>...</string>
+ * <!-- optional results dictionary -->
+ * <key>drvctl-result-data</key>
+ * <dict>
+ * <!-- results vary with command -->
+ * </dict>
+ * </dict>
+ *
+ *
+ * Commands recognized by DRVCTLCOMMAND
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * get-properties
+ *
+ * Arguments:
+ *
+ * <dict>
+ * <key>device-name</key>
+ * <string>...</string>
+ * </dict>
+ *
+ * Results:
+ * <dict>
+ * <!-- contents of device's properties dictionary -->
+ * </dict>
+ */
+
+#endif /* _SYS_DRVCTLIO_H_ */
--- /dev/null
+/* $NetBSD: dtrace_bsd.h,v 1.5 2012/01/30 23:31:27 matt Exp $ */
+
+/*-
+ * Copyright (c) 2007-2008 John Birrell (jb@freebsd.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/dtrace_bsd.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
+ *
+ * This file contains BSD shims for Sun's DTrace code.
+ */
+
+#ifndef _SYS_DTRACE_BSD_H
+#define _SYS_DTRACE_BSD_H
+
+#if defined(_KERNEL_OPT)
+#include "opt_dtrace.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/kmem.h>
+#include <sys/proc.h>
+
+/* Forward definitions: */
+struct mbuf;
+struct trapframe;
+struct lwp;
+struct vattr;
+struct vnode;
+struct ucred;
+
+/*
+ * Cyclic clock function type definition used to hook the cyclic
+ * subsystem into the appropriate timer interrupt.
+ */
+typedef void (*cyclic_clock_func_t)(struct trapframe *);
+
+/*
+ * These external variables are actually machine-dependent, so
+ * they might not actually exist.
+ *
+ * Defining them here avoids a proliferation of header files.
+ */
+extern cyclic_clock_func_t lapic_cyclic_clock_func[];
+
+/*
+ * The dtrace module handles traps that occur during a DTrace probe.
+ * This type definition is used in the trap handler to provide a
+ * hook for the dtrace module to register it's handler with.
+ */
+typedef int (*dtrace_trap_func_t)(struct trapframe *, u_int);
+
+int dtrace_trap(struct trapframe *, u_int);
+
+extern dtrace_trap_func_t dtrace_trap_func;
+
+/* Used by the machine dependent trap() code. */
+typedef int (*dtrace_invop_func_t)(uintptr_t, uintptr_t *, uintptr_t);
+typedef void (*dtrace_doubletrap_func_t)(void);
+
+/* Global variables in trap.c */
+extern dtrace_invop_func_t dtrace_invop_func;
+extern dtrace_doubletrap_func_t dtrace_doubletrap_func;
+
+/* Virtual time hook function type. */
+typedef void (*dtrace_vtime_switch_func_t)(struct lwp *);
+
+extern int dtrace_vtime_active;
+extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
+
+/* The fasttrap module hooks into the fork, exit and exit. */
+typedef void (*dtrace_fork_func_t)(struct proc *, struct proc *);
+typedef void (*dtrace_execexit_func_t)(struct proc *);
+
+/* Global variable in kern_fork.c */
+extern dtrace_fork_func_t dtrace_fasttrap_fork;
+
+/* Global variable in kern_exec.c */
+extern dtrace_execexit_func_t dtrace_fasttrap_exec;
+
+/* Global variable in kern_exit.c */
+extern dtrace_execexit_func_t dtrace_fasttrap_exit;
+
+/* The dtmalloc provider hooks into malloc. */
+typedef void (*dtrace_malloc_probe_func_t)(u_int32_t, uintptr_t arg0,
+ uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
+
+extern dtrace_malloc_probe_func_t dtrace_malloc_probe;
+
+/* dtnfsclient NFSv3 access cache provider hooks. */
+typedef void (*dtrace_nfsclient_accesscache_flush_probe_func_t)(uint32_t,
+ struct vnode *);
+extern dtrace_nfsclient_accesscache_flush_probe_func_t
+ dtrace_nfsclient_accesscache_flush_done_probe;
+
+typedef void (*dtrace_nfsclient_accesscache_get_probe_func_t)(uint32_t,
+ struct vnode *, uid_t, uint32_t);
+extern dtrace_nfsclient_accesscache_get_probe_func_t
+ dtrace_nfsclient_accesscache_get_hit_probe,
+ dtrace_nfsclient_accesscache_get_miss_probe;
+
+typedef void (*dtrace_nfsclient_accesscache_load_probe_func_t)(uint32_t,
+ struct vnode *, uid_t, uint32_t, int);
+extern dtrace_nfsclient_accesscache_load_probe_func_t
+ dtrace_nfsclient_accesscache_load_done_probe;
+
+/* dtnfsclient NFSv[23] attribute cache provider hooks. */
+typedef void (*dtrace_nfsclient_attrcache_flush_probe_func_t)(uint32_t,
+ struct vnode *);
+extern dtrace_nfsclient_attrcache_flush_probe_func_t
+ dtrace_nfsclient_attrcache_flush_done_probe;
+
+typedef void (*dtrace_nfsclient_attrcache_get_hit_probe_func_t)(uint32_t,
+ struct vnode *, struct vattr *);
+extern dtrace_nfsclient_attrcache_get_hit_probe_func_t
+ dtrace_nfsclient_attrcache_get_hit_probe;
+
+typedef void (*dtrace_nfsclient_attrcache_get_miss_probe_func_t)(uint32_t,
+ struct vnode *);
+extern dtrace_nfsclient_attrcache_get_miss_probe_func_t
+ dtrace_nfsclient_attrcache_get_miss_probe;
+
+typedef void (*dtrace_nfsclient_attrcache_load_probe_func_t)(uint32_t,
+ struct vnode *, struct vattr *, int);
+extern dtrace_nfsclient_attrcache_load_probe_func_t
+ dtrace_nfsclient_attrcache_load_done_probe;
+
+/* dtnfsclient NFSv[23] RPC provider hooks. */
+typedef void (*dtrace_nfsclient_nfs23_start_probe_func_t)(uint32_t,
+ struct vnode *, struct mbuf *, struct ucred *, int);
+extern dtrace_nfsclient_nfs23_start_probe_func_t
+ dtrace_nfsclient_nfs23_start_probe;
+
+typedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t,
+ struct vnode *, struct mbuf *, struct ucred *, int, int);
+extern dtrace_nfsclient_nfs23_done_probe_func_t
+ dtrace_nfsclient_nfs23_done_probe;
+
+/*
+ * OpenSolaris compatible time functions returning nanoseconds.
+ * On OpenSolaris these return hrtime_t which we define as uint64_t.
+ */
+uint64_t dtrace_gethrtime(void);
+uint64_t dtrace_gethrestime(void);
+
+/* sizes based on DTrace structure requirements */
+#define KDTRACE_PROC_SIZE 64
+#define KDTRACE_PROC_ZERO 8
+#define KDTRACE_THREAD_SIZE 256
+#define KDTRACE_THREAD_ZERO 64
+
+/*
+ * Functions for managing the opaque DTrace memory areas for
+ * processes and lwps.
+ */
+
+static inline size_t kdtrace_proc_size(void);
+static inline void kdtrace_proc_ctor(void *, struct proc *);
+static inline void kdtrace_proc_dtor(void *, struct proc *);
+static inline size_t kdtrace_thread_size(void);
+static inline void kdtrace_thread_ctor(void *, struct lwp *);
+static inline void kdtrace_thread_dtor(void *, struct lwp *);
+
+
+/* Return the DTrace process data size compiled in the kernel hooks. */
+static inline size_t
+kdtrace_proc_size(void)
+{
+
+ return KDTRACE_PROC_SIZE;
+}
+
+/* Return the DTrace thread data size compiled in the kernel hooks. */
+static inline size_t
+kdtrace_thread_size(void)
+{
+
+ return KDTRACE_THREAD_SIZE;
+}
+
+static inline void
+kdtrace_proc_ctor(void *arg, struct proc *p)
+{
+
+#ifdef KDTRACE_HOOKS
+ p->p_dtrace = kmem_zalloc(KDTRACE_PROC_SIZE, KM_SLEEP);
+#endif
+}
+
+static inline void
+kdtrace_proc_dtor(void *arg, struct proc *p)
+{
+
+#ifdef KDTRACE_HOOKS
+ if (p->p_dtrace != NULL) {
+ kmem_free(p->p_dtrace, KDTRACE_PROC_SIZE);
+ p->p_dtrace = NULL;
+ }
+#endif
+}
+
+static inline void
+kdtrace_thread_ctor(void *arg, struct lwp *l)
+{
+
+#ifdef KDTRACE_HOOKS
+ l->l_dtrace = kmem_zalloc(KDTRACE_THREAD_SIZE, KM_SLEEP);
+#endif
+}
+
+static inline void
+kdtrace_thread_dtor(void *arg, struct lwp *l)
+{
+
+#ifdef KDTRACE_HOOKS
+ if (l->l_dtrace != NULL) {
+ kmem_free(l->l_dtrace, KDTRACE_THREAD_SIZE);
+ l->l_dtrace = NULL;
+ }
+#endif
+}
+
+#endif /* _SYS_DTRACE_BSD_H */
--- /dev/null
+/* $NetBSD: dvdio.h,v 1.8 2005/12/26 18:41:36 perry Exp $ */
+
+#ifndef _SYS_DVDIO_H_
+#define _SYS_DVDIO_H_
+
+#include <sys/types.h>
+#include <sys/ioccom.h>
+
+/* DVD-ROM Specific ioctls */
+#define DVD_READ_STRUCT _IOWR('d', 0, dvd_struct)
+#define DVD_WRITE_STRUCT _IOWR('d', 1, dvd_struct)
+#define DVD_AUTH _IOWR('d', 2, dvd_authinfo)
+
+#define GPCMD_READ_DVD_STRUCTURE 0xad
+#define GPCMD_SEND_DVD_STRUCTURE 0xad
+#define GPCMD_REPORT_KEY 0xa4
+#define GPCMD_SEND_KEY 0xa3
+
+/* DVD struct types */
+#define DVD_STRUCT_PHYSICAL 0x00
+#define DVD_STRUCT_COPYRIGHT 0x01
+#define DVD_STRUCT_DISCKEY 0x02
+#define DVD_STRUCT_BCA 0x03
+#define DVD_STRUCT_MANUFACT 0x04
+
+struct dvd_layer {
+ uint8_t book_version : 4;
+ uint8_t book_type : 4;
+ uint8_t min_rate : 4;
+ uint8_t disc_size : 4;
+ uint8_t layer_type : 4;
+ uint8_t track_path : 1;
+ uint8_t nlayers : 2;
+ uint8_t track_density : 4;
+ uint8_t linear_density : 4;
+ uint8_t bca : 1;
+ uint32_t start_sector;
+ uint32_t end_sector;
+ uint32_t end_sector_l0;
+};
+
+struct dvd_physical {
+ uint8_t type;
+ uint8_t layer_num;
+ struct dvd_layer layer[4];
+};
+
+struct dvd_copyright {
+ uint8_t type;
+
+ uint8_t layer_num;
+ uint8_t cpst;
+ uint8_t rmi;
+};
+
+struct dvd_disckey {
+ uint8_t type;
+
+ unsigned agid : 2;
+ uint8_t value[2048];
+};
+
+struct dvd_bca {
+ uint8_t type;
+
+ int len;
+ uint8_t value[188];
+};
+
+struct dvd_manufact {
+ uint8_t type;
+
+ uint8_t layer_num;
+ int len;
+ uint8_t value[2048];
+};
+
+typedef union {
+ uint8_t type;
+
+ struct dvd_physical physical;
+ struct dvd_copyright copyright;
+ struct dvd_disckey disckey;
+ struct dvd_bca bca;
+ struct dvd_manufact manufact;
+} dvd_struct;
+
+/*
+ * DVD authentication ioctl
+ */
+
+/* Authentication states */
+#define DVD_LU_SEND_AGID 0
+#define DVD_HOST_SEND_CHALLENGE 1
+#define DVD_LU_SEND_KEY1 2
+#define DVD_LU_SEND_CHALLENGE 3
+#define DVD_HOST_SEND_KEY2 4
+
+/* Termination states */
+#define DVD_AUTH_ESTABLISHED 5
+#define DVD_AUTH_FAILURE 6
+
+/* Other functions */
+#define DVD_LU_SEND_TITLE_KEY 7
+#define DVD_LU_SEND_ASF 8
+#define DVD_INVALIDATE_AGID 9
+#define DVD_LU_SEND_RPC_STATE 10
+#define DVD_HOST_SEND_RPC_STATE 11
+
+/* State data */
+typedef uint8_t dvd_key[5]; /* 40-bit value, MSB is first elem. */
+typedef uint8_t dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
+
+struct dvd_lu_send_agid {
+ uint8_t type;
+ unsigned agid : 2;
+};
+
+struct dvd_host_send_challenge {
+ uint8_t type;
+ unsigned agid : 2;
+
+ dvd_challenge chal;
+};
+
+struct dvd_send_key {
+ uint8_t type;
+ unsigned agid : 2;
+
+ dvd_key key;
+};
+
+struct dvd_lu_send_challenge {
+ uint8_t type;
+ unsigned agid : 2;
+
+ dvd_challenge chal;
+};
+
+#define DVD_CPM_NO_COPYRIGHT 0
+#define DVD_CPM_COPYRIGHTED 1
+
+#define DVD_CP_SEC_NONE 0
+#define DVD_CP_SEC_EXIST 1
+
+#define DVD_CGMS_UNRESTRICTED 0
+#define DVD_CGMS_SINGLE 2
+#define DVD_CGMS_RESTRICTED 3
+
+struct dvd_lu_send_title_key {
+ uint8_t type;
+ unsigned agid : 2;
+
+ dvd_key title_key;
+ int lba;
+ unsigned cpm : 1;
+ unsigned cp_sec : 1;
+ unsigned cgms : 2;
+};
+
+struct dvd_lu_send_asf {
+ uint8_t type;
+ unsigned agid : 2;
+
+ unsigned asf : 1;
+};
+
+struct dvd_host_send_rpcstate {
+ uint8_t type;
+ uint8_t pdrc;
+};
+
+struct dvd_lu_send_rpcstate {
+ uint8_t type : 2;
+ uint8_t vra : 3;
+ uint8_t ucca : 3;
+ uint8_t region_mask;
+ uint8_t rpc_scheme;
+};
+
+typedef union {
+ uint8_t type;
+
+ struct dvd_lu_send_agid lsa;
+ struct dvd_host_send_challenge hsc;
+ struct dvd_send_key lsk;
+ struct dvd_lu_send_challenge lsc;
+ struct dvd_send_key hsk;
+ struct dvd_lu_send_title_key lstk;
+ struct dvd_lu_send_asf lsasf;
+ struct dvd_host_send_rpcstate hrpcs;
+ struct dvd_lu_send_rpcstate lrpcs;
+} dvd_authinfo;
+
+typedef struct {
+ uint16_t report_key_length;
+ uint8_t reserved1[2];
+ uint8_t ucca : 3;
+ uint8_t vra : 3;
+ uint8_t type_code : 2;
+ uint8_t region_mask;
+ uint8_t rpc_scheme;
+ uint8_t reserved2;
+} dvd_rpc_state_t;
+
+#endif /* _SYS_DVDIO_H_ */
--- /dev/null
+/* $NetBSD: envsys.h,v 1.32 2012/08/27 21:07:33 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tim Rightnour, Juan Romero Pardines and Bill Squier.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_ENVSYS_H_
+#define _SYS_ENVSYS_H_
+
+#ifndef _KERNEL
+#include <stdbool.h>
+#endif
+
+#include <sys/ioccom.h>
+#include <sys/power.h>
+#include <sys/queue.h>
+
+/*
+ * ENVironmental SYStem version 2 (aka ENVSYS 2)
+ */
+
+#define ENVSYS_MAXSENSORS 512
+#define ENVSYS_DESCLEN 32
+
+/* sensor units */
+enum envsys_units {
+ ENVSYS_STEMP = 0, /* Temperature */
+ ENVSYS_SFANRPM, /* Fan RPM */
+ ENVSYS_SVOLTS_AC, /* AC Volts */
+ ENVSYS_SVOLTS_DC, /* DC Volts */
+ ENVSYS_SOHMS, /* Ohms */
+ ENVSYS_SWATTS, /* Watts */
+ ENVSYS_SAMPS, /* Ampere */
+ ENVSYS_SWATTHOUR, /* Watt hour */
+ ENVSYS_SAMPHOUR, /* Ampere hour */
+ ENVSYS_INDICATOR, /* Indicator */
+ ENVSYS_INTEGER, /* Integer */
+ ENVSYS_DRIVE, /* Drive */
+ ENVSYS_BATTERY_CAPACITY, /* Battery capacity */
+ ENVSYS_BATTERY_CHARGE, /* Battery charging/discharging */
+ ENVSYS_NSENSORS
+};
+
+/* sensor states */
+enum envsys_states {
+ ENVSYS_SVALID = 10, /* sensor state is valid */
+ ENVSYS_SINVALID, /* sensor state is invalid */
+ ENVSYS_SCRITICAL, /* sensor state is critical */
+ ENVSYS_SCRITUNDER, /* sensor state is critical under */
+ ENVSYS_SCRITOVER, /* sensor state is critical over */
+ ENVSYS_SWARNUNDER, /* sensor state is warn under */
+ ENVSYS_SWARNOVER /* sensor state is warn over */
+};
+
+/* sensor drive states */
+enum envsys_drive_states {
+ ENVSYS_DRIVE_EMPTY = 1, /* drive is empty */
+ ENVSYS_DRIVE_READY, /* drive is ready */
+ ENVSYS_DRIVE_POWERUP, /* drive is powered up */
+ ENVSYS_DRIVE_ONLINE, /* drive is online */
+ ENVSYS_DRIVE_IDLE, /* drive is idle */
+ ENVSYS_DRIVE_ACTIVE, /* drive is active */
+ ENVSYS_DRIVE_REBUILD, /* drive is rebuilding */
+ ENVSYS_DRIVE_POWERDOWN, /* drive is powered down */
+ ENVSYS_DRIVE_FAIL, /* drive failed */
+ ENVSYS_DRIVE_PFAIL, /* drive is degraded */
+ ENVSYS_DRIVE_MIGRATING, /* drive is migrating */
+ ENVSYS_DRIVE_OFFLINE, /* drive is offline */
+ ENVSYS_DRIVE_BUILD, /* drive is building */
+ ENVSYS_DRIVE_CHECK /* drive is checking its state */
+};
+
+/* sensor battery capacity states */
+enum envsys_battery_capacity_states {
+ ENVSYS_BATTERY_CAPACITY_NORMAL = 1, /* normal cap in battery */
+ ENVSYS_BATTERY_CAPACITY_WARNING, /* warning cap in battery */
+ ENVSYS_BATTERY_CAPACITY_CRITICAL, /* critical cap in battery */
+ ENVSYS_BATTERY_CAPACITY_HIGH, /* high cap in battery */
+ ENVSYS_BATTERY_CAPACITY_MAX, /* maximum cap in battery */
+ ENVSYS_BATTERY_CAPACITY_LOW /* low cap in battery */
+};
+
+/* sensor indicator states */
+enum envsys_indicator_states {
+ ENVSYS_INDICATOR_FALSE = 0,
+ ENVSYS_INDICATOR_TRUE = 1
+};
+
+/*
+ * IOCTLs
+ */
+#define ENVSYS_GETDICTIONARY _IOWR('E', 0, struct plistref)
+#define ENVSYS_SETDICTIONARY _IOWR('E', 1, struct plistref)
+#define ENVSYS_REMOVEPROPS _IOWR('E', 2, struct plistref)
+
+/*
+ * Compatibility with old interface. Only ENVSYS_GTREDATA
+ * and ENVSYS_GTREINFO ioctls are supported.
+ */
+
+/* get sensor data */
+
+struct envsys_tre_data {
+ u_int sensor;
+ union { /* all data is given */
+ uint32_t data_us; /* in microKelvins, */
+ int32_t data_s; /* rpms, volts, amps, */
+ } cur, min, max, avg; /* ohms, watts, etc */
+ /* see units below */
+
+ uint32_t warnflags; /* warning flags */
+ uint32_t validflags; /* sensor valid flags */
+ u_int units; /* type of sensor */
+};
+typedef struct envsys_tre_data envsys_tre_data_t;
+
+/* flags for warnflags */
+#define ENVSYS_WARN_OK 0x00000000 /* All is well */
+#define ENVSYS_WARN_UNDER 0x00000001 /* an under condition */
+#define ENVSYS_WARN_CRITUNDER 0x00000002 /* a critical under condition */
+#define ENVSYS_WARN_OVER 0x00000004 /* an over condition */
+#define ENVSYS_WARN_CRITOVER 0x00000008 /* a critical over condition */
+
+/* drive status */
+#define ENVSYS_DRIVE_EMPTY 1
+#define ENVSYS_DRIVE_READY 2
+#define ENVSYS_DRIVE_POWERUP 3
+#define ENVSYS_DRIVE_ONLINE 4
+#define ENVSYS_DRIVE_IDLE 5
+#define ENVSYS_DRIVE_ACTIVE 6
+#define ENVSYS_DRIVE_REBUILD 7
+#define ENVSYS_DRIVE_POWERDOWN 8
+#define ENVSYS_DRIVE_FAIL 9
+#define ENVSYS_DRIVE_PFAIL 10
+
+#ifdef ENVSYSUNITNAMES
+static const char * const envsysunitnames[] = {
+ "degC", "RPM", "VAC", "V", "Ohms", "W",
+ "A", "Wh", "Ah", "bool", "integer", "drive", "Unk"
+};
+static const char * const envsysdrivestatus[] = {
+ "unknown", "empty", "ready", "powering up", "online", "idle", "active",
+ "rebuilding", "powering down", "failed", "degraded"
+};
+#endif
+
+
+/* flags for validflags */
+#define ENVSYS_FVALID 0x00000001 /* sensor is valid */
+#define ENVSYS_FCURVALID 0x00000002 /* cur for this sens is valid */
+#define ENVSYS_FMINVALID 0x00000004 /* min for this sens is valid */
+#define ENVSYS_FMAXVALID 0x00000008 /* max for this sens is valid */
+#define ENVSYS_FAVGVALID 0x00000010 /* avg for this sens is valid */
+#define ENVSYS_FFRACVALID 0x00000020 /* display fraction of max */
+
+#define ENVSYS_GTREDATA _IOWR('E', 2, envsys_tre_data_t)
+
+/* set and check sensor info */
+
+struct envsys_basic_info {
+ u_int sensor; /* sensor number */
+ u_int units; /* type of sensor */
+ char desc[33]; /* sensor description */
+ u_int rfact; /* for volts, (int)(factor x 10^4) */
+ u_int rpms; /* for fans, set nominal RPMs */
+ uint32_t validflags; /* sensor valid flags */
+};
+typedef struct envsys_basic_info envsys_basic_info_t;
+
+#define ENVSYS_GTREINFO _IOWR('E', 4, envsys_basic_info_t)
+
+#endif /* _SYS_ENVSYS_H_ */
--- /dev/null
+/* $NetBSD: evcnt.h,v 1.8 2011/01/29 18:21:22 matt Exp $ */
+
+/*
+ * Copyright (c) 1996, 2000 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the
+ * NetBSD Project. See http://www.NetBSD.org/ for
+ * information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )--
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratories.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EVCNT_H_
+#define _SYS_EVCNT_H_
+
+#include <sys/queue.h>
+#include <sys/stdint.h>
+
+/*
+ * event counters
+ */
+
+struct evcnt {
+ uint64_t ev_count; /* how many have occurred */
+ TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */
+ unsigned char ev_type; /* counter type; see below */
+ unsigned char ev_grouplen; /* 'group' len, excluding NUL */
+ unsigned char ev_namelen; /* 'name' len, excluding NUL */
+ char ev_pad1; /* reserved (for now); 0 */
+ const struct evcnt *ev_parent; /* parent, for hierarchical ctrs */
+ const char *ev_group; /* name of group */
+ const char *ev_name; /* name of specific event */
+};
+TAILQ_HEAD(evcntlist, evcnt);
+
+/* maximum group/name lengths, including trailing NUL */
+#define EVCNT_STRING_MAX 255
+
+/* ev_type values */
+#define EVCNT_TYPE_ANY -1 /* for sysctl */
+#define EVCNT_TYPE_MISC 0 /* miscellaneous; catch all */
+#define EVCNT_TYPE_INTR 1 /* interrupt; count with vmstat -i */
+#define EVCNT_TYPE_TRAP 2 /* processor trap/execption */
+
+/*
+ * initializer for an event count structure. the lengths are initted and
+ * it is added to the evcnt list at attach time.
+ */
+#define EVCNT_INITIALIZER(type, parent, group, name) \
+ { \
+ .ev_type = type, \
+ .ev_parent = parent, \
+ .ev_group = group, \
+ .ev_name = name, \
+ }
+
+/*
+ * Attach a static event counter. This uses a link set to do the work.
+ * NOTE: "ev" should not be a pointer to the object, but rather a direct
+ * reference to the object itself.
+ */
+#define EVCNT_ATTACH_STATIC(ev) __link_set_add_data(evcnts, ev)
+#define EVCNT_ATTACH_STATIC2(ev, n) __link_set_add_data2(evcnts, ev, n)
+
+#ifdef _KERNEL
+
+extern struct evcntlist allevents; /* list of all event counters */
+
+void evcnt_init(void);
+void evcnt_attach_static(struct evcnt *);
+void evcnt_attach_dynamic_nozero(struct evcnt *, int, const struct evcnt *,
+ const char *, const char *);
+void evcnt_attach_dynamic(struct evcnt *, int, const struct evcnt *,
+ const char *, const char *);
+void evcnt_detach(struct evcnt *);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_EVCNT_H_ */
--- /dev/null
+/* $NetBSD: event.h,v 1.23 2011/06/26 16:43:12 christos Exp $ */
+
+/*-
+ * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/event.h,v 1.12 2001/02/24 01:44:03 jlemon Exp $
+ */
+
+#ifndef _SYS_EVENT_H_
+#define _SYS_EVENT_H_
+
+#include <sys/featuretest.h>
+#include <sys/types.h> /* for size_t */
+#include <sys/inttypes.h> /* for uintptr_t */
+#include <sys/null.h> /* for NULL */
+
+#define EVFILT_READ 0
+#define EVFILT_WRITE 1
+#define EVFILT_AIO 2 /* attached to aio requests */
+#define EVFILT_VNODE 3 /* attached to vnodes */
+#define EVFILT_PROC 4 /* attached to struct proc */
+#define EVFILT_SIGNAL 5 /* attached to struct proc */
+#define EVFILT_TIMER 6 /* arbitrary timer (in ms) */
+#define EVFILT_SYSCOUNT 7 /* number of filters */
+
+#define EV_SET(kevp, a, b, c, d, e, f) \
+do { \
+ (kevp)->ident = (a); \
+ (kevp)->filter = (b); \
+ (kevp)->flags = (c); \
+ (kevp)->fflags = (d); \
+ (kevp)->data = (e); \
+ (kevp)->udata = (f); \
+} while (/* CONSTCOND */ 0)
+
+
+struct kevent {
+ uintptr_t ident; /* identifier for this event */
+ uint32_t filter; /* filter for event */
+ uint32_t flags; /* action flags for kqueue */
+ uint32_t fflags; /* filter flag value */
+ int64_t data; /* filter data value */
+ intptr_t udata; /* opaque user data identifier */
+};
+
+/* actions */
+#define EV_ADD 0x0001 /* add event to kq (implies ENABLE) */
+#define EV_DELETE 0x0002 /* delete event from kq */
+#define EV_ENABLE 0x0004 /* enable event */
+#define EV_DISABLE 0x0008 /* disable event (not reported) */
+
+/* flags */
+#define EV_ONESHOT 0x0010 /* only report one occurrence */
+#define EV_CLEAR 0x0020 /* clear event state after reporting */
+
+#define EV_SYSFLAGS 0xF000 /* reserved by system */
+#define EV_FLAG1 0x2000 /* filter-specific flag */
+
+/* returned values */
+#define EV_EOF 0x8000 /* EOF detected */
+#define EV_ERROR 0x4000 /* error, data contains errno */
+
+/*
+ * hint flag for in-kernel use - must not equal any existing note
+ */
+#ifdef _KERNEL
+#define NOTE_SUBMIT 0x01000000 /* initial knote submission */
+#endif
+/*
+ * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
+ */
+#define NOTE_LOWAT 0x0001 /* low water mark */
+
+/*
+ * data/hint flags for EVFILT_VNODE, shared with userspace
+ */
+#define NOTE_DELETE 0x0001 /* vnode was removed */
+#define NOTE_WRITE 0x0002 /* data contents changed */
+#define NOTE_EXTEND 0x0004 /* size increased */
+#define NOTE_ATTRIB 0x0008 /* attributes changed */
+#define NOTE_LINK 0x0010 /* link count changed */
+#define NOTE_RENAME 0x0020 /* vnode was renamed */
+#define NOTE_REVOKE 0x0040 /* vnode access was revoked */
+
+/*
+ * data/hint flags for EVFILT_PROC, shared with userspace
+ */
+#define NOTE_EXIT 0x80000000 /* process exited */
+#define NOTE_FORK 0x40000000 /* process forked */
+#define NOTE_EXEC 0x20000000 /* process exec'd */
+#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */
+#define NOTE_PDATAMASK 0x000fffff /* mask for pid */
+
+/* additional flags for EVFILT_PROC */
+#define NOTE_TRACK 0x00000001 /* follow across forks */
+#define NOTE_TRACKERR 0x00000002 /* could not track child */
+#define NOTE_CHILD 0x00000004 /* am a child process */
+
+/*
+ * This is currently visible to userland to work around broken
+ * programs which pull in <sys/proc.h> or <sys/select.h>.
+ */
+#include <sys/queue.h>
+struct knote;
+SLIST_HEAD(klist, knote);
+
+
+/*
+ * ioctl(2)s supported on kqueue descriptors.
+ */
+#include <sys/ioctl.h>
+
+struct kfilter_mapping {
+ char *name; /* name to lookup or return */
+ size_t len; /* length of name */
+ uint32_t filter; /* filter to lookup or return */
+};
+
+/* map filter to name (max size len) */
+#define KFILTER_BYFILTER _IOWR('k', 0, struct kfilter_mapping)
+/* map name to filter (len ignored) */
+#define KFILTER_BYNAME _IOWR('k', 1, struct kfilter_mapping)
+
+#ifdef _KERNEL
+
+#define KNOTE(list, hint) if (!SLIST_EMPTY(list)) knote(list, hint)
+
+/*
+ * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also
+ * shared by EVFILT_PROC (all knotes attached to p->p_klist)
+ */
+#define NOTE_SIGNAL 0x08000000
+
+/*
+ * Callback methods for each filter type.
+ */
+struct filterops {
+ int f_isfd; /* true if ident == filedescriptor */
+ int (*f_attach) (struct knote *);
+ /* called when knote is ADDed */
+ void (*f_detach) (struct knote *);
+ /* called when knote is DELETEd */
+ int (*f_event) (struct knote *, long);
+ /* called when event is triggered */
+};
+
+/*
+ * Field locking:
+ *
+ * f kn_kq->kq_fdp->fd_lock
+ * q kn_kq->kq_lock
+ * o object mutex (e.g. device driver or vnode interlock)
+ */
+struct kfilter;
+
+struct knote {
+ SLIST_ENTRY(knote) kn_link; /* f: for fd */
+ SLIST_ENTRY(knote) kn_selnext; /* o: for struct selinfo */
+ TAILQ_ENTRY(knote) kn_tqe; /* q: for struct kqueue */
+ struct kqueue *kn_kq; /* q: which queue we are on */
+ struct kevent kn_kevent;
+ uint32_t kn_status;
+ uint32_t kn_sfflags; /* saved filter flags */
+ uintptr_t kn_sdata; /* saved data field */
+ void *kn_obj; /* pointer to monitored obj */
+ const struct filterops *kn_fop;
+ struct kfilter *kn_kfilter;
+ void *kn_hook;
+
+#define KN_ACTIVE 0x01 /* event has been triggered */
+#define KN_QUEUED 0x02 /* event is on queue */
+#define KN_DISABLED 0x04 /* event is disabled */
+#define KN_DETACHED 0x08 /* knote is detached */
+#define KN_MARKER 0x10 /* is a marker */
+
+#define kn_id kn_kevent.ident
+#define kn_filter kn_kevent.filter
+#define kn_flags kn_kevent.flags
+#define kn_fflags kn_kevent.fflags
+#define kn_data kn_kevent.data
+};
+
+#include <sys/systm.h> /* for copyin_t */
+
+struct lwp;
+struct timespec;
+
+void kqueue_init(void);
+void knote(struct klist *, long);
+void knote_fdclose(int);
+
+typedef int (*kevent_fetch_changes_t)(void *, const struct kevent *,
+ struct kevent *, size_t, int);
+typedef int (*kevent_put_events_t)(void *, struct kevent *, struct kevent *,
+ size_t, int);
+
+struct kevent_ops {
+ void *keo_private;
+ copyin_t keo_fetch_timeout;
+ kevent_fetch_changes_t keo_fetch_changes;
+ kevent_put_events_t keo_put_events;
+};
+
+
+int kevent_fetch_changes(void *, const struct kevent *, struct kevent *,
+ size_t, int);
+int kevent_put_events(void *, struct kevent *, struct kevent *, size_t,
+ int);
+int kevent1(register_t *, int, const struct kevent *,
+ size_t, struct kevent *, size_t, const struct timespec *,
+ const struct kevent_ops *);
+
+int kfilter_register(const char *, const struct filterops *, int *);
+int kfilter_unregister(const char *);
+
+int filt_seltrue(struct knote *, long);
+extern const struct filterops seltrue_filtops;
+
+#else /* !_KERNEL */
+
+#include <sys/cdefs.h>
+struct timespec;
+
+__BEGIN_DECLS
+#if defined(_NETBSD_SOURCE)
+int kqueue(void);
+int kqueue1(int);
+#ifndef __LIBC12_SOURCE__
+int kevent(int, const struct kevent *, size_t, struct kevent *, size_t,
+ const struct timespec *) __RENAME(__kevent50);
+#endif
+#endif /* !_POSIX_C_SOURCE */
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_EVENT_H_ */
--- /dev/null
+/* $NetBSD: eventvar.h,v 1.8 2008/03/21 21:53:35 ad Exp $ */
+
+/*-
+ * Copyright (c) 1999,2000 Jonathan Lemon <jlemon@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * FreeBSD: src/sys/sys/eventvar.h,v 1.4 2000/07/18 19:31:48 jlemon Exp
+ */
+
+/*
+ * This header is provided for the kqueue implementation and kmem
+ * grovellers, and is not expected to be used elsewhere.
+ */
+
+#ifndef _SYS_EVENTVAR_H_
+#define _SYS_EVENTVAR_H_
+
+#include <sys/mutex.h>
+#include <sys/selinfo.h>
+#include <sys/filedesc.h>
+
+#define KQ_NEVENTS 8 /* minimize copy{in,out} calls */
+#define KQ_EXTENT 256 /* linear growth by this amount */
+#define KFILTER_MAXNAME 256 /* maximum size of a filter name */
+#define KFILTER_EXTENT 8 /* grow user_kfilters by this amt */
+
+struct kqueue {
+ TAILQ_HEAD(kqlist, knote) kq_head; /* list of pending event */
+ kmutex_t kq_lock; /* mutex for queue access */
+ filedesc_t *kq_fdp;
+ struct selinfo kq_sel;
+ kcondvar_t kq_cv;
+ int kq_count; /* number of pending events */
+};
+
+#endif /* !_SYS_EVENTVAR_H_ */
--- /dev/null
+/* $NetBSD: exec_aout.h,v 1.40 2012/03/17 21:54:12 martin Exp $ */
+
+/*
+ * Copyright (c) 1993, 1994 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christopher G. Demetriou.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EXEC_AOUT_H_
+#define _SYS_EXEC_AOUT_H_
+
+#ifndef N_PAGSIZ
+#define N_PAGSIZ(ex) (AOUT_LDPGSZ)
+#endif
+
+/*
+ * Header prepended to each a.out file.
+ * only manipulate the a_midmag field via the
+ * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below.
+ */
+struct exec {
+ u_long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
+ u_long a_text; /* text segment size */
+ u_long a_data; /* initialized data size */
+ u_long a_bss; /* uninitialized data size */
+ u_long a_syms; /* symbol table size */
+ u_long a_entry; /* entry point */
+ u_long a_trsize; /* text relocation size */
+ u_long a_drsize; /* data relocation size */
+};
+
+/* a_magic */
+#define OMAGIC 0407 /* old impure format */
+#define NMAGIC 0410 /* read-only text */
+#define ZMAGIC 0413 /* demand load format */
+#define QMAGIC 0314 /* "compact" demand load format; deprecated */
+
+#include <sys/aout_mids.h>
+
+/*
+ * a_flags
+ */
+#define EX_DYNAMIC 0x20
+#define EX_PIC 0x10
+#define EX_DPMASK 0x30
+/*
+ * Interpretation of the (a_flags & EX_DPMASK) bits:
+ *
+ * 00 traditional executable or object file
+ * 01 object file contains PIC code (set by `as -k')
+ * 10 dynamic executable
+ * 11 position independent executable image
+ * (eg. a shared library)
+ *
+ */
+
+/*
+ * The a.out structure's a_midmag field is a network-byteorder encoding
+ * of this int
+ * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
+ * Where `F' is 6 bits of flag like EX_DYNAMIC,
+ * `m' is 10 bits of machine-id like MID_I386, and
+ * `M' is 16 bits worth of magic number, ie. ZMAGIC.
+ * The macros below will set/get the needed fields.
+ */
+#define N_GETMAGIC(ex) \
+ ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \
+ (be32toh((uint32_t)((ex).a_midmag))&0xffff) : ((ex).a_midmag))
+#define N_GETMAGIC2(ex) \
+ ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \
+ (be32toh((uint32_t)((ex).a_midmag))&0xffff) : (((ex).a_midmag) | 0x10000))
+#define N_GETMID(ex) \
+ ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \
+ ((be32toh((uint32_t)((ex).a_midmag))>>16)&0x03ff) : MID_ZERO)
+#define N_GETFLAG(ex) \
+ ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \
+ ((be32toh((uint32_t)((ex).a_midmag))>>26)&0x3f) : 0)
+#define N_SETMAGIC(ex,mag,mid,flag) \
+ ((ex).a_midmag = htobe32((uint32_t) \
+ ((((flag)&0x3f)<<26)|(((mid)&0x03ff)<<16)|(((mag)&0xffff)))))
+
+#define N_ALIGN(ex,x) \
+ (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ? \
+ ((x) + AOUT_LDPGSZ - 1) & ~(AOUT_LDPGSZ - 1) : (x))
+
+/* Valid magic number check. */
+#define N_BADMAG(ex) \
+ (N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \
+ N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC)
+
+/* Address of the bottom of the text segment. */
+#define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : AOUT_LDPGSZ)
+
+/* Address of the bottom of the data segment. */
+#define N_DATADDR(ex) \
+ (N_GETMAGIC(ex) == OMAGIC ? N_TXTADDR(ex) + (ex).a_text : \
+ (N_TXTADDR(ex) + (ex).a_text + AOUT_LDPGSZ - 1) & ~(AOUT_LDPGSZ - 1))
+
+/* Address of the bottom of the bss segment. */
+#define N_BSSADDR(ex) \
+ (N_DATADDR(ex) + (ex).a_data)
+
+/* Text segment offset. */
+#define N_TXTOFF(ex) \
+ ( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \
+ 0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? AOUT_LDPGSZ : \
+ sizeof(struct exec)) )
+
+/* Data segment offset. */
+#define N_DATOFF(ex) \
+ N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
+
+/* Text relocation table offset. */
+#define N_TRELOFF(ex) \
+ (N_DATOFF(ex) + (ex).a_data)
+
+/* Data relocation table offset. */
+#define N_DRELOFF(ex) \
+ (N_TRELOFF(ex) + (ex).a_trsize)
+
+/* Symbol table offset. */
+#define N_SYMOFF(ex) \
+ (N_DRELOFF(ex) + (ex).a_drsize)
+
+/* String table offset. */
+#define N_STROFF(ex) \
+ (N_SYMOFF(ex) + (ex).a_syms)
+
+#include <machine/aout_machdep.h>
+
+#ifdef _KERNEL
+
+/* the "a.out" format's entry in the exec switch */
+int exec_aout_makecmds(struct lwp *, struct exec_package *);
+
+/* functions which prepare various a.out executable types */
+/*
+ * MI portion
+ */
+int exec_aout_prep_zmagic(struct lwp *, struct exec_package *);
+int exec_aout_prep_nmagic(struct lwp *, struct exec_package *);
+int exec_aout_prep_omagic(struct lwp *, struct exec_package *);
+
+/* For compatibility modules */
+int exec_aout_prep_oldzmagic(struct lwp *, struct exec_package *);
+int exec_aout_prep_oldnmagic(struct lwp *, struct exec_package *);
+int exec_aout_prep_oldomagic(struct lwp *, struct exec_package *);
+
+/*
+ * MD portion
+ */
+#ifndef cpu_exec_aout_makecmds
+int cpu_exec_aout_makecmds(struct lwp *, struct exec_package *);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_EXEC_AOUT_H_ */
--- /dev/null
+/* $NetBSD: exec_coff.h,v 1.7 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (C) 2000 SAITOH Masanobu. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EXEC_COFF_H_
+#define _SYS_EXEC_COFF_H_
+
+#include <machine/coff_machdep.h>
+
+/*
+ * COFF file header
+ */
+
+struct coff_filehdr {
+ u_short f_magic; /* magic number */
+ u_short f_nscns; /* # of sections */
+ long f_timdat; /* timestamp */
+ long f_symptr; /* file offset of symbol table */
+ long f_nsyms; /* # of symbol table entries */
+ u_short f_opthdr; /* size of optional header */
+ u_short f_flags; /* flags */
+};
+
+/* f_flags */
+#define COFF_F_RELFLG 0x1
+#define COFF_F_EXEC 0x2
+#define COFF_F_LNNO 0x4
+#define COFF_F_LSYMS 0x8
+#define COFF_F_SWABD 0x40
+#define COFF_F_AR16WR 0x80
+#define COFF_F_AR32WR 0x100
+#define COFF_F_AR32W 0x200
+
+/*
+ * COFF system header
+ */
+
+struct coff_aouthdr {
+ short a_magic;
+ short a_vstamp;
+ long a_tsize;
+ long a_dsize;
+ long a_bsize;
+ long a_entry;
+ long a_tstart;
+ long a_dstart;
+};
+
+/*
+ * COFF section header
+ */
+
+struct coff_scnhdr {
+ char s_name[8];
+ long s_paddr;
+ long s_vaddr;
+ long s_size;
+ long s_scnptr;
+ long s_relptr;
+ long s_lnnoptr;
+ u_short s_nreloc;
+ u_short s_nlnno;
+ long s_flags;
+};
+
+/* s_flags */
+#define COFF_STYP_REG 0x00
+#define COFF_STYP_DSECT 0x01
+#define COFF_STYP_NOLOAD 0x02
+#define COFF_STYP_GROUP 0x04
+#define COFF_STYP_PAD 0x08
+#define COFF_STYP_COPY 0x10
+#define COFF_STYP_TEXT 0x20
+#define COFF_STYP_DATA 0x40
+#define COFF_STYP_BSS 0x80
+#define COFF_STYP_INFO 0x200
+#define COFF_STYP_OVER 0x400
+#define COFF_STYP_SHLIB 0x800
+
+/*
+ * COFF shared library header
+ */
+
+struct coff_slhdr {
+ long entry_len; /* in words */
+ long path_index; /* in words */
+ char sl_name[1];
+};
+
+struct coff_exechdr {
+ struct coff_filehdr f;
+ struct coff_aouthdr a;
+};
+
+#define COFF_ROUND(val, by) (((val) + by - 1) & ~(by - 1))
+
+#define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))
+
+#define COFF_HDR_SIZE \
+ (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))
+
+#define COFF_BLOCK_ALIGN(ap, value) \
+ ((ap)->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
+ value)
+
+#define COFF_TXTOFF(fp, ap) \
+ ((ap)->a_magic == COFF_ZMAGIC ? 0 : \
+ COFF_ROUND(COFF_HDR_SIZE + (fp)->f_nscns * \
+ sizeof(struct coff_scnhdr), \
+ COFF_SEGMENT_ALIGNMENT(fp, ap)))
+
+#define COFF_DATOFF(fp, ap) \
+ (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + (ap)->a_tsize))
+
+#define COFF_SEGMENT_ALIGN(fp, ap, value) \
+ (COFF_ROUND(value, ((ap)->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
+ COFF_SEGMENT_ALIGNMENT(fp, ap))))
+
+#ifdef _KERNEL
+int exec_coff_makecmds(struct lwp *, struct exec_package *);
+
+int exec_coff_prep_omagic(struct lwp *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *);
+int exec_coff_prep_nmagic(struct lwp *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *);
+int exec_coff_prep_zmagic(struct lwp *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *);
+#endif /* _KERNEL */
+#endif /* !_SYS_EXEC_COFF_H_ */
--- /dev/null
+/* $NetBSD: exec_ecoff.h,v 1.20 2009/12/10 14:13:54 matt Exp $ */
+
+/*
+ * Copyright (c) 1994 Adam Glass
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Adam Glass.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EXEC_ECOFF_H_
+#define _SYS_EXEC_ECOFF_H_
+
+#include <machine/ecoff_machdep.h>
+
+struct ecoff_filehdr {
+ u_short f_magic; /* magic number */
+ u_short f_nscns; /* # of sections */
+ u_int f_timdat; /* time and date stamp */
+ u_long f_symptr; /* file offset of symbol table */
+ u_int f_nsyms; /* # of symbol table entries */
+ u_short f_opthdr; /* sizeof the optional header */
+ u_short f_flags; /* flags??? */
+};
+
+struct ecoff_aouthdr {
+ u_short magic;
+ u_short vstamp;
+ ECOFF_PAD
+ u_long tsize;
+ u_long dsize;
+ u_long bsize;
+ u_long entry;
+ u_long text_start;
+ u_long data_start;
+ u_long bss_start;
+ ECOFF_MACHDEP;
+};
+
+struct ecoff_scnhdr { /* needed for size info */
+ char s_name[8]; /* name */
+ u_long s_paddr; /* physical addr? for ROMing?*/
+ u_long s_vaddr; /* virtual addr? */
+ u_long s_size; /* size */
+ u_long s_scnptr; /* file offset of raw data */
+ u_long s_relptr; /* file offset of reloc data */
+ u_long s_lnnoptr; /* file offset of line data */
+ u_short s_nreloc; /* # of relocation entries */
+ u_short s_nlnno; /* # of line entries */
+ u_int s_flags; /* flags */
+};
+
+struct ecoff_exechdr {
+ struct ecoff_filehdr f;
+ struct ecoff_aouthdr a;
+};
+
+#define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr))
+
+#define ECOFF_OMAGIC 0407
+#define ECOFF_NMAGIC 0410
+#define ECOFF_ZMAGIC 0413
+
+#define ECOFF_ROUND(value, by) \
+ (((value) + (by) - 1) & ~((by) - 1))
+
+#define ECOFF_BLOCK_ALIGN(ep, value) \
+ ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \
+ (value))
+
+#define ECOFF_TXTOFF(ep) \
+ ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \
+ ECOFF_ROUND(ECOFF_HDR_SIZE + (ep)->f.f_nscns * \
+ sizeof(struct ecoff_scnhdr), ECOFF_SEGMENT_ALIGNMENT(ep)))
+
+#define ECOFF_DATOFF(ep) \
+ (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize))
+
+#define ECOFF_SEGMENT_ALIGN(ep, value) \
+ (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
+ ECOFF_SEGMENT_ALIGNMENT(ep))))
+
+#ifdef _KERNEL
+int exec_ecoff_makecmds(struct lwp *, struct exec_package *);
+int cpu_exec_ecoff_probe(struct lwp *, struct exec_package *);
+void cpu_exec_ecoff_setregs(struct lwp *, struct exec_package *, vaddr_t);
+
+int exec_ecoff_prep_omagic(struct lwp *, struct exec_package *,
+ struct ecoff_exechdr *, struct vnode *);
+int exec_ecoff_prep_nmagic(struct lwp *, struct exec_package *,
+ struct ecoff_exechdr *, struct vnode *);
+int exec_ecoff_prep_zmagic(struct lwp *, struct exec_package *,
+ struct ecoff_exechdr *, struct vnode *);
+
+#endif /* _KERNEL */
+#endif /* !_SYS_EXEC_ECOFF_H_ */
--- /dev/null
+/* $NetBSD: exec_script.h,v 1.12 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Copyright (c) 1994 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christopher G. Demetriou.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EXEC_SCRIPT_H_
+#define _SYS_EXEC_SCRIPT_H_
+
+#define EXEC_SCRIPT_MAGIC "#!"
+#define EXEC_SCRIPT_MAGICLEN 2
+
+/* Extra 2 are for possible space between #! and shell name, and newline. */
+#define SCRIPT_HDR_SIZE (EXEC_SCRIPT_MAGICLEN + MAXINTERP + 2)
+
+#ifdef _KERNEL
+
+/* the shell script handler's entry in the exec switch */
+int exec_script_makecmds(struct lwp *, struct exec_package *);
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_EXEC_SCRIPT_H_ */
--- /dev/null
+/* $NetBSD: extent.h,v 1.19 2012/01/27 18:53:10 para Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_EXTENT_H_
+#define _SYS_EXTENT_H_
+
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+
+struct extent_region {
+ LIST_ENTRY(extent_region) er_link; /* link in region list */
+ u_long er_start; /* start of region */
+ u_long er_end; /* end of region */
+ int er_flags; /* misc. flags */
+};
+
+/* er_flags */
+#define ER_ALLOC 0x01 /* region descriptor dynamically allocated */
+
+struct extent {
+ const char *ex_name; /* name of extent */
+ kmutex_t ex_lock; /* lock on this extent */
+ kcondvar_t ex_cv; /* synchronization */
+ /* allocated regions in extent */
+ LIST_HEAD(, extent_region) ex_regions;
+ u_long ex_start; /* start of extent */
+ u_long ex_end; /* end of extent */
+ int ex_flags; /* misc. information */
+};
+
+struct extent_fixed {
+ struct extent fex_extent; /* MUST BE FIRST */
+ /* freelist of region descriptors */
+ LIST_HEAD(, extent_region) fex_freelist;
+ void * fex_storage; /* storage space for descriptors */
+ size_t fex_storagesize; /* size of storage space */
+};
+
+/* ex_flags; for internal use only */
+#define EXF_FIXED 0x01 /* extent uses fixed storage */
+#define EXF_NOCOALESCE 0x02 /* coalescing of regions not allowed */
+#define EXF_FLWANTED 0x08 /* someone asleep on freelist */
+
+#define EXF_BITS "\20\4FLWANTED\2NOCOALESCE\1FIXED"
+
+/* misc. flags passed to extent functions */
+#define EX_NOWAIT 0x00 /* not safe to sleep */
+#define EX_WAITOK 0x01 /* safe to sleep */
+#define EX_FAST 0x02 /* take first fit in extent_alloc() */
+#define EX_CATCH 0x04 /* catch signals while sleeping */
+#define EX_NOCOALESCE 0x08 /* create a non-coalescing extent */
+#define EX_MALLOCOK 0x10 /* safe to call kmem_alloc() */
+#define EX_WAITSPACE 0x20 /* wait for space to become free */
+#define EX_BOUNDZERO 0x40 /* boundary lines start at 0 */
+
+/*
+ * Special place holders for "alignment" and "boundary" arguments,
+ * in the event the caller doesn't wish to use those features.
+ */
+#define EX_NOALIGN 1 /* don't do alignment */
+#define EX_NOBOUNDARY 0 /* don't do boundary checking */
+
+#if defined(_KERNEL) || defined(_EXTENT_TESTING)
+#define EXTENT_FIXED_STORAGE_SIZE(_nregions) \
+ (ALIGN(sizeof(struct extent_fixed)) + \
+ ((ALIGN(sizeof(struct extent_region))) * \
+ (_nregions)))
+
+struct extent *extent_create(const char *, u_long, u_long,
+ void *, size_t, int);
+void extent_destroy(struct extent *);
+int extent_alloc_subregion1(struct extent *, u_long, u_long,
+ u_long, u_long, u_long, u_long, int, u_long *);
+int extent_alloc_subregion(struct extent *, u_long, u_long,
+ u_long, u_long, u_long, int, u_long *);
+int extent_alloc_region(struct extent *, u_long, u_long, int);
+int extent_alloc1(struct extent *, u_long, u_long, u_long, u_long, int,
+ u_long *);
+int extent_alloc(struct extent *, u_long, u_long, u_long, int, u_long *);
+int extent_free(struct extent *, u_long, u_long, int);
+void extent_print(struct extent *);
+void extent_init(void);
+
+#endif /* _KERNEL || _EXTENT_TESTING */
+
+#endif /* ! _SYS_EXTENT_H_ */
--- /dev/null
+/* $NetBSD: fdio.h,v 1.4 2008/04/28 20:24:10 martin Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by John Kohl.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_FDIO_H_
+#define _SYS_FDIO_H_
+
+#include <sys/ioccom.h>
+
+/* Floppy diskette definitions */
+
+enum fdformat_result {
+ FDFORMAT_SUCCESS,
+ FDFORMAT_MEDIA_ERROR, /* hardware reported a formatting
+ error */
+ FDFORMAT_CONFIG_ERROR /* something bogus in parameters */
+};
+
+#define FDFORMAT_VERSION 19961120
+
+struct fdformat_cmd {
+ u_int formatcmd_version; /* FDFORMAT_VERSION */
+ int head; /* IN */
+ int cylinder; /* IN */
+};
+
+struct fdformat_parms {
+/* list of items taken from i386 formatting glop (NEC 765);
+ should be made the union of support needed for other devices. */
+ u_int fdformat_version; /* rev this when needed; write drivers to
+ allow forward compatibility, please,
+ and add elements to the end of the
+ structure */
+ u_int nbps; /* number of bytes per sector */
+ u_int ncyl; /* number of cylinders */
+ u_int nspt; /* sectors per track */
+ u_int ntrk; /* number of heads/tracks per cyl */
+ u_int stepspercyl; /* steps per cylinder */
+ u_int gaplen; /* formatting gap length */
+ u_int fillbyte; /* formatting fill byte */
+ u_int xfer_rate; /* in bits per second; driver
+ must convert */
+ u_int interleave; /* interleave factor */
+};
+
+
+#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
+#define FDOPT_SILENT 0x0002 /* no error messages (cleared on close) */
+
+#define FDIOCGETOPTS _IOR('d', 114, int) /* drive options, see previous */
+#define FDIOCSETOPTS _IOW('d', 115, int)
+
+#define FDIOCSETFORMAT _IOW('d', 116, struct fdformat_parms) /* set format parms */
+#define FDIOCGETFORMAT _IOR('d', 117, struct fdformat_parms) /* get format parms */
+#define FDIOCFORMAT_TRACK _IOW('d', 118, struct fdformat_cmd) /* do it */
+
+#endif /* _SYS_FDIO_H_ */
--- /dev/null
+/* $NetBSD: fileassoc.h,v 1.11 2007/05/15 19:47:44 elad Exp $ */
+
+/*-
+ * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_FILEASSOC_H_
+#define _SYS_FILEASSOC_H_
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+typedef struct fileassoc *fileassoc_t;
+typedef void (*fileassoc_cleanup_cb_t)(void *);
+typedef void (*fileassoc_cb_t)(void *, void *);
+
+int fileassoc_register(const char *, fileassoc_cleanup_cb_t, fileassoc_t *);
+int fileassoc_deregister(fileassoc_t);
+void *fileassoc_lookup(struct vnode *, fileassoc_t);
+int fileassoc_table_delete(struct mount *);
+int fileassoc_table_clear(struct mount *, fileassoc_t);
+int fileassoc_file_delete(struct vnode *);
+int fileassoc_add(struct vnode *, fileassoc_t, void *);
+int fileassoc_clear(struct vnode *, fileassoc_t);
+int fileassoc_table_run(struct mount *, fileassoc_t, fileassoc_cb_t, void *);
+
+#endif /* !_SYS_FILEASSOC_H_ */
--- /dev/null
+/* $NetBSD: filedesc.h,v 1.63 2012/02/11 23:16:18 martin Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_FILEDESC_H_
+#define _SYS_FILEDESC_H_
+
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/rwlock.h>
+#include <sys/condvar.h>
+
+/*
+ * This structure is used for the management of descriptors. It may be
+ * shared by multiple processes.
+ *
+ * A process is initially started out with NDFILE descriptors stored within
+ * this structure, selected to be enough for typical applications based on
+ * the historical limit of 20 open files (and the usage of descriptors by
+ * shells). If these descriptors are exhausted, a larger descriptor table
+ * may be allocated, up to a process' resource limit; the internal arrays
+ * are then unused. The initial expansion is set to NDEXTENT; each time
+ * it runs out, it is doubled until the resource limit is reached. NDEXTENT
+ * should be selected to be the biggest multiple of OFILESIZE (see below)
+ * that will fit in a power-of-two sized piece of memory.
+ */
+#define NDFILE 20
+#define NDEXTENT 50 /* 250 bytes in 256-byte alloc */
+#define NDENTRIES 32 /* 32 fds per entry */
+#define NDENTRYMASK (NDENTRIES - 1)
+#define NDENTRYSHIFT 5 /* bits per entry */
+#define NDLOSLOTS(x) (((x) + NDENTRIES - 1) >> NDENTRYSHIFT)
+#define NDHISLOTS(x) ((NDLOSLOTS(x) + NDENTRIES - 1) >> NDENTRYSHIFT)
+#define NDFDFILE 6 /* first 6 descriptors are free */
+
+/*
+ * Process-private descriptor reference, one for each descriptor slot
+ * in use. Locks:
+ *
+ * : unlocked
+ * a atomic operations + filedesc_t::fd_lock in some cases
+ * d filedesc_t::fd_lock
+ *
+ * Note that ff_exclose and ff_allocated are likely to be byte sized
+ * (bool). In general adjacent sub-word sized fields must be locked
+ * the same way, but in this case it's ok: ff_exclose can only be
+ * modified while the descriptor slot is live, and ff_allocated when
+ * it's invalid.
+ */
+typedef struct fdfile {
+ bool ff_exclose; /* :: close on exec flag */
+ bool ff_allocated; /* d: descriptor slot is allocated */
+ u_int ff_refcnt; /* a: reference count on structure */
+ struct file *ff_file; /* d: pointer to file if open */
+ SLIST_HEAD(,knote) ff_knlist; /* d: knotes attached to this fd */
+ kcondvar_t ff_closing; /* d: notifier for close */
+} fdfile_t;
+
+/* Reference count */
+#define FR_CLOSING (0x80000000) /* closing: must interlock */
+#define FR_MASK (~FR_CLOSING) /* reference count */
+
+/*
+ * Open file table, potentially many 'active' tables per filedesc_t
+ * in a multi-threaded process, or with a shared filedesc_t (clone()).
+ * nfiles is first to avoid pointer arithmetic.
+ */
+typedef struct fdtab {
+ u_int dt_nfiles; /* number of open files allocated */
+ struct fdtab *dt_link; /* for lists of dtab */
+ fdfile_t *dt_ff[NDFILE]; /* file structures for open fds */
+} fdtab_t;
+
+typedef struct filedesc {
+ /*
+ * Built-in fdfile_t records first, since they have strict
+ * alignment requirements.
+ */
+ uint8_t fd_dfdfile[NDFDFILE][CACHE_LINE_SIZE];
+ /*
+ * All of the remaining fields are locked by fd_lock.
+ */
+ kmutex_t fd_lock; /* lock on structure */
+ fdtab_t * volatile fd_dt; /* active descriptor table */
+ uint32_t *fd_himap; /* each bit points to 32 fds */
+ uint32_t *fd_lomap; /* bitmap of free fds */
+ struct klist *fd_knhash; /* hash of attached non-fd knotes */
+ int fd_lastkqfile; /* max descriptor for kqueue */
+ int fd_lastfile; /* high-water mark of fd_ofiles */
+ int fd_refcnt; /* reference count */
+ u_long fd_knhashmask; /* size of fd_knhash */
+ int fd_freefile; /* approx. next free file */
+ int fd_unused; /* unused */
+ bool fd_exclose; /* non-zero if >0 fd with EXCLOSE */
+ /*
+ * This structure is used when the number of open files is
+ * <= NDFILE, and are then pointed to by the pointers above.
+ */
+ fdtab_t fd_dtbuiltin;
+ /*
+ * These arrays are used when the number of open files is
+ * <= 1024, and are then pointed to by the pointers above.
+ */
+#define fd_startzero fd_dhimap /* area to zero on return to cache */
+ uint32_t fd_dhimap[NDENTRIES >> NDENTRYSHIFT];
+ uint32_t fd_dlomap[NDENTRIES];
+} filedesc_t;
+
+typedef struct cwdinfo {
+ struct vnode *cwdi_cdir; /* current directory */
+ struct vnode *cwdi_rdir; /* root directory */
+ struct vnode *cwdi_edir; /* emulation root (if known) */
+ krwlock_t cwdi_lock; /* lock on entire struct */
+ u_short cwdi_cmask; /* mask for file creation */
+ u_int cwdi_refcnt; /* reference count */
+} cwdinfo_t;
+
+#ifdef _KERNEL
+
+struct fileops;
+struct socket;
+struct proc;
+
+/*
+ * Kernel global variables and routines.
+ */
+void fd_sys_init(void);
+int fd_open(const char*, int, int, int*);
+int fd_dupopen(int, int *, int, int);
+int fd_alloc(struct proc *, int, int *);
+void fd_tryexpand(struct proc *);
+int fd_allocfile(file_t **, int *);
+void fd_affix(struct proc *, file_t *, unsigned);
+void fd_abort(struct proc *, file_t *, unsigned);
+filedesc_t *fd_copy(void);
+filedesc_t *fd_init(filedesc_t *);
+void fd_share(proc_t *);
+void fd_hold(lwp_t *);
+void fd_free(void);
+void fd_closeexec(void);
+void fd_ktrexecfd(void);
+int fd_checkstd(void);
+file_t *fd_getfile(unsigned);
+file_t *fd_getfile2(proc_t *, unsigned);
+void fd_putfile(unsigned);
+int fd_getvnode(unsigned, file_t **);
+int fd_getsock(unsigned, struct socket **);
+int fd_getsock1(unsigned, struct socket **, file_t **);
+void fd_putvnode(unsigned);
+void fd_putsock(unsigned);
+int fd_close(unsigned);
+int fd_dup(file_t *, int, int *, bool);
+int fd_dup2(file_t *, unsigned, int);
+int fd_clone(file_t *, unsigned, int, const struct fileops *, void *);
+void fd_set_exclose(struct lwp *, int, bool);
+int pipe1(struct lwp *, register_t *, int);
+int dodup(struct lwp *, int, int, int, register_t *);
+
+void cwd_sys_init(void);
+struct cwdinfo *cwdinit(void);
+void cwdshare(proc_t *);
+void cwdunshare(proc_t *);
+void cwdfree(struct cwdinfo *);
+void cwdexec(struct proc *);
+
+#define GETCWD_CHECK_ACCESS 0x0001
+int getcwd_common(struct vnode *, struct vnode *, char **, char *, int,
+ int, struct lwp *);
+int vnode_to_path(char *, size_t, struct vnode *, struct lwp *,
+ struct proc *);
+
+int closef(file_t *);
+file_t *fgetdummy(void);
+void fputdummy(file_t *);
+
+struct stat;
+int do_sys_fstat(int, struct stat *);
+struct flock;
+int do_fcntl_lock(int, int, struct flock *);
+int do_posix_fadvise(int, off_t, off_t, int);
+
+extern kmutex_t filelist_lock;
+extern filedesc_t filedesc0;
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_FILEDESC_H_ */
--- /dev/null
+/* $NetBSD: filio.h,v 1.10 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)filio.h 8.1 (Berkeley) 3/28/94
+ */
+
+#ifndef _SYS_FILIO_H_
+#define _SYS_FILIO_H_
+
+#include <sys/ioccom.h>
+
+/* Generic file-descriptor ioctl's. */
+#define FIOCLEX _IO('f', 1) /* set close on exec on fd */
+#define FIONCLEX _IO('f', 2) /* remove close on exec */
+#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
+#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
+#define FIOSETOWN _IOW('f', 124, int) /* set owner */
+#define FIOGETOWN _IOR('f', 123, int) /* get owner */
+#define OFIOGETBMAP _IOWR('f', 122, uint32_t) /* get underlying block no. */
+#define FIOGETBMAP _IOWR('f', 122, daddr_t) /* get underlying block no. */
+#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding
+ * in send queue. */
+#define FIONSPACE _IOR('f', 120, int) /* get space in send queue. */
+
+
+/* Ugly symbol for compatibility with other operating systems */
+#define FIBMAP FIOGETBMAP
+
+#endif /* !_SYS_FILIO_H_ */
--- /dev/null
+/* $NetBSD: flashio.h,v 1.4 2011/06/28 20:49:43 ahoka Exp $ */
+
+/*-
+ * Copyright (c) 2011 Department of Software Engineering,
+ * University of Szeged, Hungary
+ * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org>
+ * Copyright (c) 2010 David Tengeri <dtengeri@inf.u-szeged.hu>
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by the Department of Software Engineering, University of Szeged, Hungary
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FLASHIO_H_
+#define _FLASHIO_H_
+
+#include <sys/ioctl.h>
+
+/* this header may be used fron the kernel */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/types.h>
+#else
+#include <stdint.h>
+#include <stdbool.h>
+#endif
+
+enum {
+ FLASH_ERASE_DONE = 0x0,
+ FLASH_ERASE_FAILED = 0x1
+};
+
+enum {
+ FLASH_TYPE_UNKNOWN = 0x0,
+ FLASH_TYPE_NOR = 0x1,
+ FLASH_TYPE_NAND = 0x2
+};
+
+/* public userspace API */
+
+/* common integer type to address flash */
+typedef int64_t flash_off_t;
+typedef uint64_t flash_size_t;
+typedef uint64_t flash_addr_t;
+
+/**
+ * struct erase_params - for ioctl erase call
+ * @addr: start address of the erase
+ * @len: length of the erase
+ */
+struct flash_erase_params {
+ flash_off_t ep_addr;
+ flash_off_t ep_len;
+};
+
+struct flash_badblock_params {
+ flash_off_t bbp_addr;
+ bool bbp_isbad;
+};
+
+struct flash_info_params {
+ flash_off_t ip_flash_size;
+ flash_size_t ip_page_size;
+ flash_size_t ip_erase_size;
+ uint8_t ip_flash_type;
+};
+
+struct flash_dump_params {
+ flash_off_t dp_block;
+ flash_off_t dp_len;
+ uint8_t *dp_buf;
+};
+
+enum {
+ FLASH_IOCTL_ERASE_BLOCK,
+ FLASH_IOCTL_DUMP,
+ FLASH_IOCTL_GET_INFO,
+ FLASH_IOCTL_BLOCK_ISBAD,
+ FLASH_IOCTL_BLOCK_MARKBAD
+};
+
+#define FLASH_ERASE_BLOCK \
+ _IOW('&', FLASH_IOCTL_ERASE_BLOCK, struct flash_erase_params)
+
+#define FLASH_DUMP \
+ _IOWR('&', FLASH_IOCTL_DUMP, struct flash_dump_params)
+
+#define FLASH_GET_INFO \
+ _IOWR('&', FLASH_IOCTL_GET_INFO, struct flash_info_params)
+
+#define FLASH_BLOCK_ISBAD \
+ _IOWR('&', FLASH_IOCTL_BLOCK_ISBAD, struct flash_badblock_params)
+
+#define FLASH_BLOCK_MARKBAD \
+ _IOW('&', FLASH_IOCTL_BLOCK_MARKBAD, struct flash_badblock_params)
+
+#endif
+
--- /dev/null
+/* $NetBSD: fstrans.h,v 1.10 2008/11/07 00:15:42 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Juergen Hannken-Illjes.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * File system transaction operations.
+ */
+
+#ifndef _SYS_FSTRANS_H_
+#define _SYS_FSTRANS_H_
+
+#include <sys/mount.h>
+
+#define SUSPEND_SUSPEND 0x0001 /* VFS_SUSPENDCTL: suspend */
+#define SUSPEND_RESUME 0x0002 /* VFS_SUSPENDCTL: resume */
+
+enum fstrans_lock_type {
+ FSTRANS_LAZY = 1, /* Granted while not suspended */
+ FSTRANS_SHARED = 2 /* Granted while not suspending */
+#ifdef _FSTRANS_API_PRIVATE
+ ,
+ FSTRANS_EXCL = 3 /* Internal: exclusive lock */
+#endif /* _FSTRANS_API_PRIVATE */
+};
+
+enum fstrans_state {
+ FSTRANS_NORMAL,
+ FSTRANS_SUSPENDING,
+ FSTRANS_SUSPENDED
+};
+
+void fstrans_init(void);
+#define fstrans_start(mp, t) _fstrans_start((mp), (t), 1)
+#define fstrans_start_nowait(mp, t) _fstrans_start((mp), (t), 0)
+int _fstrans_start(struct mount *, enum fstrans_lock_type, int);
+void fstrans_done(struct mount *);
+int fstrans_is_owner(struct mount *);
+int fstrans_mount(struct mount *);
+void fstrans_unmount(struct mount *);
+
+int fstrans_setstate(struct mount *, enum fstrans_state);
+enum fstrans_state fstrans_getstate(struct mount *);
+
+int fscow_establish(struct mount *, int (*)(void *, struct buf *, bool),
+ void *);
+int fscow_disestablish(struct mount *, int (*)(void *, struct buf *, bool),
+ void *);
+int fscow_run(struct buf *, bool);
+
+int vfs_suspend(struct mount *, int);
+void vfs_resume(struct mount *);
+
+#endif /* _SYS_FSTRANS_H_ */
--- /dev/null
+/* $NetBSD: gpio.h,v 1.13 2011/11/13 16:56:15 mbalmer Exp $ */
+/* $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $ */
+/*
+ * Copyright (c) 2009, 2011 Marc Balmer <marc@msys.ch>
+ * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SYS_GPIO_H_
+#define _SYS_GPIO_H_
+
+#include <sys/time.h>
+
+/* GPIO pin states */
+#define GPIO_PIN_LOW 0x00 /* low level (logical 0) */
+#define GPIO_PIN_HIGH 0x01 /* high level (logical 1) */
+
+/* Max name length of a pin */
+#define GPIOMAXNAME 64
+
+/* GPIO pin configuration flags */
+#define GPIO_PIN_INPUT 0x0001 /* input direction */
+#define GPIO_PIN_OUTPUT 0x0002 /* output direction */
+#define GPIO_PIN_INOUT 0x0004 /* bi-directional */
+#define GPIO_PIN_OPENDRAIN 0x0008 /* open-drain output */
+#define GPIO_PIN_PUSHPULL 0x0010 /* push-pull output */
+#define GPIO_PIN_TRISTATE 0x0020 /* output disabled */
+#define GPIO_PIN_PULLUP 0x0040 /* internal pull-up enabled */
+#define GPIO_PIN_PULLDOWN 0x0080 /* internal pull-down enabled */
+#define GPIO_PIN_INVIN 0x0100 /* invert input */
+#define GPIO_PIN_INVOUT 0x0200 /* invert output */
+#define GPIO_PIN_USER 0x0400 /* user != 0 can access */
+#define GPIO_PIN_PULSATE 0x0800 /* pulsate in hardware */
+#define GPIO_PIN_SET 0x8000 /* set for securelevel access */
+
+/* GPIO controller description */
+struct gpio_info {
+ int gpio_npins; /* total number of pins available */
+};
+
+/* GPIO pin request (read/write/toggle) */
+struct gpio_req {
+ char gp_name[GPIOMAXNAME]; /* pin name */
+ int gp_pin; /* pin number */
+ int gp_value; /* value */
+};
+
+/* GPIO pin configuration */
+struct gpio_set {
+ char gp_name[GPIOMAXNAME];
+ int gp_pin;
+ int gp_caps;
+ int gp_flags;
+ char gp_name2[GPIOMAXNAME]; /* new name */
+};
+
+/* Attach device drivers that use GPIO pins */
+struct gpio_attach {
+ char ga_dvname[16]; /* device name */
+ int ga_offset; /* pin number */
+ uint32_t ga_mask; /* binary mask */
+ uint32_t ga_flags; /* driver dependent flags */
+};
+
+/* gpio(4) API */
+#define GPIOINFO _IOR('G', 0, struct gpio_info)
+#define GPIOSET _IOWR('G', 5, struct gpio_set)
+#define GPIOUNSET _IOWR('G', 6, struct gpio_set)
+#define GPIOREAD _IOWR('G', 7, struct gpio_req)
+#define GPIOWRITE _IOWR('G', 8, struct gpio_req)
+#define GPIOTOGGLE _IOWR('G', 9, struct gpio_req)
+#define GPIOATTACH _IOWR('G', 10, struct gpio_attach)
+
+#ifdef COMPAT_50
+/* Old structure to attach/detach devices */
+struct gpio_attach50 {
+ char ga_dvname[16]; /* device name */
+ int ga_offset; /* pin number */
+ uint32_t ga_mask; /* binary mask */
+};
+
+/* GPIO pin control (old API) */
+struct gpio_pin_ctl {
+ int gp_pin; /* pin number */
+ int gp_caps; /* pin capabilities (read-only) */
+ int gp_flags; /* pin configuration flags */
+};
+
+/* GPIO pin operation (read/write/toggle) (old API) */
+struct gpio_pin_op {
+ int gp_pin; /* pin number */
+ int gp_value; /* value */
+};
+
+/* the old API */
+#define GPIOPINREAD _IOWR('G', 1, struct gpio_pin_op)
+#define GPIOPINWRITE _IOWR('G', 2, struct gpio_pin_op)
+#define GPIOPINTOGGLE _IOWR('G', 3, struct gpio_pin_op)
+#define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl)
+#define GPIOATTACH50 _IOWR('G', 10, struct gpio_attach50)
+#define GPIODETACH50 _IOWR('G', 11, struct gpio_attach50)
+#define GPIODETACH _IOWR('G', 11, struct gpio_attach)
+#endif /* COMPAT_50 */
+
+#endif /* !_SYS_GPIO_H_ */
--- /dev/null
+/* $NetBSD: idle.h,v 1.4 2008/05/27 14:48:52 ad Exp $ */
+
+/*-
+ * Copyright (c)2002, 2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_IDLE_H_
+#define _SYS_IDLE_H_
+
+struct cpu_info;
+
+void idle_loop(void *);
+int create_idle_lwp(struct cpu_info *);
+
+#endif /* !_SYS_IDLE_H_ */
--- /dev/null
+/* $NetBSD: intr.h,v 1.12 2012/07/27 14:05:08 matt Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_INTR_H_
+#define _SYS_INTR_H_
+
+#include <machine/intr.h>
+
+#ifdef _KERNEL
+
+struct cpu_info;
+
+/* Public interface. */
+void *softint_establish(u_int, void (*)(void *), void *);
+void softint_disestablish(void *);
+void softint_schedule(void *);
+
+/* MI hooks. */
+void softint_init(struct cpu_info *);
+lwp_t *softint_picklwp(void);
+void softint_overlay(void);
+void softint_block(lwp_t *);
+
+/* MD-MI interface. */
+void softint_init_md(lwp_t *, u_int, uintptr_t *);
+void softint_trigger(uintptr_t);
+void softint_dispatch(lwp_t *, int);
+
+/* Flags for softint_establish(). */
+#define SOFTINT_BIO 0x0000
+#define SOFTINT_CLOCK 0x0001
+#define SOFTINT_SERIAL 0x0002
+#define SOFTINT_NET 0x0003
+#define SOFTINT_MPSAFE 0x0100
+
+/* Implementation private flags. */
+#define SOFTINT_PENDING 0x1000
+#define SOFTINT_ACTIVE 0x2000
+
+#define SOFTINT_COUNT 0x0004
+#define SOFTINT_LVLMASK 0x00ff
+#define SOFTINT_IMPMASK 0xf000
+
+extern u_int softint_timing;
+
+/*
+ * Historical aliases.
+ */
+#define IPL_BIO IPL_VM
+#define IPL_NET IPL_VM
+#define IPL_TTY IPL_VM
+#define IPL_AUDIO IPL_SCHED
+#define IPL_CLOCK IPL_SCHED
+#define IPL_SERIAL IPL_HIGH
+
+#define splbio() splvm()
+#define splnet() splvm()
+#define spltty() splvm()
+#define splaudio() splsched()
+#define splclock() splsched()
+#define splserial() splhigh()
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_INTR_H_ */
--- /dev/null
+/* $NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $ */
+
+/*
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_IOCTL_COMPAT_H_
+#define _SYS_IOCTL_COMPAT_H_
+
+#include <sys/ttychars.h>
+#include <sys/ttydev.h>
+
+struct tchars {
+ char t_intrc; /* interrupt */
+ char t_quitc; /* quit */
+ char t_startc; /* start output */
+ char t_stopc; /* stop output */
+ char t_eofc; /* end-of-file */
+ char t_brkc; /* input delimiter (like nl) */
+};
+
+struct ltchars {
+ char t_suspc; /* stop process signal */
+ char t_dsuspc; /* delayed stop process signal */
+ char t_rprntc; /* reprint line */
+ char t_flushc; /* flush output (toggles) */
+ char t_werasc; /* word erase */
+ char t_lnextc; /* literal next character */
+};
+
+/*
+ * Structure for TIOCGETP and TIOCSETP ioctls.
+ */
+#ifndef _SGTTYB_
+#define _SGTTYB_
+struct sgttyb {
+ char sg_ispeed; /* input speed */
+ char sg_ospeed; /* output speed */
+ char sg_erase; /* erase character */
+ char sg_kill; /* kill character */
+ short sg_flags; /* mode flags */
+};
+#endif
+
+#ifdef USE_OLD_TTY
+# undef TIOCGETD
+# define TIOCGETD _IOR('t', 0, int) /* get line discipline */
+# undef TIOCSETD
+# define TIOCSETD _IOW('t', 1, int) /* set line discipline */
+#else
+# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
+# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
+#endif
+#define TIOCHPCL _IO('t', 2) /* hang up on last close */
+#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
+#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
+#define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
+#define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */
+#define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */
+#define TANDEM 0x00000001 /* send stopc on out q full */
+#define CBREAK 0x00000002 /* half-cooked mode */
+#define LCASE 0x00000004 /* simulate lower case */
+#define ECHO 0x00000008 /* enable echoing */
+#define CRMOD 0x00000010 /* map \r to \r\n on output */
+#define RAW 0x00000020 /* no i/o processing */
+#define ODDP 0x00000040 /* get/send odd parity */
+#define EVENP 0x00000080 /* get/send even parity */
+#define ANYP 0x000000c0 /* get any parity/send none */
+#define NLDELAY 0x00000300 /* \n delay */
+#define NL0 0x00000000
+#define NL1 0x00000100 /* tty 37 */
+#define NL2 0x00000200 /* vt05 */
+#define NL3 0x00000300
+#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TAB0 0x00000000
+#define TAB1 0x00000400 /* tty 37 */
+#define TAB2 0x00000800
+#define XTABS 0x00000c00 /* expand tabs on output */
+#define CRDELAY 0x00003000 /* \r delay */
+#define CR0 0x00000000
+#define CR1 0x00001000 /* tn 300 */
+#define CR2 0x00002000 /* tty 37 */
+#define CR3 0x00003000 /* concept 100 */
+#define VTDELAY 0x00004000 /* vertical tab delay */
+#define FF0 0x00000000
+#define FF1 0x00004000 /* tty 37 */
+#define BSDELAY 0x00008000 /* \b delay */
+#define BS0 0x00000000
+#define BS1 0x00008000
+#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
+#define CRTBS 0x00010000 /* do backspacing for crt */
+#define PRTERA 0x00020000 /* \ ... / erase */
+#define CRTERA 0x00040000 /* " \b " to wipe out char */
+#define TILDE 0x00080000 /* hazeltine tilde kludge */
+#define MDMBUF 0x00100000 /* DTR/DCD hardware flow control */
+#define LITOUT 0x00200000 /* literal output */
+#define TOSTOP 0x00400000 /* stop background jobs on output */
+#define FLUSHO 0x00800000 /* output being flushed (state) */
+#define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
+#define L001000 0x02000000
+#define CRTKIL 0x04000000 /* kill line with " \b " */
+#define PASS8 0x08000000
+#define CTLECH 0x10000000 /* echo control chars as ^X */
+#define PENDIN 0x20000000 /* re-echo input buffer at next read */
+#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
+#define NOFLSH 0x80000000 /* don't flush output on signal */
+#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
+#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
+#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
+#define TIOCLGET _IOR('t', 124, int) /* get local modes */
+#define LCRTBS (CRTBS>>16)
+#define LPRTERA (PRTERA>>16)
+#define LCRTERA (CRTERA>>16)
+#define LTILDE (TILDE>>16)
+#define LMDMBUF (MDMBUF>>16)
+#define LLITOUT (LITOUT>>16)
+#define LTOSTOP (TOSTOP>>16)
+#define LFLUSHO (FLUSHO>>16)
+#define LNOHANG (NOHANG>>16)
+#define LCRTKIL (CRTKIL>>16)
+#define LPASS8 (PASS8>>16)
+#define LCTLECH (CTLECH>>16)
+#define LPENDIN (PENDIN>>16)
+#define LDECCTQ (DECCTQ>>16)
+#define LNOFLSH (NOFLSH>>16)
+#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/
+#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/
+#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
+#define OTTYDISC 0
+#define NETLDISC 1
+#define NTTYDISC 2
+
+#endif /* !_SYS_IOCTL_COMPAT_H_ */
--- /dev/null
+/* $NetBSD: joystick.h,v 1.2 2005/12/03 17:10:46 christos Exp $ */
+
+#ifndef _SYS_JOYSTICK_H_
+#define _SYS_JOYSTICK_H_
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+struct joystick {
+ int x;
+ int y;
+ int b1;
+ int b2;
+};
+
+#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
+#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
+#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */
+#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on X-axis */
+#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */
+#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */
+
+#endif /* _SYS_JOYSTICK_H_ */
--- /dev/null
+/* $NetBSD: kauth.h,v 1.70 2012/06/27 12:28:28 cheusov Exp $ */
+
+/*-
+ * Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This is based on Apple TN2127, available online at
+ * http://developer.apple.com/technotes/tn2005/tn2127.html
+ */
+
+#ifndef _SYS_KAUTH_H_
+#define _SYS_KAUTH_H_
+
+#include <secmodel/secmodel.h> /* for secmodel_t type */
+#include <sys/stat.h> /* for modes */
+
+struct uucred;
+struct ki_ucred;
+struct ki_pcred;
+struct proc;
+struct tty;
+struct vnode;
+struct cwdinfo;
+enum vtype;
+
+/* Types. */
+typedef struct kauth_scope *kauth_scope_t;
+typedef struct kauth_listener *kauth_listener_t;
+typedef uint32_t kauth_action_t;
+typedef int (*kauth_scope_callback_t)(kauth_cred_t, kauth_action_t,
+ void *, void *, void *, void *, void *);
+typedef struct kauth_key *kauth_key_t;
+
+/*
+ * Possible return values for a listener.
+ */
+#define KAUTH_RESULT_ALLOW 0 /* allow access */
+#define KAUTH_RESULT_DENY 1 /* deny access */
+#define KAUTH_RESULT_DEFER 2 /* let others decide */
+
+/*
+ * Scopes.
+ */
+#define KAUTH_SCOPE_GENERIC "org.netbsd.kauth.generic"
+#define KAUTH_SCOPE_SYSTEM "org.netbsd.kauth.system"
+#define KAUTH_SCOPE_PROCESS "org.netbsd.kauth.process"
+#define KAUTH_SCOPE_NETWORK "org.netbsd.kauth.network"
+#define KAUTH_SCOPE_MACHDEP "org.netbsd.kauth.machdep"
+#define KAUTH_SCOPE_DEVICE "org.netbsd.kauth.device"
+#define KAUTH_SCOPE_CRED "org.netbsd.kauth.cred"
+#define KAUTH_SCOPE_VNODE "org.netbsd.kauth.vnode"
+
+/*
+ * Generic scope - actions.
+ */
+enum {
+ KAUTH_GENERIC_UNUSED1=1,
+ KAUTH_GENERIC_ISSUSER,
+};
+
+/*
+ * System scope - actions.
+ */
+enum {
+ KAUTH_SYSTEM_ACCOUNTING=1,
+ KAUTH_SYSTEM_CHROOT,
+ KAUTH_SYSTEM_CHSYSFLAGS,
+ KAUTH_SYSTEM_CPU,
+ KAUTH_SYSTEM_DEBUG,
+ KAUTH_SYSTEM_FILEHANDLE,
+ KAUTH_SYSTEM_MKNOD,
+ KAUTH_SYSTEM_MOUNT,
+ KAUTH_SYSTEM_PSET,
+ KAUTH_SYSTEM_REBOOT,
+ KAUTH_SYSTEM_SETIDCORE,
+ KAUTH_SYSTEM_SWAPCTL,
+ KAUTH_SYSTEM_SYSCTL,
+ KAUTH_SYSTEM_TIME,
+ KAUTH_SYSTEM_MODULE,
+ KAUTH_SYSTEM_FS_RESERVEDSPACE,
+ KAUTH_SYSTEM_FS_QUOTA,
+ KAUTH_SYSTEM_SEMAPHORE,
+ KAUTH_SYSTEM_SYSVIPC,
+ KAUTH_SYSTEM_MQUEUE,
+ KAUTH_SYSTEM_VERIEXEC,
+ KAUTH_SYSTEM_DEVMAPPER,
+ KAUTH_SYSTEM_MAP_VA_ZERO,
+ KAUTH_SYSTEM_LFS,
+ KAUTH_SYSTEM_FS_EXTATTR,
+ KAUTH_SYSTEM_FS_SNAPSHOT,
+};
+
+/*
+ * System scope - sub-actions.
+ */
+enum kauth_system_req {
+ KAUTH_REQ_SYSTEM_CHROOT_CHROOT=1,
+ KAUTH_REQ_SYSTEM_CHROOT_FCHROOT,
+ KAUTH_REQ_SYSTEM_CPU_SETSTATE,
+ KAUTH_REQ_SYSTEM_DEBUG_IPKDB,
+ KAUTH_REQ_SYSTEM_MOUNT_GET,
+ KAUTH_REQ_SYSTEM_MOUNT_NEW,
+ KAUTH_REQ_SYSTEM_MOUNT_UNMOUNT,
+ KAUTH_REQ_SYSTEM_MOUNT_UPDATE,
+ KAUTH_REQ_SYSTEM_PSET_ASSIGN,
+ KAUTH_REQ_SYSTEM_PSET_BIND,
+ KAUTH_REQ_SYSTEM_PSET_CREATE,
+ KAUTH_REQ_SYSTEM_PSET_DESTROY,
+ KAUTH_REQ_SYSTEM_SYSCTL_ADD,
+ KAUTH_REQ_SYSTEM_SYSCTL_DELETE,
+ KAUTH_REQ_SYSTEM_SYSCTL_DESC,
+ KAUTH_REQ_SYSTEM_SYSCTL_MODIFY,
+ KAUTH_REQ_SYSTEM_SYSCTL_PRVT,
+ KAUTH_REQ_SYSTEM_TIME_ADJTIME,
+ KAUTH_REQ_SYSTEM_TIME_NTPADJTIME,
+ KAUTH_REQ_SYSTEM_TIME_RTCOFFSET,
+ KAUTH_REQ_SYSTEM_TIME_SYSTEM,
+ KAUTH_REQ_SYSTEM_TIME_TIMECOUNTERS,
+ KAUTH_REQ_SYSTEM_FS_QUOTA_GET,
+ KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE,
+ KAUTH_REQ_SYSTEM_FS_QUOTA_NOLIMIT,
+ KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF,
+ KAUTH_REQ_SYSTEM_SYSVIPC_BYPASS,
+ KAUTH_REQ_SYSTEM_SYSVIPC_SHM_LOCK,
+ KAUTH_REQ_SYSTEM_SYSVIPC_SHM_UNLOCK,
+ KAUTH_REQ_SYSTEM_SYSVIPC_MSGQ_OVERSIZE,
+ KAUTH_REQ_SYSTEM_VERIEXEC_ACCESS,
+ KAUTH_REQ_SYSTEM_VERIEXEC_MODIFY,
+ KAUTH_REQ_SYSTEM_LFS_MARKV,
+ KAUTH_REQ_SYSTEM_LFS_BMAPV,
+ KAUTH_REQ_SYSTEM_LFS_SEGCLEAN,
+ KAUTH_REQ_SYSTEM_LFS_SEGWAIT,
+ KAUTH_REQ_SYSTEM_LFS_FCNTL,
+ KAUTH_REQ_SYSTEM_MOUNT_UMAP,
+ KAUTH_REQ_SYSTEM_MOUNT_DEVICE,
+};
+
+/*
+ * Process scope - actions.
+ */
+enum {
+ KAUTH_PROCESS_CANSEE=1,
+ KAUTH_PROCESS_CORENAME,
+ KAUTH_PROCESS_FORK,
+ KAUTH_PROCESS_KEVENT_FILTER,
+ KAUTH_PROCESS_KTRACE,
+ KAUTH_PROCESS_NICE,
+ KAUTH_PROCESS_PROCFS,
+ KAUTH_PROCESS_PTRACE,
+ KAUTH_PROCESS_RLIMIT,
+ KAUTH_PROCESS_SCHEDULER_GETAFFINITY,
+ KAUTH_PROCESS_SCHEDULER_SETAFFINITY,
+ KAUTH_PROCESS_SCHEDULER_GETPARAM,
+ KAUTH_PROCESS_SCHEDULER_SETPARAM,
+ KAUTH_PROCESS_SETID,
+ KAUTH_PROCESS_SIGNAL,
+ KAUTH_PROCESS_STOPFLAG
+};
+
+/*
+ * Process scope - sub-actions.
+ */
+enum kauth_process_req {
+ KAUTH_REQ_PROCESS_CANSEE_ARGS=1,
+ KAUTH_REQ_PROCESS_CANSEE_ENTRY,
+ KAUTH_REQ_PROCESS_CANSEE_ENV,
+ KAUTH_REQ_PROCESS_CANSEE_OPENFILES,
+ KAUTH_REQ_PROCESS_CORENAME_GET,
+ KAUTH_REQ_PROCESS_CORENAME_SET,
+ KAUTH_REQ_PROCESS_KTRACE_PERSISTENT,
+ KAUTH_REQ_PROCESS_PROCFS_CTL,
+ KAUTH_REQ_PROCESS_PROCFS_READ,
+ KAUTH_REQ_PROCESS_PROCFS_RW,
+ KAUTH_REQ_PROCESS_PROCFS_WRITE,
+ KAUTH_REQ_PROCESS_RLIMIT_GET,
+ KAUTH_REQ_PROCESS_RLIMIT_SET,
+ KAUTH_REQ_PROCESS_RLIMIT_BYPASS,
+};
+
+/*
+ * Network scope - actions.
+ */
+enum {
+ KAUTH_NETWORK_ALTQ=1,
+ KAUTH_NETWORK_BIND,
+ KAUTH_NETWORK_FIREWALL,
+ KAUTH_NETWORK_INTERFACE,
+ KAUTH_NETWORK_FORWSRCRT,
+ KAUTH_NETWORK_NFS,
+ KAUTH_NETWORK_ROUTE,
+ KAUTH_NETWORK_SOCKET,
+ KAUTH_NETWORK_INTERFACE_PPP,
+ KAUTH_NETWORK_INTERFACE_SLIP,
+ KAUTH_NETWORK_INTERFACE_STRIP,
+ KAUTH_NETWORK_INTERFACE_TUN,
+ KAUTH_NETWORK_INTERFACE_BRIDGE,
+ KAUTH_NETWORK_IPSEC,
+ KAUTH_NETWORK_INTERFACE_PVC,
+ KAUTH_NETWORK_IPV6,
+ KAUTH_NETWORK_SMB,
+};
+
+/*
+ * Network scope - sub-actions.
+ */
+enum kauth_network_req {
+ KAUTH_REQ_NETWORK_ALTQ_AFMAP=1,
+ KAUTH_REQ_NETWORK_ALTQ_BLUE,
+ KAUTH_REQ_NETWORK_ALTQ_CBQ,
+ KAUTH_REQ_NETWORK_ALTQ_CDNR,
+ KAUTH_REQ_NETWORK_ALTQ_CONF,
+ KAUTH_REQ_NETWORK_ALTQ_FIFOQ,
+ KAUTH_REQ_NETWORK_ALTQ_HFSC,
+ KAUTH_REQ_NETWORK_ALTQ_JOBS,
+ KAUTH_REQ_NETWORK_ALTQ_PRIQ,
+ KAUTH_REQ_NETWORK_ALTQ_RED,
+ KAUTH_REQ_NETWORK_ALTQ_RIO,
+ KAUTH_REQ_NETWORK_ALTQ_WFQ,
+ KAUTH_REQ_NETWORK_BIND_PORT,
+ KAUTH_REQ_NETWORK_BIND_PRIVPORT,
+ KAUTH_REQ_NETWORK_FIREWALL_FW,
+ KAUTH_REQ_NETWORK_FIREWALL_NAT,
+ KAUTH_REQ_NETWORK_INTERFACE_GET,
+ KAUTH_REQ_NETWORK_INTERFACE_GETPRIV,
+ KAUTH_REQ_NETWORK_INTERFACE_SET,
+ KAUTH_REQ_NETWORK_INTERFACE_SETPRIV,
+ KAUTH_REQ_NETWORK_NFS_EXPORT,
+ KAUTH_REQ_NETWORK_NFS_SVC,
+ KAUTH_REQ_NETWORK_SOCKET_OPEN,
+ KAUTH_REQ_NETWORK_SOCKET_RAWSOCK,
+ KAUTH_REQ_NETWORK_SOCKET_CANSEE,
+ KAUTH_REQ_NETWORK_SOCKET_DROP,
+ KAUTH_REQ_NETWORK_SOCKET_SETPRIV,
+ KAUTH_REQ_NETWORK_INTERFACE_PPP_ADD,
+ KAUTH_REQ_NETWORK_INTERFACE_SLIP_ADD,
+ KAUTH_REQ_NETWORK_INTERFACE_STRIP_ADD,
+ KAUTH_REQ_NETWORK_INTERFACE_TUN_ADD,
+ KAUTH_REQ_NETWORK_IPV6_HOPBYHOP,
+ KAUTH_REQ_NETWORK_INTERFACE_BRIDGE_GETPRIV,
+ KAUTH_REQ_NETWORK_INTERFACE_BRIDGE_SETPRIV,
+ KAUTH_REQ_NETWORK_IPSEC_BYPASS,
+ KAUTH_REQ_NETWORK_IPV6_JOIN_MULTICAST,
+ KAUTH_REQ_NETWORK_INTERFACE_PVC_ADD,
+ KAUTH_REQ_NETWORK_SMB_SHARE_ACCESS,
+ KAUTH_REQ_NETWORK_SMB_SHARE_CREATE,
+ KAUTH_REQ_NETWORK_SMB_VC_ACCESS,
+ KAUTH_REQ_NETWORK_SMB_VC_CREATE,
+ KAUTH_REQ_NETWORK_INTERFACE_FIRMWARE,
+};
+
+/*
+ * Machdep scope - actions.
+ */
+enum {
+ KAUTH_MACHDEP_CACHEFLUSH=1,
+ KAUTH_MACHDEP_CPU_UCODE_APPLY,
+ KAUTH_MACHDEP_IOPERM_GET,
+ KAUTH_MACHDEP_IOPERM_SET,
+ KAUTH_MACHDEP_IOPL,
+ KAUTH_MACHDEP_LDT_GET,
+ KAUTH_MACHDEP_LDT_SET,
+ KAUTH_MACHDEP_MTRR_GET,
+ KAUTH_MACHDEP_MTRR_SET,
+ KAUTH_MACHDEP_NVRAM,
+ KAUTH_MACHDEP_UNMANAGEDMEM,
+ KAUTH_MACHDEP_PXG,
+};
+
+/*
+ * Device scope - actions.
+ */
+enum {
+ KAUTH_DEVICE_TTY_OPEN=1,
+ KAUTH_DEVICE_TTY_PRIVSET,
+ KAUTH_DEVICE_TTY_STI,
+ KAUTH_DEVICE_RAWIO_SPEC,
+ KAUTH_DEVICE_RAWIO_PASSTHRU,
+ KAUTH_DEVICE_BLUETOOTH_SETPRIV,
+ KAUTH_DEVICE_RND_ADDDATA,
+ KAUTH_DEVICE_RND_ADDDATA_ESTIMATE,
+ KAUTH_DEVICE_RND_GETPRIV,
+ KAUTH_DEVICE_RND_SETPRIV,
+ KAUTH_DEVICE_BLUETOOTH_BCSP,
+ KAUTH_DEVICE_BLUETOOTH_BTUART,
+ KAUTH_DEVICE_GPIO_PINSET,
+ KAUTH_DEVICE_BLUETOOTH_SEND,
+ KAUTH_DEVICE_BLUETOOTH_RECV,
+ KAUTH_DEVICE_TTY_VIRTUAL,
+ KAUTH_DEVICE_WSCONS_KEYBOARD_BELL,
+ KAUTH_DEVICE_WSCONS_KEYBOARD_KEYREPEAT,
+};
+
+/*
+ * Device scope - sub-actions.
+ */
+enum kauth_device_req {
+ KAUTH_REQ_DEVICE_RAWIO_SPEC_READ=1,
+ KAUTH_REQ_DEVICE_RAWIO_SPEC_WRITE,
+ KAUTH_REQ_DEVICE_RAWIO_SPEC_RW,
+ KAUTH_REQ_DEVICE_BLUETOOTH_BCSP_ADD,
+ KAUTH_REQ_DEVICE_BLUETOOTH_BTUART_ADD,
+};
+
+/*
+ * Credentials scope - actions.
+ */
+enum {
+ KAUTH_CRED_INIT=1,
+ KAUTH_CRED_FORK,
+ KAUTH_CRED_COPY,
+ KAUTH_CRED_FREE,
+ KAUTH_CRED_CHROOT
+};
+
+/*
+ * Vnode scope - action bits.
+ */
+#define KAUTH_VNODE_READ_DATA (1U << 0)
+#define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA
+#define KAUTH_VNODE_WRITE_DATA (1U << 1)
+#define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA
+#define KAUTH_VNODE_EXECUTE (1U << 2)
+#define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE
+#define KAUTH_VNODE_DELETE (1U << 3)
+#define KAUTH_VNODE_APPEND_DATA (1U << 4)
+#define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA
+#define KAUTH_VNODE_READ_TIMES (1U << 5)
+#define KAUTH_VNODE_WRITE_TIMES (1U << 6)
+#define KAUTH_VNODE_READ_FLAGS (1U << 7)
+#define KAUTH_VNODE_WRITE_FLAGS (1U << 8)
+#define KAUTH_VNODE_READ_SYSFLAGS (1U << 9)
+#define KAUTH_VNODE_WRITE_SYSFLAGS (1U << 10)
+#define KAUTH_VNODE_RENAME (1U << 11)
+#define KAUTH_VNODE_CHANGE_OWNERSHIP (1U << 12)
+#define KAUTH_VNODE_READ_SECURITY (1U << 13)
+#define KAUTH_VNODE_WRITE_SECURITY (1U << 14)
+#define KAUTH_VNODE_READ_ATTRIBUTES (1U << 15)
+#define KAUTH_VNODE_WRITE_ATTRIBUTES (1U << 16)
+#define KAUTH_VNODE_READ_EXTATTRIBUTES (1U << 17)
+#define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1U << 18)
+#define KAUTH_VNODE_RETAIN_SUID (1U << 19)
+#define KAUTH_VNODE_RETAIN_SGID (1U << 20)
+#define KAUTH_VNODE_REVOKE (1U << 21)
+
+#define KAUTH_VNODE_IS_EXEC (1U << 29)
+#define KAUTH_VNODE_HAS_SYSFLAGS (1U << 30)
+#define KAUTH_VNODE_ACCESS (1U << 31)
+
+/*
+ * This is a special fs_decision indication that can be used by file-systems
+ * that don't support decision-before-action to tell kauth(9) it can only
+ * short-circuit the operation beforehand.
+ */
+#define KAUTH_VNODE_REMOTEFS (-1)
+
+/*
+ * Device scope, passthru request - identifiers.
+ */
+#define KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_READ 0x00000001
+#define KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_WRITE 0x00000002
+#define KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_READCONF 0x00000004
+#define KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_WRITECONF 0x00000008
+#define KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_ALL 0x0000000F
+
+#define NOCRED ((kauth_cred_t)-1) /* no credential available */
+#define FSCRED ((kauth_cred_t)-2) /* filesystem credential */
+
+/* Macro to help passing arguments to authorization wrappers. */
+#define KAUTH_ARG(arg) ((void *)(unsigned long)(arg))
+
+/*
+ * A file-system object is determined to be able to execute if it's a
+ * directory or if the execute bit is present in any of the
+ * owner/group/other modes.
+ *
+ * This helper macro is intended to be used in order to implement a
+ * policy that maintains the semantics of "a privileged user can enter
+ * directory, and can execute any file, but only if the file is actually
+ * executable."
+ */
+#define FS_OBJECT_CAN_EXEC(vtype, mode) (((vtype) == VDIR) || \
+ ((mode) & \
+ (S_IXUSR|S_IXGRP|S_IXOTH)))
+
+/*
+ * Prototypes.
+ */
+void kauth_init(void);
+kauth_scope_t kauth_register_scope(const char *, kauth_scope_callback_t, void *);
+void kauth_deregister_scope(kauth_scope_t);
+kauth_listener_t kauth_listen_scope(const char *, kauth_scope_callback_t, void *);
+void kauth_unlisten_scope(kauth_listener_t);
+int kauth_authorize_action(kauth_scope_t, kauth_cred_t, kauth_action_t, void *,
+ void *, void *, void *);
+
+/* Authorization wrappers. */
+int kauth_authorize_generic(kauth_cred_t, kauth_action_t, void *);
+int kauth_authorize_system(kauth_cred_t, kauth_action_t, enum kauth_system_req,
+ void *, void *, void *);
+int kauth_authorize_process(kauth_cred_t, kauth_action_t, struct proc *,
+ void *, void *, void *);
+int kauth_authorize_network(kauth_cred_t, kauth_action_t,
+ enum kauth_network_req, void *, void *, void *);
+int kauth_authorize_machdep(kauth_cred_t, kauth_action_t,
+ void *, void *, void *, void *);
+int kauth_authorize_device(kauth_cred_t, kauth_action_t,
+ void *, void *, void *, void *);
+int kauth_authorize_device_tty(kauth_cred_t, kauth_action_t, struct tty *);
+int kauth_authorize_device_spec(kauth_cred_t, enum kauth_device_req,
+ struct vnode *);
+int kauth_authorize_device_passthru(kauth_cred_t, dev_t, u_long, void *);
+int kauth_authorize_vnode(kauth_cred_t, kauth_action_t, struct vnode *,
+ struct vnode *, int);
+
+/* Kauth credentials management routines. */
+kauth_cred_t kauth_cred_alloc(void);
+void kauth_cred_free(kauth_cred_t);
+void kauth_cred_clone(kauth_cred_t, kauth_cred_t);
+kauth_cred_t kauth_cred_dup(kauth_cred_t);
+kauth_cred_t kauth_cred_copy(kauth_cred_t);
+
+uid_t kauth_cred_getuid(kauth_cred_t);
+uid_t kauth_cred_geteuid(kauth_cred_t);
+uid_t kauth_cred_getsvuid(kauth_cred_t);
+gid_t kauth_cred_getgid(kauth_cred_t);
+gid_t kauth_cred_getegid(kauth_cred_t);
+gid_t kauth_cred_getsvgid(kauth_cred_t);
+int kauth_cred_ismember_gid(kauth_cred_t, gid_t, int *);
+u_int kauth_cred_ngroups(kauth_cred_t);
+gid_t kauth_cred_group(kauth_cred_t, u_int);
+
+void kauth_cred_setuid(kauth_cred_t, uid_t);
+void kauth_cred_seteuid(kauth_cred_t, uid_t);
+void kauth_cred_setsvuid(kauth_cred_t, uid_t);
+void kauth_cred_setgid(kauth_cred_t, gid_t);
+void kauth_cred_setegid(kauth_cred_t, gid_t);
+void kauth_cred_setsvgid(kauth_cred_t, gid_t);
+
+void kauth_cred_hold(kauth_cred_t);
+u_int kauth_cred_getrefcnt(kauth_cred_t);
+
+int kauth_cred_setgroups(kauth_cred_t, const gid_t *, size_t, uid_t,
+ enum uio_seg);
+int kauth_cred_getgroups(kauth_cred_t, gid_t *, size_t, enum uio_seg);
+
+/* This is for sys_setgroups() */
+int kauth_proc_setgroups(struct lwp *, kauth_cred_t);
+
+int kauth_register_key(secmodel_t, kauth_key_t *);
+int kauth_deregister_key(kauth_key_t);
+void kauth_cred_setdata(kauth_cred_t, kauth_key_t, void *);
+void *kauth_cred_getdata(kauth_cred_t, kauth_key_t);
+
+int kauth_cred_uidmatch(kauth_cred_t, kauth_cred_t);
+void kauth_uucred_to_cred(kauth_cred_t, const struct uucred *);
+void kauth_cred_to_uucred(struct uucred *, const kauth_cred_t);
+int kauth_cred_uucmp(kauth_cred_t, const struct uucred *);
+void kauth_cred_toucred(kauth_cred_t, struct ki_ucred *);
+void kauth_cred_topcred(kauth_cred_t, struct ki_pcred *);
+
+kauth_action_t kauth_mode_to_action(mode_t);
+kauth_action_t kauth_access_action(mode_t, enum vtype, mode_t);
+kauth_action_t kauth_extattr_action(mode_t);
+
+kauth_cred_t kauth_cred_get(void);
+
+void kauth_proc_fork(struct proc *, struct proc *);
+void kauth_proc_chroot(kauth_cred_t cred, struct cwdinfo *cwdi);
+
+#endif /* !_SYS_KAUTH_H_ */
--- /dev/null
+/* $NetBSD: kcore.h,v 1.4 2011/01/18 08:17:39 matt Exp $ */
+
+/*
+ * Copyright (c) 1996 Leo Weppelman.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_KCORE_H_
+#define _SYS_KCORE_H_
+
+/*
+ * Definitions for the kernel crash-dump format. The structure of
+ * the files and headers is borrowed from the 'regular' core files
+ * as described in <sys/core.h>.
+ */
+#define KCORE_MAGIC 0x8fca
+#define KCORESEG_MAGIC 0x8fac
+
+/*
+ * Description of a memory segment. To make this suitable for sharing
+ * between all architectures, u_quad_t seems to be the necessary type...
+ */
+typedef struct phys_ram_seg {
+ u_quad_t start; /* Physical start address */
+ u_quad_t size; /* Size in bytes */
+} phys_ram_seg_t;
+
+typedef struct kcore_hdr {
+ uint32_t c_midmag; /* Magic, id, flags */
+ uint16_t c_hdrsize; /* Aligned header size */
+ uint16_t c_seghdrsize; /* Aligned seg-header size */
+ uint32_t c_nseg; /* Number of segments */
+} kcore_hdr_t;
+
+typedef struct kcore_seg {
+ uint32_t c_midmag; /* Magic, id, flags */
+ uint32_t c_size; /* Sizeof this segment */
+} kcore_seg_t;
+
+#endif /* _SYS_KCORE_H_ */
--- /dev/null
+/* $NetBSD: kcpuset.h,v 1.8 2012/09/16 22:09:33 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2008, 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas and Mindaugas Rasiukevicius.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KCPUSET_H_
+#define _SYS_KCPUSET_H_
+
+struct kcpuset;
+typedef struct kcpuset kcpuset_t;
+
+#ifdef _KERNEL
+
+#include <sys/sched.h>
+
+void kcpuset_sysinit(void);
+
+void kcpuset_create(kcpuset_t **, bool);
+void kcpuset_destroy(kcpuset_t *);
+void kcpuset_copy(kcpuset_t *, kcpuset_t *);
+
+void kcpuset_use(kcpuset_t *);
+void kcpuset_unuse(kcpuset_t *, kcpuset_t **);
+
+int kcpuset_copyin(const cpuset_t *, kcpuset_t *, size_t);
+int kcpuset_copyout(kcpuset_t *, cpuset_t *, size_t);
+
+void kcpuset_zero(kcpuset_t *);
+void kcpuset_fill(kcpuset_t *);
+void kcpuset_set(kcpuset_t *, cpuid_t);
+void kcpuset_clear(kcpuset_t *, cpuid_t);
+
+bool kcpuset_isset(kcpuset_t *, cpuid_t);
+bool kcpuset_isotherset(kcpuset_t *, cpuid_t);
+bool kcpuset_iszero(kcpuset_t *);
+bool kcpuset_match(const kcpuset_t *, const kcpuset_t *);
+void kcpuset_merge(kcpuset_t *, kcpuset_t *);
+void kcpuset_intersect(kcpuset_t *, kcpuset_t *);
+int kcpuset_countset(kcpuset_t *);
+
+void kcpuset_atomic_set(kcpuset_t *, cpuid_t);
+void kcpuset_atomic_clear(kcpuset_t *, cpuid_t);
+
+void kcpuset_export_u32(const kcpuset_t *, uint32_t *, size_t);
+
+#endif
+
+#endif /* _SYS_KCPUSET_H_ */
--- /dev/null
+/* $NetBSD: kern_ctf.h,v 1.1 2010/03/12 21:43:10 darran Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CTF_H_
+#define _SYS_CTF_H_
+
+/*
+ * Modules CTF section
+ */
+typedef struct mod_ctf {
+ const uint8_t *ctftab; /* Decompressed CTF data. */
+ int ctfcnt; /* Number of CTF data bytes. */
+ const Elf_Sym *symtab; /* Ptr to the symbol table. */
+ int nsym; /* Number of symbols. */
+ uint32_t *nmap; /* symbol id map */
+ int nmapsize; /* Span of id map */
+ const char *strtab; /* Ptr to the string table. */
+ int strcnt; /* Number of string bytes. */
+ uint32_t *ctfoffp; /* Ptr to array of obj/fnc offsets. */
+ uint32_t *typoffp; /* Ptr to array of type offsets. */
+ long typlen; /* number of type data entries. */
+ int ctfalloc; /* ctftab is alloced */
+} mod_ctf_t;
+
+int
+mod_ctf_get(struct module *, mod_ctf_t *);
+
+#endif
--- /dev/null
+/* $NetBSD: kernel.h,v 1.28 2009/01/11 02:45:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kernel.h 8.3 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_KERNEL_H_
+#define _SYS_KERNEL_H_
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+/* Global variables for the kernel. */
+
+extern long hostid;
+extern char hostname[MAXHOSTNAMELEN];
+extern int hostnamelen;
+extern char domainname[MAXHOSTNAMELEN];
+extern int domainnamelen;
+
+extern struct timespec boottime;
+
+extern int rtc_offset; /* offset of rtc from UTC in minutes */
+
+extern int cold; /* still working on startup */
+extern int tick; /* usec per tick (1000000 / hz) */
+extern int tickadj; /* "standard" clock skew, us./tick */
+extern int hardclock_ticks; /* # of hardclock ticks */
+extern int hz; /* system clock's frequency */
+extern int stathz; /* statistics clock's frequency */
+extern int profhz; /* profiling clock's frequency */
+
+extern int profsrc; /* profiling source */
+
+#define PROFSRC_CLOCK 0
+
+#endif
+
+#endif /* _SYS_KERNEL_H_ */
--- /dev/null
+/* $NetBSD: kernhist.h,v 1.5 2012/07/30 23:56:48 matt Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: NetBSD: uvm_stat.h,v 1.49 2011/04/23 18:14:13 rmind Exp
+ * from: Id: uvm_stat.h,v 1.1.2.4 1998/02/07 01:16:56 chs Exp
+ */
+
+#ifndef _SYS_KERNHIST_H_
+#define _SYS_KERNHIST_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_kernhist.h"
+#endif
+
+#include <sys/queue.h>
+#ifdef KERNHIST
+#include <sys/cpu.h>
+#endif
+
+/*
+ * kernel history/tracing, was uvm_stat
+ */
+
+struct kern_history_ent {
+ struct timeval tv; /* time stamp */
+ int cpunum;
+ const char *fmt; /* printf format */
+ size_t fmtlen; /* length of printf format */
+ const char *fn; /* function name */
+ size_t fnlen; /* length of function name */
+ u_long call; /* function call number */
+ u_long v[4]; /* values */
+};
+
+struct kern_history {
+ const char *name; /* name of this history */
+ size_t namelen; /* length of name, not including null */
+ LIST_ENTRY(kern_history) list; /* link on list of all histories */
+ unsigned int n; /* number of entries */
+ unsigned int f; /* next free one */
+ struct kern_history_ent *e; /* the allocated entries */
+};
+
+LIST_HEAD(kern_history_head, kern_history);
+
+/*
+ * grovelling lists all at once. we currently do not allow more than
+ * 32 histories to exist, as the way to dump a number of them at once
+ * is by calling kern_hist() with a bitmask.
+ *
+ * XXX extend this to have a registration function? however, there
+ * needs to be static ones as UVM requires this before almost anything
+ * else is setup.
+ */
+
+/* this is used to set the size of some arrays */
+#define MAXHISTS 32
+
+/* and these are the bit values of each history */
+#define KERNHIST_UVMMAPHIST 0x00000001 /* maphist */
+#define KERNHIST_UVMPDHIST 0x00000002 /* pdhist */
+#define KERNHIST_UVMUBCHIST 0x00000004 /* ubchist */
+#define KERNHIST_UVMLOANHIST 0x00000008 /* loanhist */
+
+#ifdef _KERNEL
+
+/*
+ * macros to use the history/tracing code. note that KERNHIST_LOG
+ * must take 4 arguments (even if they are ignored by the format).
+ */
+#ifndef KERNHIST
+#define KERNHIST_DECL(NAME)
+#define KERNHIST_DEFINE(NAME)
+#define KERNHIST_INIT(NAME,N)
+#define KERNHIST_INIT_STATIC(NAME,BUF)
+#define KERNHIST_LOG(NAME,FMT,A,B,C,D)
+#define KERNHIST_CALLED(NAME)
+#define KERNHIST_FUNC(FNAME)
+#define kernhist_dump(NAME)
+#else
+#include <sys/kernel.h> /* for "cold" variable */
+#include <sys/atomic.h>
+#include <sys/kmem.h>
+
+extern struct kern_history_head kern_histories;
+
+#define KERNHIST_DECL(NAME) extern struct kern_history NAME
+#define KERNHIST_DEFINE(NAME) struct kern_history NAME
+
+#define KERNHIST_INIT(NAME,N) \
+do { \
+ (NAME).name = __STRING(NAME); \
+ (NAME).namelen = strlen(__STRING(NAME)); \
+ (NAME).n = (N); \
+ (NAME).f = 0; \
+ (NAME).e = (struct kern_history_ent *) \
+ kmem_zalloc(sizeof(struct kern_history_ent) * (N), KM_SLEEP); \
+ LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \
+} while (/*CONSTCOND*/ 0)
+
+#define KERNHIST_INIT_STATIC(NAME,BUF) \
+do { \
+ (NAME).name = __STRING(NAME); \
+ (NAME).namelen = strlen(__STRING(NAME)); \
+ (NAME).n = sizeof(BUF) / sizeof(struct kern_history_ent); \
+ (NAME).f = 0; \
+ (NAME).e = (struct kern_history_ent *) (BUF); \
+ memset((NAME).e, 0, sizeof(struct kern_history_ent) * (NAME).n); \
+ LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \
+} while (/*CONSTCOND*/ 0)
+
+#if defined(KERNHIST_PRINT)
+extern int kernhist_print_enabled;
+#define KERNHIST_PRINTNOW(E) \
+do { \
+ if (kernhist_print_enabled) { \
+ kernhist_entry_print(E); \
+ DELAY(100000); \
+ } \
+} while (/*CONSTCOND*/ 0)
+#else
+#define KERNHIST_PRINTNOW(E) /* nothing */
+#endif
+
+#define KERNHIST_LOG(NAME,FMT,A,B,C,D) \
+do { \
+ unsigned int _i_, _j_; \
+ do { \
+ _i_ = (NAME).f; \
+ _j_ = (_i_ + 1 < (NAME).n) ? _i_ + 1 : 0; \
+ } while (atomic_cas_uint(&(NAME).f, _i_, _j_) != _i_); \
+ struct kern_history_ent * const _e_ = &(NAME).e[_i_]; \
+ if (__predict_true(!cold)) \
+ microtime(&_e_->tv); \
+ _e_->cpunum = cpu_number(); \
+ _e_->fmt = (FMT); \
+ _e_->fmtlen = strlen(FMT); \
+ _e_->fn = _kernhist_name; \
+ _e_->fnlen = strlen(_kernhist_name); \
+ _e_->call = _kernhist_call; \
+ _e_->v[0] = (u_long)(A); \
+ _e_->v[1] = (u_long)(B); \
+ _e_->v[2] = (u_long)(C); \
+ _e_->v[3] = (u_long)(D); \
+ KERNHIST_PRINTNOW(_e_); \
+} while (/*CONSTCOND*/ 0)
+
+#define KERNHIST_CALLED(NAME) \
+do { \
+ _kernhist_call = atomic_inc_uint_nv(&_kernhist_cnt); \
+ KERNHIST_LOG(NAME, "called!", 0, 0, 0, 0); \
+} while (/*CONSTCOND*/ 0)
+
+#define KERNHIST_FUNC(FNAME) \
+ static unsigned int _kernhist_cnt = 0; \
+ static const char *const _kernhist_name = FNAME; \
+ int _kernhist_call = 0;
+
+static inline void kernhist_entry_print(const struct kern_history_ent *);
+
+static inline void
+kernhist_entry_print(const struct kern_history_ent *e)
+{
+ printf("%06" PRIu64 ".%06d ", e->tv.tv_sec, e->tv.tv_usec);
+ printf("%s#%ld@%d: ", e->fn, e->call, e->cpunum);
+ printf(e->fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
+ printf("\n");
+}
+
+#if defined(DDB)
+void kernhist_print(void (*)(const char *, ...) __printflike(1, 2));
+#endif /* DDB */
+
+#endif /* KERNHIST */
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_KERNHIST_H_ */
--- /dev/null
+/* $NetBSD: kgdb.h,v 1.12 2011/04/03 22:29:28 dyoung Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratories.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)remote-sl.h 8.1 (Berkeley) 6/11/93
+ */
+
+#ifndef _SYS_KGDB_H_
+#define _SYS_KGDB_H_
+
+/*
+ * Protocol definition for KGDB
+ * (gdb over remote serial line)
+ */
+
+#include <machine/db_machdep.h>
+
+/*
+ * Message types.
+ */
+#define KGDB_MEM_R 'm'
+#define KGDB_MEM_W 'M'
+#define KGDB_REG_R 'g'
+#define KGDB_REG_W 'G'
+#define KGDB_CONT 'c'
+#define KGDB_STEP 's'
+#define KGDB_KILL 'k'
+#define KGDB_DETACH 'D'
+#define KGDB_SIGNAL '?'
+#define KGDB_DEBUG 'd'
+
+/*
+ * start of frame/end of frame
+ */
+#define KGDB_START '$'
+#define KGDB_END '#'
+#define KGDB_GOODP '+'
+#define KGDB_BADP '-'
+
+#ifdef _KERNEL
+
+#include <ddb/db_run.h>
+#include <ddb/db_access.h>
+
+/*
+ * Functions and variables exported from kgdb_stub.c
+ */
+extern dev_t kgdb_dev;
+extern int kgdb_rate, kgdb_active;
+extern int kgdb_debug_init, kgdb_debug_panic;
+extern label_t *kgdb_recover;
+
+void kgdb_attach(int (*)(void *), void (*)(void *, int), void *);
+void kgdb_connect(int);
+void kgdb_panic(void);
+int kgdb_trap(int, db_regs_t *);
+int kgdb_disconnected(void);
+
+/*
+ * Machine dependent functions needed by kgdb_stub.c
+ */
+int kgdb_signal(int);
+int kgdb_acc(vaddr_t, size_t);
+void kgdb_entry_notice(int, db_regs_t *);
+void kgdb_getregs(db_regs_t *, kgdb_reg_t *);
+void kgdb_setregs(db_regs_t *, kgdb_reg_t *);
+
+#endif /* _KERNEL */
+#endif /* !_SYS_KGDB_H_ */
--- /dev/null
+/* $NetBSD: kmem.h,v 1.9 2012/02/05 03:40:08 rmind Exp $ */
+
+/*-
+ * Copyright (c)2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KMEM_H_
+#define _SYS_KMEM_H_
+
+#include <sys/types.h>
+
+typedef unsigned int km_flag_t;
+
+void kmem_init(void);
+size_t kmem_roundup_size(size_t);
+
+void * kmem_alloc(size_t, km_flag_t);
+void * kmem_zalloc(size_t, km_flag_t);
+void kmem_free(void *, size_t);
+
+void * kmem_intr_alloc(size_t, km_flag_t);
+void * kmem_intr_zalloc(size_t, km_flag_t);
+void kmem_intr_free(void *, size_t);
+
+char * kmem_asprintf(const char *, ...) __printflike(1, 2);
+
+/*
+ * km_flag_t values:
+ */
+#define KM_SLEEP 0x00000001 /* can sleep */
+#define KM_NOSLEEP 0x00000002 /* don't sleep */
+
+#endif /* !_SYS_KMEM_H_ */
--- /dev/null
+/* $NetBSD: kobj.h,v 1.16 2011/08/13 21:04:07 christos Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KOBJ_H_
+#define _SYS_KOBJ_H_
+
+#define ELFSIZE ARCH_ELFSIZE
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+
+typedef struct kobj *kobj_t;
+
+/* External interface. */
+int kobj_load_vfs(kobj_t *, const char *, const bool);
+int kobj_load_mem(kobj_t *, const char *, void *, ssize_t);
+int kobj_affix(kobj_t, const char *);
+void kobj_unload(kobj_t);
+int kobj_stat(kobj_t, vaddr_t *, size_t *);
+int kobj_find_section(kobj_t, const char *, void **, size_t *);
+
+/* MI-MD interface. */
+uintptr_t kobj_sym_lookup(kobj_t, uintptr_t);
+int kobj_reloc(kobj_t, uintptr_t, const void *, bool, bool);
+int kobj_machdep(kobj_t, void *, size_t, bool);
+
+/* implementation interface. */
+int kobj_renamespace(Elf_Sym *, size_t, char **, size_t *);
+
+#endif /* !_SYS_KOBJ_H_ */
--- /dev/null
+/* $NetBSD: kobj_impl.h,v 1.3 2011/08/13 21:04:07 christos Exp $ */
+
+/*-
+ * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1998-2000 Doug Rabson
+ * Copyright (c) 2004 Peter Wemm
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Data structures private to kobj, shared only with kernel grovellers.
+ */
+
+#ifndef _SYS_KOBJ_IMPL_H_
+#define _SYS_KOBJ_IMPL_H_
+
+#define ELFSIZE ARCH_ELFSIZE
+
+#include <sys/systm.h>
+#include <sys/kobj.h>
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+#include <sys/module.h>
+
+typedef struct {
+ void *addr;
+ Elf_Off size;
+ int flags;
+ int sec; /* Original section */
+ const char *name;
+} progent_t;
+
+typedef struct {
+ Elf_Rel *rel;
+ int nrel;
+ int sec;
+ size_t size;
+} relent_t;
+
+typedef struct {
+ Elf_Rela *rela;
+ int nrela;
+ int sec;
+ size_t size;
+} relaent_t;
+
+typedef enum kobjtype {
+ KT_UNSET,
+ KT_VNODE,
+ KT_MEMORY
+} kobjtype_t;
+
+typedef int (*kobj_read_fn)(kobj_t, void **, size_t, off_t, bool);
+typedef void (*kobj_close_fn)(kobj_t);
+
+struct kobj {
+ char ko_name[MAXMODNAME];
+ kobjtype_t ko_type;
+ void *ko_source;
+ ssize_t ko_memsize;
+ vaddr_t ko_address; /* Relocation address */
+ Elf_Shdr *ko_shdr;
+ progent_t *ko_progtab;
+ relaent_t *ko_relatab;
+ relent_t *ko_reltab;
+ Elf_Sym *ko_symtab; /* Symbol table */
+ char *ko_strtab; /* String table */
+ char *ko_shstrtab; /* Section name string table */
+ size_t ko_size; /* Size of text/data/bss */
+ size_t ko_symcnt; /* Number of symbols */
+ size_t ko_strtabsz; /* Number of bytes in string table */
+ size_t ko_shstrtabsz; /* Number of bytes in scn str table */
+ size_t ko_shdrsz;
+ int ko_nrel;
+ int ko_nrela;
+ int ko_nprogtab;
+ bool ko_ksyms;
+ bool ko_loaded;
+ kobj_read_fn ko_read;
+ kobj_close_fn ko_close;
+};
+
+#ifdef _KERNEL
+int kobj_load(kobj_t);
+void kobj_setname(kobj_t, const char *);
+#endif
+
+#endif /* _SYS_KOBJ_IMPL_H_ */
--- /dev/null
+/* $NetBSD: kprintf.h,v 1.11 2011/07/17 20:54:54 joerg Exp $ */
+
+/*-
+ * Copyright (c) 1986, 1988, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KPRINTF_H_
+#define _SYS_KPRINTF_H_
+
+#include <sys/stdarg.h>
+
+/*
+ * Implementation internals of the kernel printf. Exposing them here
+ * allows other subsystems to implement precisely the printf semantics
+ * they need.
+ */
+
+/* max size buffer kprintf needs to print quad_t [size in base 8 + \0] */
+#define KPRINTF_BUFSIZE (sizeof(quad_t) * NBBY / 3 + 2)
+
+/* flags for kprintf */
+#define TOCONS 0x0001 /* to the console */
+#define TOTTY 0x0002 /* to the process' tty */
+#define TOLOG 0x0004 /* to the kernel message buffer */
+#define TOBUFONLY 0x0008 /* to the buffer (only) [for snprintf] */
+#define TODDB 0x0010 /* to ddb console */
+#define NOLOCK 0x1000 /* don't acquire a tty lock */
+
+void kprintf_init(void);
+void kprintf_lock(void);
+void kprintf_unlock(void);
+/*
+ * NOTE: the kprintf mutex must be held when these functions are called!
+ */
+int kprintf(const char *, int, void *, char *, va_list);
+void klogpri(int);
+
+#endif /* _SYS_KPRINTF_H_ */
--- /dev/null
+/* $NetBSD: ksem.h,v 1.13 2012/03/10 21:52:00 joerg Exp $ */
+
+/*
+ * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KSEM_H_
+#define _SYS_KSEM_H_
+
+#include <sys/cdefs.h>
+
+struct timespec;
+
+#ifdef _KERNEL
+#define KSEM_MAX 128
+
+int do_ksem_init(struct lwp *, unsigned int, intptr_t *, copyout_t);
+int do_ksem_open(struct lwp *, const char *, int, mode_t, unsigned int,
+ intptr_t *, copyout_t);
+int do_ksem_wait(struct lwp *, intptr_t, bool, struct timespec *);
+
+extern int ksem_max;
+#endif
+
+#ifdef _LIBC
+__BEGIN_DECLS
+int _ksem_close(intptr_t);
+int _ksem_destroy(intptr_t);
+int _ksem_getvalue(intptr_t, int *);
+int _ksem_init(unsigned int, intptr_t *);
+int _ksem_open(const char *, int, mode_t, unsigned int, intptr_t *);
+int _ksem_post(intptr_t);
+int _ksem_timedwait(intptr_t, const struct timespec * __restrict);
+int _ksem_trywait(intptr_t);
+int _ksem_unlink(const char *);
+int _ksem_wait(intptr_t);
+__END_DECLS
+#endif /* _LIBC */
+
+#endif /* _SYS_KSEM_H_ */
--- /dev/null
+/* $NetBSD: ksyms.h,v 1.27 2010/03/15 02:28:59 darran Exp $ */
+
+/*
+ * Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KSYMS_H_
+#define _SYS_KSYMS_H_
+
+#ifdef _KSYMS_PRIVATE
+
+#if defined(_KERNEL_OPT)
+#include "opt_dtrace.h"
+#endif
+
+#define ELFSIZE ARCH_ELFSIZE
+#include <sys/exec_elf.h>
+#include <sys/queue.h>
+
+struct ksyms_symtab {
+ TAILQ_ENTRY(ksyms_symtab) sd_queue; /* All active tables */
+ const char *sd_name; /* Name of this table */
+ Elf_Sym *sd_symstart; /* Address of symbol table */
+ uintptr_t sd_minsym; /* symbol with minimum value */
+ uintptr_t sd_maxsym; /* symbol with maximum value */
+ char *sd_strstart; /* Address of corresponding string table */
+ int sd_usroffset; /* Real address for userspace */
+ int sd_symsize; /* Size in bytes of symbol table */
+ int sd_strsize; /* Size of string table */
+ int sd_nglob; /* Number of global symbols */
+ bool sd_gone; /* dead but around for open() */
+#ifdef KDTRACE_HOOKS
+ void *sd_ctfstart; /* Address of CTF contents */
+ int sd_ctfsize; /* Size in bytes of CTF contents */
+ uint32_t *sd_nmap; /* Name map for sorted symbols */
+ int sd_nmapsize; /* Total span of map */
+#endif
+};
+
+/*
+ * Static allocated ELF header.
+ * Basic info is filled in at attach, sizes at open.
+ */
+#define SYMTAB 1
+#define STRTAB 2
+#define SHSTRTAB 3
+#define SHBSS 4
+#ifdef KDTRACE_HOOKS
+#define SHCTF 5
+#define NSECHDR 6
+#else
+#define NSECHDR 5
+#endif
+
+#define NPRGHDR 1
+#define SHSTRSIZ 42
+
+struct ksyms_hdr {
+ Elf_Ehdr kh_ehdr;
+ Elf_Phdr kh_phdr[NPRGHDR];
+ Elf_Shdr kh_shdr[NSECHDR];
+ char kh_strtab[SHSTRSIZ];
+};
+#endif /* _KSYMS_PRIVATE */
+
+/*
+ * Do a lookup of a symbol using the in-kernel lookup algorithm.
+ */
+struct ksyms_gsymbol {
+ const char *kg_name;
+ union {
+ void *ku_sym; /* Normally Elf_Sym */
+ unsigned long *ku_value;
+ } _un;
+#define kg_sym _un.ku_sym
+#define kg_value _un.ku_value
+};
+
+#define KIOCGSYMBOL _IOW('l', 1, struct ksyms_gsymbol)
+#define KIOCGVALUE _IOW('l', 2, struct ksyms_gsymbol)
+#define KIOCGSIZE _IOR('l', 3, int)
+
+
+#if defined(_KERNEL) || defined(_KMEMUSER)
+/*
+ * Definitions used in ksyms_getname() and ksyms_getval().
+ */
+#define KSYMS_CLOSEST 0001 /* Nearest lower match */
+#define KSYMS_EXACT 0002 /* Only exact match allowed */
+#define KSYMS_EXTERN 0000 /* Only external symbols (pseudo) */
+#define KSYMS_PROC 0100 /* Procedures only */
+#define KSYMS_ANY 0200 /* Also local symbols (DDB use only) */
+
+typedef int (*ksyms_callback_t)(const char *, int, void *,
+ uint32_t, int, void *);
+
+/*
+ * Prototypes
+ */
+
+int ksyms_getname(const char **, const char **, vaddr_t, int);
+int ksyms_getval(const char *, const char *, unsigned long *, int);
+int ksyms_getval_unlocked(const char *, const char *, unsigned long *, int);
+struct ksyms_symtab *ksyms_get_mod(const char *);
+int ksyms_mod_foreach(const char *mod, ksyms_callback_t, void *);
+int ksyms_addsymtab(const char *, void *, vsize_t, char *, vsize_t);
+int ksyms_delsymtab(const char *);
+void ksyms_init(void);
+void ksyms_addsyms_elf(int, void *, void *);
+void ksyms_addsyms_explicit(void *, void *, size_t, void *, size_t);
+int ksyms_sift(char *, char *, int);
+void ksyms_modload(const char *, void *, vsize_t, char *, vsize_t);
+void ksyms_modunload(const char *);
+
+#endif /* _KERNEL */
+#endif /* _SYS_KSYMS_H_ */
--- /dev/null
+/* $NetBSD: kthread.h,v 1.12 2011/11/21 04:36:05 christos Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_KTHREAD_H_
+#define _SYS_KTHREAD_H_
+
+#if !defined(_KERNEL)
+#error "not supposed to be exposed to userland"
+#endif
+
+/*
+ * Kernel thread handling.
+ */
+
+#include <sys/proc.h>
+
+#define KTHREAD_IDLE 0x01 /* Do not run on creation */
+#define KTHREAD_MPSAFE 0x02 /* Do not acquire kernel_lock */
+#define KTHREAD_INTR 0x04 /* Software interrupt handler */
+#define KTHREAD_TS 0x08 /* Time-sharing priority range */
+#define KTHREAD_MUSTJOIN 0x10 /* Must join on exit */
+
+void kthread_sysinit(void);
+
+int kthread_create(pri_t, int, struct cpu_info *,
+ void (*)(void *), void *, lwp_t **, const char *, ...) __printflike(7, 8);
+void kthread_exit(int) __dead;
+void kthread_destroy(lwp_t *);
+int kthread_join(lwp_t *);
+
+#endif /* _SYS_KTHREAD_H_ */
--- /dev/null
+/* $NetBSD: ktrace.h,v 1.59 2012/02/19 21:06:58 rmind Exp $ */
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ktrace.h 8.2 (Berkeley) 2/19/95
+ */
+
+#ifndef _SYS_KTRACE_H_
+#define _SYS_KTRACE_H_
+
+#include <sys/mutex.h>
+
+/*
+ * operations to ktrace system call (KTROP(op))
+ */
+#define KTROP_SET 0 /* set trace points */
+#define KTROP_CLEAR 1 /* clear trace points */
+#define KTROP_CLEARFILE 2 /* stop all tracing to file */
+#define KTROP_MASK 0x3
+#define KTROP(o) ((o)&KTROP_MASK) /* macro to extract operation */
+/*
+ * flags (ORed in with operation)
+ */
+#define KTRFLAG_DESCEND 4 /* perform op on all children too */
+
+/*
+ * ktrace record header
+ */
+struct ktr_header {
+ int ktr_len; /* length of record minus length of old header */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ short ktr_type; /* trace record type */
+ short ktr_version; /* trace record version */
+#else
+ short ktr_version; /* trace record version */
+ short ktr_type; /* trace record type */
+#endif
+ pid_t ktr_pid; /* process id */
+ char ktr_comm[MAXCOMLEN+1]; /* command name */
+ union {
+ struct { /* v0 */
+ struct {
+ int32_t tv_sec;
+ long tv_usec;
+ } _tv;
+ const void *_buf;
+ } _v0;
+ struct { /* v1 */
+ struct {
+ int32_t tv_sec;
+ long tv_nsec;
+ } _ts;
+ lwpid_t _lid;
+ } _v1;
+ struct { /* v2 */
+ struct timespec _ts;
+ lwpid_t _lid;
+ } _v2;
+ } _v;
+};
+
+#define ktr_lid _v._v2._lid
+#define ktr_olid _v._v1._lid
+#define ktr_time _v._v2._ts
+#define ktr_otv _v._v0._tv
+#define ktr_ots _v._v1._ts
+#define ktr_ts _v._v2._ts
+#define ktr_unused _v._v0._buf
+
+#define KTR_SHIMLEN offsetof(struct ktr_header, ktr_pid)
+
+/*
+ * Test for kernel trace point
+ */
+#define KTRPOINT(p, type) \
+ (((p)->p_traceflag & (1<<(type))) != 0)
+
+/*
+ * ktrace record types
+ */
+
+/*
+ * KTR_SYSCALL - system call record
+ */
+#define KTR_SYSCALL 1
+struct ktr_syscall {
+ int ktr_code; /* syscall number */
+ int ktr_argsize; /* size of arguments */
+ /*
+ * followed by ktr_argsize/sizeof(register_t) "register_t"s
+ */
+};
+
+/*
+ * KTR_SYSRET - return from system call record
+ */
+#define KTR_SYSRET 2
+struct ktr_sysret {
+ short ktr_code;
+ short ktr_eosys; /* XXX unused */
+ int ktr_error;
+ register_t ktr_retval;
+ register_t ktr_retval_1;
+};
+
+/*
+ * KTR_NAMEI - namei record
+ */
+#define KTR_NAMEI 3
+ /* record contains pathname */
+
+/*
+ * KTR_GENIO - trace generic process i/o
+ */
+#define KTR_GENIO 4
+struct ktr_genio {
+ int ktr_fd;
+ enum uio_rw ktr_rw;
+ /*
+ * followed by data successfully read/written
+ */
+};
+
+/*
+ * KTR_PSIG - trace processed signal
+ */
+#define KTR_PSIG 5
+struct ktr_psig {
+ int signo;
+ sig_t action;
+ sigset_t mask;
+ int code;
+ /*
+ * followed by optional siginfo_t
+ */
+};
+
+/*
+ * KTR_CSW - trace context switches
+ */
+#define KTR_CSW 6
+struct ktr_csw {
+ int out; /* 1 if switch out, 0 if switch in */
+ int user; /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */
+};
+
+/*
+ * KTR_EMUL - emulation change
+ */
+#define KTR_EMUL 7
+ /* record contains emulation name */
+
+/*
+ * KTR_USER - user record
+ */
+#define KTR_USER 8
+#define KTR_USER_MAXIDLEN 20
+#define KTR_USER_MAXLEN 2048 /* maximum length of passed data */
+struct ktr_user {
+ char ktr_id[KTR_USER_MAXIDLEN]; /* string id of caller */
+ /*
+ * Followed by ktr_len - sizeof(struct ktr_user) of user data.
+ */
+};
+
+/*
+ * KTR_EXEC_ARG, KTR_EXEC_ENV - Arguments and environment from exec
+ */
+#define KTR_EXEC_ARG 10
+#define KTR_EXEC_ENV 11
+ /* record contains arg/env string */
+
+/*
+ * KTR_SAUPCALL - scheduler activated upcall.
+ *
+ * The structure is no longer used, but retained for compatibility.
+ */
+#define KTR_SAUPCALL 13
+struct ktr_saupcall {
+ int ktr_type;
+ int ktr_nevent;
+ int ktr_nint;
+ void *ktr_sas;
+ void *ktr_ap;
+ /*
+ * followed by nevent sa_t's from sas[]
+ */
+};
+
+/*
+ * KTR_MIB - MIB name and data
+ */
+#define KTR_MIB 14
+ /* Record contains MIB name */
+
+/*
+ * KTR_EXEC_FD - Opened file descriptor from exec
+ */
+#define KTR_EXEC_FD 15
+struct ktr_execfd {
+ int ktr_fd;
+ u_int ktr_dtype; /* one of DTYPE_* constants */
+};
+
+/*
+ * kernel trace points (in p_traceflag)
+ */
+#define KTRFAC_MASK 0x00ffffff
+#define KTRFAC_SYSCALL (1<<KTR_SYSCALL)
+#define KTRFAC_SYSRET (1<<KTR_SYSRET)
+#define KTRFAC_NAMEI (1<<KTR_NAMEI)
+#define KTRFAC_GENIO (1<<KTR_GENIO)
+#define KTRFAC_PSIG (1<<KTR_PSIG)
+#define KTRFAC_CSW (1<<KTR_CSW)
+#define KTRFAC_EMUL (1<<KTR_EMUL)
+#define KTRFAC_USER (1<<KTR_USER)
+#define KTRFAC_EXEC_ARG (1<<KTR_EXEC_ARG)
+#define KTRFAC_EXEC_ENV (1<<KTR_EXEC_ENV)
+#define KTRFAC_MIB (1<<KTR_MIB)
+#define KTRFAC_EXEC_FD (1<<KTR_EXEC_FD)
+/*
+ * trace flags (also in p_traceflags)
+ */
+#define KTRFAC_PERSISTENT 0x80000000 /* persistent trace across sugid
+ exec (exclusive) */
+#define KTRFAC_INHERIT 0x40000000 /* pass trace flags to children */
+#define KTRFAC_TRC_EMUL 0x10000000 /* ktrace KTR_EMUL before next trace */
+#define KTRFAC_VER_MASK 0x0f000000 /* record version mask */
+#define KTRFAC_VER_SHIFT 24 /* record version shift */
+
+#define KTRFAC_VERSION(tf) (((tf) & KTRFAC_VER_MASK) >> KTRFAC_VER_SHIFT)
+
+#define KTRFACv0 (0 << KTRFAC_VER_SHIFT)
+#define KTRFACv1 (1 << KTRFAC_VER_SHIFT)
+#define KTRFACv2 (2 << KTRFAC_VER_SHIFT)
+
+#ifndef _KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int ktrace(const char *, int, int, pid_t);
+int fktrace(int, int, int, pid_t);
+int utrace(const char *, void *, size_t);
+__END_DECLS
+
+#else
+
+void ktrinit(void);
+void ktrderef(struct proc *);
+void ktradref(struct proc *);
+
+extern kmutex_t ktrace_lock;
+extern int ktrace_on;
+
+int ktruser(const char *, void *, size_t, int);
+bool ktr_point(int);
+
+void ktr_csw(int, int);
+void ktr_emul(void);
+void ktr_geniov(int, enum uio_rw, struct iovec *, size_t, int);
+void ktr_genio(int, enum uio_rw, const void *, size_t, int);
+void ktr_mibio(int, enum uio_rw, const void *, size_t, int);
+void ktr_namei(const char *, size_t);
+void ktr_namei2(const char *, size_t, const char *, size_t);
+void ktr_psig(int, sig_t, const sigset_t *, const ksiginfo_t *);
+void ktr_syscall(register_t, const register_t [], int);
+void ktr_sysret(register_t, int, register_t *);
+void ktr_kuser(const char *, void *, size_t);
+void ktr_mib(const int *a , u_int b);
+void ktr_execarg(const void *, size_t);
+void ktr_execenv(const void *, size_t);
+void ktr_execfd(int, u_int);
+
+static inline bool
+ktrpoint(int fac)
+{
+ return __predict_false(ktrace_on) && __predict_false(ktr_point(1 << fac));
+}
+
+static inline void
+ktrcsw(int a, int b)
+{
+ if (__predict_false(ktrace_on))
+ ktr_csw(a, b);
+}
+
+static inline void
+ktremul(void)
+{
+ if (__predict_false(ktrace_on))
+ ktr_emul();
+}
+
+static inline void
+ktrgenio(int a, enum uio_rw b, const void *c, size_t d, int e)
+{
+ if (__predict_false(ktrace_on))
+ ktr_genio(a, b, c, d, e);
+}
+
+static inline void
+ktrgeniov(int a, enum uio_rw b, struct iovec *c, int d, int e)
+{
+ if (__predict_false(ktrace_on))
+ ktr_geniov(a, b, c, d, e);
+}
+
+static inline void
+ktrmibio(int a, enum uio_rw b, const void *c, size_t d, int e)
+{
+ if (__predict_false(ktrace_on))
+ ktr_mibio(a, b, c, d, e);
+}
+
+static inline void
+ktrnamei(const char *a, size_t b)
+{
+ if (__predict_false(ktrace_on))
+ ktr_namei(a, b);
+}
+
+static inline void
+ktrnamei2(const char *a, size_t b, const char *c, size_t d)
+{
+ if (__predict_false(ktrace_on))
+ ktr_namei2(a, b, c, d);
+}
+
+static inline void
+ktrpsig(int a, sig_t b, const sigset_t *c, const ksiginfo_t * d)
+{
+ if (__predict_false(ktrace_on))
+ ktr_psig(a, b, c, d);
+}
+
+static inline void
+ktrsyscall(register_t code, const register_t args[], int narg)
+{
+ if (__predict_false(ktrace_on))
+ ktr_syscall(code, args, narg);
+}
+
+static inline void
+ktrsysret(register_t a, int b, register_t *c)
+{
+ if (__predict_false(ktrace_on))
+ ktr_sysret(a, b, c);
+}
+
+static inline void
+ktrkuser(const char *a, void *b, size_t c)
+{
+ if (__predict_false(ktrace_on))
+ ktr_kuser(a, b, c);
+}
+
+static inline void
+ktrmib(const int *a , u_int b)
+{
+ if (__predict_false(ktrace_on))
+ ktr_mib(a, b);
+}
+
+static inline void
+ktrexecarg(const void *a, size_t b)
+{
+ if (__predict_false(ktrace_on))
+ ktr_execarg(a, b);
+}
+
+static inline void
+ktrexecenv(const void *a, size_t b)
+{
+ if (__predict_false(ktrace_on))
+ ktr_execenv(a, b);
+}
+
+static inline void
+ktrexecfd(int fd, u_int dtype)
+{
+ if (__predict_false(ktrace_on))
+ ktr_execfd(fd, dtype);
+}
+
+#endif /* !_KERNEL */
+
+#endif /* _SYS_KTRACE_H_ */
--- /dev/null
+/* $NetBSD: lockdebug.h,v 1.13 2011/11/21 04:36:05 christos Exp $ */
+
+/*-
+ * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SYS_LOCKDEBUG_H__
+#define __SYS_LOCKDEBUG_H__
+
+#ifdef _KERNEL_OPT
+#include "opt_lockdebug.h"
+#endif
+
+#if !defined(_KERNEL) && !defined(_KMEMUSER)
+#error "Sorry, nothing of interest to user level programs here."
+#endif
+
+#define LOCKOPS_SLEEP 0
+#define LOCKOPS_SPIN 1
+#define LOCKOPS_CV 2
+
+typedef struct lockops {
+ const char *lo_name;
+ int lo_type;
+ void (*lo_dump)(volatile void *);
+} lockops_t;
+
+#define LOCKDEBUG_ABORT(l, o, f, m) lockdebug_abort(l, o, f, m)
+
+void lockdebug_abort(volatile void *, lockops_t *,
+ const char *, const char *);
+
+void lockdebug_lock_print(void *, void (*)(const char *, ...)
+ __printflike(1, 2));
+
+#ifdef LOCKDEBUG
+
+bool lockdebug_alloc(volatile void *, lockops_t *, uintptr_t);
+void lockdebug_free(volatile void *);
+void lockdebug_wantlock(volatile void *, uintptr_t, bool, bool);
+void lockdebug_locked(volatile void *, void *, uintptr_t, int);
+void lockdebug_unlocked(volatile void *, uintptr_t, int);
+void lockdebug_barrier(volatile void *, int);
+void lockdebug_mem_check(const char *, void *, size_t);
+void lockdebug_wakeup(volatile void *, uintptr_t);
+
+#define LOCKDEBUG_ALLOC(lock, ops, addr) lockdebug_alloc(lock, ops, addr)
+#define LOCKDEBUG_FREE(dodebug, lock) \
+ if (dodebug) lockdebug_free(lock)
+#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) \
+ if (dodebug) lockdebug_wantlock(lock, where, s, t)
+#define LOCKDEBUG_LOCKED(dodebug, lock, al, where, s) \
+ if (dodebug) lockdebug_locked(lock, al, where, s)
+#define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) \
+ if (dodebug) lockdebug_unlocked(lock, where, s)
+#define LOCKDEBUG_BARRIER(lock, slp) lockdebug_barrier(lock, slp)
+#define LOCKDEBUG_MEM_CHECK(base, sz) \
+ lockdebug_mem_check(__func__, base, sz)
+#define LOCKDEBUG_WAKEUP(dodebug, lock, where) \
+ if (dodebug) lockdebug_wakeup(lock, where)
+
+#else /* LOCKDEBUG */
+
+#define LOCKDEBUG_ALLOC(lock, ops, addr) false
+#define LOCKDEBUG_FREE(dodebug, lock) /* nothing */
+#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) /* nothing */
+#define LOCKDEBUG_LOCKED(dodebug, lock, al, where, s) /* nothing */
+#define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) /* nothing */
+#define LOCKDEBUG_BARRIER(lock, slp) /* nothing */
+#define LOCKDEBUG_MEM_CHECK(base, sz) /* nothing */
+#define LOCKDEBUG_WAKEUP(dodebug, lock, where) /* nothing */
+
+#endif /* LOCKDEBUG */
+
+#endif /* __SYS_LOCKDEBUG_H__ */
--- /dev/null
+/* $NetBSD: lockf.h,v 1.20 2008/11/19 13:34:11 pooka Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Scooter Morris at Genentech Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)lockf.h 8.2 (Berkeley) 10/26/94
+ */
+
+#ifndef _SYS_LOCKF_H_
+#define _SYS_LOCKF_H_
+
+#ifdef _KERNEL
+
+#include <sys/vnode.h>
+
+struct lockf;
+
+int lf_advlock(struct vop_advlock_args *, struct lockf **, off_t);
+void lf_init(void);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_LOCKF_H_ */
--- /dev/null
+/* $NetBSD: lwpctl.h,v 1.4 2008/04/28 20:24:10 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_LWPCTL_H_)
+#define _SYS_LWPCTL_H_
+
+/*
+ * Note on compatibility:
+ *
+ * This must be the same size for both 32 and 64-bit processes, since
+ * the same format will be used by both.
+ *
+ * Removal of unused fields is OK, as long as the change in layout
+ * does not affect supported fields.
+ *
+ * It is OK to add fields to this structure, since the kernel allocates
+ * the space. Re-use of fields is more complicated - see the feature
+ * word passed to the system call.
+ */
+typedef struct lwpctl {
+ volatile int lc_curcpu;
+ volatile int lc_pctr;
+} lwpctl_t;
+
+#define LWPCTL_CPU_NONE (-1)
+#define LWPCTL_CPU_EXITED (-2)
+
+#define LWPCTL_FEATURE_CURCPU 0x00000001
+#define LWPCTL_FEATURE_PCTR 0x00000002
+
+#if defined(_KERNEL)
+
+#include <sys/mutex.h>
+
+#include <uvm/uvm_extern.h>
+
+typedef struct lcpage {
+ TAILQ_ENTRY(lcpage) lcp_chain;
+ vaddr_t lcp_uaddr;
+ vaddr_t lcp_kaddr;
+ u_int lcp_nfree;
+ u_int lcp_rotor;
+ u_int lcp_bitmap[1];
+} lcpage_t;
+
+typedef struct lcproc {
+ kmutex_t lp_lock;
+ struct uvm_object *lp_uao;
+ TAILQ_HEAD(,lcpage) lp_pages;
+ vaddr_t lp_cur;
+ vaddr_t lp_max;
+ vaddr_t lp_uva;
+} lcproc_t;
+
+#define LWPCTL_PER_PAGE ((PAGE_SIZE / sizeof(lwpctl_t)) & ~31)
+#define LWPCTL_BITMAP_ENTRIES (LWPCTL_PER_PAGE >> 5)
+#define LWPCTL_BITMAP_SZ (LWPCTL_BITMAP_ENTRIES * sizeof(u_int))
+#define LWPCTL_LCPAGE_SZ \
+ (sizeof(lcpage_t) - sizeof(u_int) + LWPCTL_BITMAP_SZ)
+#define LWPCTL_UAREA_SZ \
+ (round_page(MAX_LWP_PER_PROC * sizeof(lwpctl_t)))
+
+int lwp_ctl_alloc(vaddr_t *);
+void lwp_ctl_free(lwp_t *);
+void lwp_ctl_exit(void);
+
+#endif /* defined(_KERNEL) */
+
+#endif /* !_SYS_LWPCTL_H_ */
--- /dev/null
+/* $NetBSD: malloc.h,v 1.114 2012/04/30 22:51:27 rmind Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)malloc.h 8.5 (Berkeley) 5/3/95
+ */
+
+#ifndef _SYS_MALLOC_H_
+#define _SYS_MALLOC_H_
+
+#ifdef _KERNEL
+
+/*
+ * flags to malloc
+ */
+#define M_WAITOK 0x0000 /* can wait for resources */
+#define M_NOWAIT 0x0001 /* do not wait for resources */
+#define M_ZERO 0x0002 /* zero the allocation */
+#define M_CANFAIL 0x0004 /* can fail if requested memory can't ever
+ * be allocated */
+#include <sys/mallocvar.h>
+#if 0
+/*
+ * The following are standard, built-in malloc types that are
+ * not specific to any one subsystem.
+ *
+ * They are currently not defined, but are still passed to malloc()
+ * and free(). They may be re-instated as diagnostics at some point.
+ */
+MALLOC_DECLARE(M_DEVBUF);
+MALLOC_DECLARE(M_DMAMAP);
+MALLOC_DECLARE(M_FREE);
+MALLOC_DECLARE(M_PCB);
+MALLOC_DECLARE(M_TEMP);
+MALLOC_DECLARE(M_RTABLE);
+MALLOC_DECLARE(M_FTABLE);
+MALLOC_DECLARE(M_UFSMNT);
+MALLOC_DECLARE(M_NETADDR);
+MALLOC_DECLARE(M_MRTABLE);
+#endif
+
+void *kern_malloc(unsigned long, int);
+void *kern_realloc(void *, unsigned long, int);
+void kern_free(void *);
+
+#define malloc(size, type, flags) kern_malloc(size, flags)
+#define free(addr, type) kern_free(addr)
+#define realloc(ptr, size, type, flags) kern_realloc(ptr, size, flags)
+
+#endif /* _KERNEL */
+
+/*
+ * Set of buckets for each size of memory block that is retained
+ */
+struct kmembuckets {
+ void *kb_next; /* list of free blocks */
+ void *kb_last; /* last free block */
+ long kb_calls; /* total calls to allocate this size */
+ long kb_total; /* total number of blocks allocated */
+ long kb_totalfree; /* # of free elements in this bucket */
+ long kb_elmpercl; /* # of elements in this sized allocation */
+ long kb_highwat; /* high water mark */
+ long kb_couldfree; /* over high water mark and could free */
+};
+
+#endif /* !_SYS_MALLOC_H_ */
--- /dev/null
+/* $NetBSD: mallocvar.h,v 1.12 2012/04/29 20:27:32 dsl Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)malloc.h 8.5 (Berkeley) 5/3/95
+ */
+
+#ifndef _SYS_MALLOCVAR_H_
+#define _SYS_MALLOCVAR_H_
+
+#include <sys/types.h>
+
+/*
+ * This structure describes a type of malloc'd memory and carries
+ * allocation statistics for that memory.
+ */
+struct malloc_type;
+
+#ifdef _KERNEL
+#define MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit)
+
+#define MALLOC_JUSTDEFINE(type, shortdesc, longdesc) \
+ MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, 0)
+
+#define MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, limit) \
+ MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit)
+
+#define MALLOC_DEFINE(type, shortdesc, longdesc) \
+ MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, 0)
+
+#define MALLOC_DECLARE(type) \
+ static struct malloc_type *const __unused type = 0
+
+#define malloc_type_attach(malloc_type)
+#define malloc_type_detach(malloc_type)
+#endif /* _KERNEL */
+
+#endif /* _SYS_MALLOCVAR_H_ */
--- /dev/null
+/* $NetBSD: mbuf.h,v 1.149 2012/04/29 16:36:54 dsl Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center and Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
+ */
+
+#ifndef _SYS_MBUF_H_
+#define _SYS_MBUF_H_
+
+#ifdef _KERNEL_OPT
+#include "opt_mbuftrace.h"
+#endif
+
+#ifndef M_WAITOK
+#include <sys/malloc.h>
+#endif
+#include <sys/pool.h>
+#include <sys/queue.h>
+#if defined(_KERNEL)
+#include <sys/percpu_types.h>
+#endif /* defined(_KERNEL) */
+
+/* For offsetof() */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/systm.h>
+#else
+#include <stddef.h>
+#endif
+
+#include <uvm/uvm_param.h> /* for MIN_PAGE_SIZE */
+
+/*
+ * Mbufs are of a single size, MSIZE (machine/param.h), which
+ * includes overhead. An mbuf may add a single "mbuf cluster" of size
+ * MCLBYTES (also in machine/param.h), which has no additional overhead
+ * and is used instead of the internal data area; this is done when
+ * at least MINCLSIZE of data must be stored.
+ */
+
+/* Packet tags structure */
+struct m_tag {
+ SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */
+ uint16_t m_tag_id; /* Tag ID */
+ uint16_t m_tag_len; /* Length of data */
+};
+
+/* mbuf ownership structure */
+struct mowner {
+ char mo_name[16]; /* owner name (fxp0) */
+ char mo_descr[16]; /* owner description (input) */
+ LIST_ENTRY(mowner) mo_link; /* */
+ struct percpu *mo_counters;
+};
+
+#define MOWNER_INIT(x, y) { .mo_name = x, .mo_descr = y }
+
+enum mowner_counter_index {
+ MOWNER_COUNTER_CLAIMS, /* # of small mbuf claimed */
+ MOWNER_COUNTER_RELEASES, /* # of small mbuf released */
+ MOWNER_COUNTER_CLUSTER_CLAIMS, /* # of M_CLUSTER mbuf claimed */
+ MOWNER_COUNTER_CLUSTER_RELEASES,/* # of M_CLUSTER mbuf released */
+ MOWNER_COUNTER_EXT_CLAIMS, /* # of M_EXT mbuf claimed */
+ MOWNER_COUNTER_EXT_RELEASES, /* # of M_EXT mbuf released */
+
+ MOWNER_COUNTER_NCOUNTERS,
+};
+
+#if defined(_KERNEL)
+struct mowner_counter {
+ u_long mc_counter[MOWNER_COUNTER_NCOUNTERS];
+};
+#endif /* defined(_KERNEL) */
+
+/* userland-exported version of struct mowner */
+struct mowner_user {
+ char mo_name[16]; /* owner name (fxp0) */
+ char mo_descr[16]; /* owner description (input) */
+ LIST_ENTRY(mowner) mo_link; /* unused padding; for compatibility */
+ u_long mo_counter[MOWNER_COUNTER_NCOUNTERS]; /* counters */
+};
+
+/*
+ * Macros for type conversion
+ * mtod(m,t) - convert mbuf pointer to data pointer of correct type
+ */
+#define mtod(m, t) ((t)((m)->m_data))
+
+/* header at beginning of each mbuf: */
+struct m_hdr {
+ struct mbuf *mh_next; /* next buffer in chain */
+ struct mbuf *mh_nextpkt; /* next chain in queue/record */
+ char *mh_data; /* location of data */
+ struct mowner *mh_owner; /* mbuf owner */
+ int mh_len; /* amount of data in this mbuf */
+ int mh_flags; /* flags; see below */
+ paddr_t mh_paddr; /* physical address of mbuf */
+ short mh_type; /* type of data in this mbuf */
+};
+
+/*
+ * record/packet header in first mbuf of chain; valid if M_PKTHDR set
+ *
+ * A note about csum_data: For the out-bound direction, the low 16 bits
+ * indicates the offset after the L4 header where the final L4 checksum value
+ * is to be stored and the high 16 bits is the length of the L3 header (the
+ * start of the data to be checksumed). For the in-bound direction, it is only
+ * valid if the M_CSUM_DATA flag is set. In this case, an L4 checksum has been
+ * calculated by hardware, but it is up to software to perform final
+ * verification.
+ *
+ * Note for in-bound TCP/UDP checksums, we expect the csum_data to NOT
+ * be bit-wise inverted (the final step in the calculation of an IP
+ * checksum) -- this is so we can accumulate the checksum for fragmented
+ * packets during reassembly.
+ */
+struct pkthdr {
+ struct ifnet *rcvif; /* rcv interface */
+ SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
+ int len; /* total packet length */
+ int csum_flags; /* checksum flags */
+ uint32_t csum_data; /* checksum data */
+ u_int segsz; /* segment size */
+};
+
+/*
+ * Note: These bits are carefully arrange so that the compiler can have
+ * a prayer of generating a jump table.
+ */
+#define M_CSUM_TCPv4 0x00000001 /* TCP header/payload */
+#define M_CSUM_UDPv4 0x00000002 /* UDP header/payload */
+#define M_CSUM_TCP_UDP_BAD 0x00000004 /* TCP/UDP checksum bad */
+#define M_CSUM_DATA 0x00000008 /* consult csum_data */
+#define M_CSUM_TCPv6 0x00000010 /* IPv6 TCP header/payload */
+#define M_CSUM_UDPv6 0x00000020 /* IPv6 UDP header/payload */
+#define M_CSUM_IPv4 0x00000040 /* IPv4 header */
+#define M_CSUM_IPv4_BAD 0x00000080 /* IPv4 header checksum bad */
+#define M_CSUM_TSOv4 0x00000100 /* TCPv4 segmentation offload */
+#define M_CSUM_TSOv6 0x00000200 /* TCPv6 segmentation offload */
+
+/* Checksum-assist quirks: keep separate from jump-table bits. */
+#define M_CSUM_NO_PSEUDOHDR 0x80000000 /* Rx csum_data does not include
+ * the UDP/TCP pseudo-hdr, and
+ * is not yet 1s-complemented.
+ */
+
+#define M_CSUM_BITS \
+ "\20\1TCPv4\2UDPv4\3TCP_UDP_BAD\4DATA\5TCPv6\6UDPv6\7IPv4\10IPv4_BAD" \
+ "\11TSOv4\12TSOv6\40NO_PSEUDOHDR"
+
+/*
+ * Macros for manipulating csum_data on outgoing packets. These are
+ * used to pass information down from the L4/L3 to the L2.
+ */
+#define M_CSUM_DATA_IPv4_IPHL(x) ((x) >> 16)
+#define M_CSUM_DATA_IPv4_OFFSET(x) ((x) & 0xffff)
+
+/*
+ * Macros for M_CSUM_TCPv6 and M_CSUM_UDPv6
+ *
+ * M_CSUM_DATA_IPv6_HL: length of ip6_hdr + ext header.
+ * ie. offset of UDP/TCP header in the packet.
+ *
+ * M_CSUM_DATA_IPv6_OFFSET: offset of the checksum field in UDP/TCP header.
+ */
+
+#define M_CSUM_DATA_IPv6_HL(x) ((x) >> 16)
+#define M_CSUM_DATA_IPv6_HL_SET(x, v) (x) = ((x) & 0xffff) | ((v) << 16)
+#define M_CSUM_DATA_IPv6_OFFSET(x) ((x) & 0xffff)
+
+/*
+ * Max # of pages we can attach to m_ext. This is carefully chosen
+ * to be able to handle SOSEND_LOAN_CHUNK with our minimum sized page.
+ */
+#ifdef MIN_PAGE_SIZE
+#define M_EXT_MAXPAGES ((65536 / MIN_PAGE_SIZE) + 1)
+#endif
+
+/* description of external storage mapped into mbuf, valid if M_EXT set */
+struct _m_ext_storage {
+ unsigned int ext_refcnt;
+ int ext_flags;
+ char *ext_buf; /* start of buffer */
+ void (*ext_free) /* free routine if not the usual */
+ (struct mbuf *, void *, size_t, void *);
+ void *ext_arg; /* argument for ext_free */
+ size_t ext_size; /* size of buffer, for ext_free */
+ union {
+ paddr_t extun_paddr; /* physical address (M_EXT_CLUSTER) */
+ /* pages (M_EXT_PAGES) */
+ /*
+ * XXX This is gross, but it doesn't really matter; this is
+ * XXX overlaid on top of the mbuf data area.
+ */
+#ifdef M_EXT_MAXPAGES
+ struct vm_page *extun_pgs[M_EXT_MAXPAGES];
+#endif
+ } ext_un;
+#define ext_paddr ext_un.extun_paddr
+#define ext_pgs ext_un.extun_pgs
+#ifdef DEBUG
+ const char *ext_ofile;
+ const char *ext_nfile;
+ int ext_oline;
+ int ext_nline;
+#endif
+};
+
+struct _m_ext {
+ struct mbuf *ext_ref;
+ struct _m_ext_storage ext_storage;
+};
+
+#define M_PADDR_INVALID POOL_PADDR_INVALID
+
+/*
+ * Definition of "struct mbuf".
+ * Don't change this without understanding how MHLEN/MLEN are defined.
+ */
+#define MBUF_DEFINE(name, mhlen, mlen) \
+ struct name { \
+ struct m_hdr m_hdr; \
+ union { \
+ struct { \
+ struct pkthdr MH_pkthdr; \
+ union { \
+ struct _m_ext MH_ext; \
+ char MH_databuf[(mhlen)]; \
+ } MH_dat; \
+ } MH; \
+ char M_databuf[(mlen)]; \
+ } M_dat; \
+ }
+#define m_next m_hdr.mh_next
+#define m_len m_hdr.mh_len
+#define m_data m_hdr.mh_data
+#define m_owner m_hdr.mh_owner
+#define m_type m_hdr.mh_type
+#define m_flags m_hdr.mh_flags
+#define m_nextpkt m_hdr.mh_nextpkt
+#define m_paddr m_hdr.mh_paddr
+#define m_pkthdr M_dat.MH.MH_pkthdr
+#define m_ext_storage M_dat.MH.MH_dat.MH_ext.ext_storage
+#define m_ext_ref M_dat.MH.MH_dat.MH_ext.ext_ref
+#define m_ext m_ext_ref->m_ext_storage
+#define m_pktdat M_dat.MH.MH_dat.MH_databuf
+#define m_dat M_dat.M_databuf
+
+/*
+ * Dummy mbuf structure to calculate the right values for MLEN/MHLEN, taking
+ * into account inter-structure padding.
+ */
+MBUF_DEFINE(_mbuf_dummy, 1, 1);
+
+/* normal data len */
+#define MLEN (MSIZE - offsetof(struct _mbuf_dummy, m_dat))
+/* data len w/pkthdr */
+#define MHLEN (MSIZE - offsetof(struct _mbuf_dummy, m_pktdat))
+
+#define MINCLSIZE (MHLEN+MLEN+1) /* smallest amount to put in cluster */
+#define M_MAXCOMPRESS (MHLEN / 2) /* max amount to copy for compression */
+
+/*
+ * The *real* struct mbuf
+ */
+MBUF_DEFINE(mbuf, MHLEN, MLEN);
+
+/* mbuf flags */
+#define M_EXT 0x00001 /* has associated external storage */
+#define M_PKTHDR 0x00002 /* start of record */
+#define M_EOR 0x00004 /* end of record */
+#define M_PROTO1 0x00008 /* protocol-specific */
+
+/* mbuf pkthdr flags, also in m_flags */
+#define M_AUTHIPHDR 0x00010 /* data origin authentication for IP header */
+#define M_DECRYPTED 0x00020 /* confidentiality */
+#define M_LOOP 0x00040 /* for Mbuf statistics */
+#define M_AUTHIPDGM 0x00080 /* data origin authentication */
+#define M_BCAST 0x00100 /* send/received as link-level broadcast */
+#define M_MCAST 0x00200 /* send/received as link-level multicast */
+#define M_CANFASTFWD 0x00400 /* used by filters to indicate packet can
+ be fast-forwarded */
+#define M_ANYCAST6 0x00800 /* received as IPv6 anycast */
+#define M_LINK0 0x01000 /* link layer specific flag */
+#define M_LINK1 0x02000 /* link layer specific flag */
+#define M_LINK2 0x04000 /* link layer specific flag */
+#define M_LINK3 0x08000 /* link layer specific flag */
+#define M_LINK4 0x10000 /* link layer specific flag */
+#define M_LINK5 0x20000 /* link layer specific flag */
+#define M_LINK6 0x40000 /* link layer specific flag */
+#define M_LINK7 0x80000 /* link layer specific flag */
+
+/* additional flags for M_EXT mbufs */
+#define M_EXT_FLAGS 0xff000000
+#define M_EXT_CLUSTER 0x01000000 /* ext is a cluster */
+#define M_EXT_PAGES 0x02000000 /* ext_pgs is valid */
+#define M_EXT_ROMAP 0x04000000 /* ext mapping is r-o at MMU */
+#define M_EXT_RW 0x08000000 /* ext storage is writable */
+
+/* for source-level compatibility */
+#define M_CLUSTER M_EXT_CLUSTER
+
+#define M_FLAGS_BITS \
+ "\20\1EXT\2PKTHDR\3EOR\4PROTO1\5AUTHIPHDR\6DECRYPTED\7LOOP\10AUTHIPDGM" \
+ "\11BCAST\12MCAST\13CANFASTFWD\14ANYCAST6\15LINK0\16LINK1\17LINK2\20LINK3" \
+ "\21LINK4\22LINK5\23LINK6\24LINK7" \
+ "\31EXT_CLUSTER\32EXT_PAGES\33EXT_ROMAP\34EXT_RW"
+
+/* flags copied when copying m_pkthdr */
+#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST|M_CANFASTFWD|M_ANYCAST6|M_LINK0|M_LINK1|M_LINK2|M_AUTHIPHDR|M_DECRYPTED|M_LOOP|M_AUTHIPDGM)
+
+/* flag copied when shallow-copying external storage */
+#define M_EXTCOPYFLAGS (M_EXT|M_EXT_FLAGS)
+
+/* mbuf types */
+#define MT_FREE 0 /* should be on free list */
+#define MT_DATA 1 /* dynamic (data) allocation */
+#define MT_HEADER 2 /* packet header */
+#define MT_SONAME 3 /* socket name */
+#define MT_SOOPTS 4 /* socket options */
+#define MT_FTABLE 5 /* fragment reassembly header */
+#define MT_CONTROL 6 /* extra-data protocol message */
+#define MT_OOBDATA 7 /* expedited data */
+
+#ifdef MBUFTYPES
+static const char *mbuftypes[] = {
+ "mbfree",
+ "mbdata",
+ "mbheader",
+ "mbsoname",
+ "mbsopts",
+ "mbftable",
+ "mbcontrol",
+ "mboobdata",
+};
+#endif
+
+/* flags to m_get/MGET */
+#define M_DONTWAIT M_NOWAIT
+#define M_WAIT M_WAITOK
+
+#ifdef MBUFTRACE
+/*
+ * mbuf allocation tracing
+ */
+void mowner_init(struct mbuf *, int);
+void mowner_ref(struct mbuf *, int);
+void m_claim(struct mbuf *, struct mowner *);
+void mowner_revoke(struct mbuf *, bool, int);
+void mowner_attach(struct mowner *);
+void mowner_detach(struct mowner *);
+void m_claimm(struct mbuf *, struct mowner *);
+#else
+#define mowner_init(m, type) do { } while (/* CONSTCOND */ 0)
+#define mowner_ref(m, flags) do { } while (/* CONSTCOND */ 0)
+#define mowner_revoke(m, all, flags) do { } while (/* CONSTCOND */ 0)
+#define m_claim(m, mowner) do { } while (/* CONSTCOND */ 0)
+#define mowner_attach(mo) do { } while (/* CONSTCOND */ 0)
+#define mowner_detach(mo) do { } while (/* CONSTCOND */ 0)
+#define m_claimm(m, mo) do { } while (/* CONSTCOND */ 0)
+#endif
+
+#define MCLAIM(m, mo) m_claim((m), (mo))
+#define MOWNER_ATTACH(mo) mowner_attach(mo)
+#define MOWNER_DETACH(mo) mowner_detach(mo)
+
+/*
+ * mbuf allocation/deallocation macros:
+ *
+ * MGET(struct mbuf *m, int how, int type)
+ * allocates an mbuf and initializes it to contain internal data.
+ *
+ * MGETHDR(struct mbuf *m, int how, int type)
+ * allocates an mbuf and initializes it to contain a packet header
+ * and internal data.
+ *
+ * If 'how' is M_WAIT, these macros (and the corresponding functions)
+ * are guaranteed to return successfully.
+ */
+#define MGET(m, how, type) m = m_get((how), (type))
+#define MGETHDR(m, how, type) m = m_gethdr((how), (type))
+
+#if defined(_KERNEL)
+#define _M_
+/*
+ * Macros for tracking external storage associated with an mbuf.
+ */
+#ifdef DEBUG
+#define MCLREFDEBUGN(m, file, line) \
+do { \
+ (m)->m_ext.ext_nfile = (file); \
+ (m)->m_ext.ext_nline = (line); \
+} while (/* CONSTCOND */ 0)
+
+#define MCLREFDEBUGO(m, file, line) \
+do { \
+ (m)->m_ext.ext_ofile = (file); \
+ (m)->m_ext.ext_oline = (line); \
+} while (/* CONSTCOND */ 0)
+#else
+#define MCLREFDEBUGN(m, file, line)
+#define MCLREFDEBUGO(m, file, line)
+#endif
+
+#define MCLINITREFERENCE(m) \
+do { \
+ KDASSERT(((m)->m_flags & M_EXT) == 0); \
+ (m)->m_ext_ref = (m); \
+ (m)->m_ext.ext_refcnt = 1; \
+ MCLREFDEBUGO((m), __FILE__, __LINE__); \
+ MCLREFDEBUGN((m), NULL, 0); \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * Macros for mbuf external storage.
+ *
+ * MCLGET allocates and adds an mbuf cluster to a normal mbuf;
+ * the flag M_EXT is set upon success.
+ *
+ * MEXTMALLOC allocates external storage and adds it to
+ * a normal mbuf; the flag M_EXT is set upon success.
+ *
+ * MEXTADD adds pre-allocated external storage to
+ * a normal mbuf; the flag M_EXT is set upon success.
+ */
+
+#define _MCLGET(m, pool_cache, size, how) \
+do { \
+ (m)->m_ext_storage.ext_buf = \
+ pool_cache_get_paddr((pool_cache), \
+ (how) == M_WAIT ? (PR_WAITOK|PR_LIMITFAIL) : 0, \
+ &(m)->m_ext_storage.ext_paddr); \
+ if ((m)->m_ext_storage.ext_buf != NULL) { \
+ MCLINITREFERENCE(m); \
+ (m)->m_data = (m)->m_ext.ext_buf; \
+ (m)->m_flags = ((m)->m_flags & ~M_EXTCOPYFLAGS) | \
+ M_EXT|M_CLUSTER|M_EXT_RW; \
+ (m)->m_ext.ext_flags = 0; \
+ (m)->m_ext.ext_size = (size); \
+ (m)->m_ext.ext_free = NULL; \
+ (m)->m_ext.ext_arg = (pool_cache); \
+ /* ext_paddr initialized above */ \
+ mowner_ref((m), M_EXT|M_CLUSTER); \
+ } \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * The standard mbuf cluster pool.
+ */
+#define MCLGET(m, how) _MCLGET((m), mcl_cache, MCLBYTES, (how))
+
+#define MEXTMALLOC(m, size, how) \
+do { \
+ (m)->m_ext_storage.ext_buf = \
+ (void *)malloc((size), mbtypes[(m)->m_type], (how)); \
+ if ((m)->m_ext_storage.ext_buf != NULL) { \
+ MCLINITREFERENCE(m); \
+ (m)->m_data = (m)->m_ext.ext_buf; \
+ (m)->m_flags = ((m)->m_flags & ~M_EXTCOPYFLAGS) | \
+ M_EXT|M_EXT_RW; \
+ (m)->m_ext.ext_flags = 0; \
+ (m)->m_ext.ext_size = (size); \
+ (m)->m_ext.ext_free = NULL; \
+ (m)->m_ext.ext_arg = NULL; \
+ mowner_ref((m), M_EXT); \
+ } \
+} while (/* CONSTCOND */ 0)
+
+#define MEXTADD(m, buf, size, type, free, arg) \
+do { \
+ MCLINITREFERENCE(m); \
+ (m)->m_data = (m)->m_ext.ext_buf = (void *)(buf); \
+ (m)->m_flags = ((m)->m_flags & ~M_EXTCOPYFLAGS) | M_EXT; \
+ (m)->m_ext.ext_flags = 0; \
+ (m)->m_ext.ext_size = (size); \
+ (m)->m_ext.ext_free = (free); \
+ (m)->m_ext.ext_arg = (arg); \
+ mowner_ref((m), M_EXT); \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * Reset the data pointer on an mbuf.
+ */
+#define MRESETDATA(m) \
+do { \
+ if ((m)->m_flags & M_EXT) \
+ (m)->m_data = (m)->m_ext.ext_buf; \
+ else if ((m)->m_flags & M_PKTHDR) \
+ (m)->m_data = (m)->m_pktdat; \
+ else \
+ (m)->m_data = (m)->m_dat; \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * MFREE(struct mbuf *m, struct mbuf *n)
+ * Free a single mbuf and associated external storage.
+ * Place the successor, if any, in n.
+ */
+#define MFREE(m, n) \
+ mowner_revoke((m), 1, (m)->m_flags); \
+ mbstat_type_add((m)->m_type, -1); \
+ if ((m)->m_flags & M_PKTHDR) \
+ m_tag_delete_chain((m), NULL); \
+ (n) = (m)->m_next; \
+ if ((m)->m_flags & M_EXT) { \
+ m_ext_free(m); \
+ } else { \
+ KASSERT(m->m_type != MT_FREE); \
+ m->m_type = MT_FREE; \
+ pool_cache_put(mb_cache, (m)); \
+ } \
+
+/*
+ * Copy mbuf pkthdr from `from' to `to'.
+ * `from' must have M_PKTHDR set, and `to' must be empty.
+ */
+#define M_COPY_PKTHDR(to, from) \
+do { \
+ (to)->m_pkthdr = (from)->m_pkthdr; \
+ (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
+ SLIST_INIT(&(to)->m_pkthdr.tags); \
+ m_tag_copy_chain((to), (from)); \
+ (to)->m_data = (to)->m_pktdat; \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * Move mbuf pkthdr from `from' to `to'.
+ * `from' must have M_PKTHDR set, and `to' must be empty.
+ */
+#define M_MOVE_PKTHDR(to, from) m_move_pkthdr(to, from)
+
+/*
+ * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
+ * an object of the specified size at the end of the mbuf, longword aligned.
+ */
+#define M_ALIGN(m, len) \
+do { \
+ (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * As above, for mbufs allocated with m_gethdr/MGETHDR
+ * or initialized by M_COPY_PKTHDR.
+ */
+#define MH_ALIGN(m, len) \
+do { \
+ (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); \
+} while (/* CONSTCOND */ 0)
+
+/*
+ * Determine if an mbuf's data area is read-only. This is true
+ * if external storage is read-only mapped, or not marked as R/W,
+ * or referenced by more than one mbuf.
+ */
+#define M_READONLY(m) \
+ (((m)->m_flags & M_EXT) != 0 && \
+ (((m)->m_flags & (M_EXT_ROMAP|M_EXT_RW)) != M_EXT_RW || \
+ (m)->m_ext.ext_refcnt > 1))
+
+#define M_UNWRITABLE(__m, __len) \
+ ((__m)->m_len < (__len) || M_READONLY((__m)))
+/*
+ * Determine if an mbuf's data area is read-only at the MMU.
+ */
+#define M_ROMAP(m) \
+ (((m)->m_flags & (M_EXT|M_EXT_ROMAP)) == (M_EXT|M_EXT_ROMAP))
+
+/*
+ * Compute the amount of space available
+ * before the current start of data in an mbuf.
+ */
+#define _M_LEADINGSPACE(m) \
+ ((m)->m_flags & M_EXT ? (m)->m_data - (m)->m_ext.ext_buf : \
+ (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
+ (m)->m_data - (m)->m_dat)
+
+#define M_LEADINGSPACE(m) \
+ (M_READONLY((m)) ? 0 : _M_LEADINGSPACE((m)))
+
+/*
+ * Compute the amount of space available
+ * after the end of data in an mbuf.
+ */
+#define _M_TRAILINGSPACE(m) \
+ ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
+ ((m)->m_data + (m)->m_len) : \
+ &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
+
+#define M_TRAILINGSPACE(m) \
+ (M_READONLY((m)) ? 0 : _M_TRAILINGSPACE((m)))
+
+/*
+ * Compute the address of an mbuf's data area.
+ */
+#define M_BUFADDR(m) \
+ (((m)->m_flags & M_PKTHDR) ? (m)->m_pktdat : (m)->m_dat)
+
+/*
+ * Compute the offset of the beginning of the data buffer of a non-ext
+ * mbuf.
+ */
+#define M_BUFOFFSET(m) \
+ (((m)->m_flags & M_PKTHDR) ? \
+ offsetof(struct mbuf, m_pktdat) : offsetof(struct mbuf, m_dat))
+
+/*
+ * Arrange to prepend space of size plen to mbuf m.
+ * If a new mbuf must be allocated, how specifies whether to wait.
+ * If how is M_DONTWAIT and allocation fails, the original mbuf chain
+ * is freed and m is set to NULL.
+ */
+#define M_PREPEND(m, plen, how) \
+do { \
+ if (M_LEADINGSPACE(m) >= (plen)) { \
+ (m)->m_data -= (plen); \
+ (m)->m_len += (plen); \
+ } else \
+ (m) = m_prepend((m), (plen), (how)); \
+ if ((m) && (m)->m_flags & M_PKTHDR) \
+ (m)->m_pkthdr.len += (plen); \
+} while (/* CONSTCOND */ 0)
+
+/* change mbuf to new type */
+#define MCHTYPE(m, t) \
+do { \
+ KASSERT((t) != MT_FREE); \
+ mbstat_type_add((m)->m_type, -1); \
+ mbstat_type_add(t, 1); \
+ (m)->m_type = t; \
+} while (/* CONSTCOND */ 0)
+
+/* length to m_copy to copy all */
+#define M_COPYALL 1000000000
+
+/* compatibility with 4.3 */
+#define m_copy(m, o, l) m_copym((m), (o), (l), M_DONTWAIT)
+
+/*
+ * Allow drivers and/or protocols to use the rcvif member of
+ * PKTHDR mbufs to store private context information.
+ */
+#define M_GETCTX(m, t) ((t)(m)->m_pkthdr.rcvif)
+#define M_SETCTX(m, c) ((void)((m)->m_pkthdr.rcvif = (void *)(c)))
+
+#endif /* defined(_KERNEL) */
+
+/*
+ * Simple mbuf queueing system
+ *
+ * this is basically a SIMPLEQ adapted to mbuf use (ie using
+ * m_nextpkt instead of field.sqe_next).
+ *
+ * m_next is ignored, so queueing chains of mbufs is possible
+ */
+#define MBUFQ_HEAD(name) \
+struct name { \
+ struct mbuf *mq_first; \
+ struct mbuf **mq_last; \
+}
+
+#define MBUFQ_INIT(q) do { \
+ (q)->mq_first = NULL; \
+ (q)->mq_last = &(q)->mq_first; \
+} while (/*CONSTCOND*/0)
+
+#define MBUFQ_ENQUEUE(q, m) do { \
+ (m)->m_nextpkt = NULL; \
+ *(q)->mq_last = (m); \
+ (q)->mq_last = &(m)->m_nextpkt; \
+} while (/*CONSTCOND*/0)
+
+#define MBUFQ_PREPEND(q, m) do { \
+ if (((m)->m_nextpkt = (q)->mq_first) == NULL) \
+ (q)->mq_last = &(m)->m_nextpkt; \
+ (q)->mq_first = (m); \
+} while (/*CONSTCOND*/0)
+
+#define MBUFQ_DEQUEUE(q, m) do { \
+ if (((m) = (q)->mq_first) != NULL) { \
+ if (((q)->mq_first = (m)->m_nextpkt) == NULL) \
+ (q)->mq_last = &(q)->mq_first; \
+ else \
+ (m)->m_nextpkt = NULL; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define MBUFQ_DRAIN(q) do { \
+ struct mbuf *__m0; \
+ while ((__m0 = (q)->mq_first) != NULL) { \
+ (q)->mq_first = __m0->m_nextpkt; \
+ m_freem(__m0); \
+ } \
+ (q)->mq_last = &(q)->mq_first; \
+} while (/*CONSTCOND*/0)
+
+#define MBUFQ_FIRST(q) ((q)->mq_first)
+#define MBUFQ_NEXT(m) ((m)->m_nextpkt)
+#define MBUFQ_LAST(q) (*(q)->mq_last)
+
+/*
+ * Mbuf statistics.
+ * For statistics related to mbuf and cluster allocations, see also the
+ * pool headers (mb_cache and mcl_cache).
+ */
+struct mbstat {
+ u_long _m_spare; /* formerly m_mbufs */
+ u_long _m_spare1; /* formerly m_clusters */
+ u_long _m_spare2; /* spare field */
+ u_long _m_spare3; /* formely m_clfree - free clusters */
+ u_long m_drops; /* times failed to find space */
+ u_long m_wait; /* times waited for space */
+ u_long m_drain; /* times drained protocols for space */
+ u_short m_mtypes[256]; /* type specific mbuf allocations */
+};
+
+struct mbstat_cpu {
+ u_int m_mtypes[256]; /* type specific mbuf allocations */
+};
+
+/*
+ * Mbuf sysctl variables.
+ */
+#define MBUF_MSIZE 1 /* int: mbuf base size */
+#define MBUF_MCLBYTES 2 /* int: mbuf cluster size */
+#define MBUF_NMBCLUSTERS 3 /* int: limit on the # of clusters */
+#define MBUF_MBLOWAT 4 /* int: mbuf low water mark */
+#define MBUF_MCLLOWAT 5 /* int: mbuf cluster low water mark */
+#define MBUF_STATS 6 /* struct: mbstat */
+#define MBUF_MOWNERS 7 /* struct: m_owner[] */
+#define MBUF_MAXID 8 /* number of valid MBUF ids */
+
+#define CTL_MBUF_NAMES { \
+ { 0, 0 }, \
+ { "msize", CTLTYPE_INT }, \
+ { "mclbytes", CTLTYPE_INT }, \
+ { "nmbclusters", CTLTYPE_INT }, \
+ { "mblowat", CTLTYPE_INT }, \
+ { "mcllowat", CTLTYPE_INT }, \
+ { 0 /* "stats" */, CTLTYPE_STRUCT }, \
+ { 0 /* "mowners" */, CTLTYPE_STRUCT }, \
+}
+
+#ifdef _KERNEL
+extern struct mbstat mbstat;
+extern int nmbclusters; /* limit on the # of clusters */
+extern int mblowat; /* mbuf low water mark */
+extern int mcllowat; /* mbuf cluster low water mark */
+extern int max_linkhdr; /* largest link-level header */
+extern int max_protohdr; /* largest protocol header */
+extern int max_hdr; /* largest link+protocol header */
+extern int max_datalen; /* MHLEN - max_hdr */
+extern const int msize; /* mbuf base size */
+extern const int mclbytes; /* mbuf cluster size */
+extern pool_cache_t mb_cache;
+extern pool_cache_t mcl_cache;
+#ifdef MBUFTRACE
+LIST_HEAD(mownerhead, mowner);
+extern struct mownerhead mowners;
+extern struct mowner unknown_mowners[];
+extern struct mowner revoked_mowner;
+#endif
+
+MALLOC_DECLARE(M_MBUF);
+MALLOC_DECLARE(M_SONAME);
+MALLOC_DECLARE(M_SOOPTS);
+
+struct mbuf *m_copym(struct mbuf *, int, int, int);
+struct mbuf *m_copypacket(struct mbuf *, int);
+struct mbuf *m_devget(char *, int, int, struct ifnet *,
+ void (*copy)(const void *, void *, size_t));
+struct mbuf *m_dup(struct mbuf *, int, int, int);
+struct mbuf *m_free(struct mbuf *);
+struct mbuf *m_get(int, int);
+struct mbuf *m_getclr(int, int);
+struct mbuf *m_gethdr(int, int);
+struct mbuf *m_prepend(struct mbuf *,int, int);
+struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
+struct mbuf *m_pullup(struct mbuf *, int);
+struct mbuf *m_copyup(struct mbuf *, int, int);
+struct mbuf *m_split(struct mbuf *,int, int);
+struct mbuf *m_getptr(struct mbuf *, int, int *);
+void m_adj(struct mbuf *, int);
+struct mbuf *m_defrag(struct mbuf *, int);
+int m_apply(struct mbuf *, int, int,
+ int (*)(void *, void *, unsigned int), void *);
+void m_cat(struct mbuf *,struct mbuf *);
+void m_clget(struct mbuf *, int);
+int m_mballoc(int, int);
+void m_copyback(struct mbuf *, int, int, const void *);
+struct mbuf *m_copyback_cow(struct mbuf *, int, int, const void *, int);
+int m_makewritable(struct mbuf **, int, int, int);
+struct mbuf *m_getcl(int, int, int);
+void m_copydata(struct mbuf *, int, int, void *);
+void m_freem(struct mbuf *);
+void m_reclaim(void *, int);
+void mbinit(void);
+void m_ext_free(struct mbuf *);
+char * m_mapin(struct mbuf *);
+void m_move_pkthdr(struct mbuf *to, struct mbuf *from);
+
+/* Inline routines. */
+static __inline u_int m_length(const struct mbuf *) __unused;
+
+/* Statistics */
+void mbstat_type_add(int, int);
+
+/* Packet tag routines */
+struct m_tag *m_tag_get(int, int, int);
+void m_tag_free(struct m_tag *);
+void m_tag_prepend(struct mbuf *, struct m_tag *);
+void m_tag_unlink(struct mbuf *, struct m_tag *);
+void m_tag_delete(struct mbuf *, struct m_tag *);
+void m_tag_delete_chain(struct mbuf *, struct m_tag *);
+void m_tag_delete_nonpersistent(struct mbuf *);
+struct m_tag *m_tag_find(const struct mbuf *, int, struct m_tag *);
+struct m_tag *m_tag_copy(struct m_tag *);
+int m_tag_copy_chain(struct mbuf *, struct mbuf *);
+void m_tag_init(struct mbuf *);
+struct m_tag *m_tag_first(struct mbuf *);
+struct m_tag *m_tag_next(struct mbuf *, struct m_tag *);
+
+/* Packet tag types */
+#define PACKET_TAG_NONE 0 /* Nothing */
+#define PACKET_TAG_VLAN 1 /* VLAN ID */
+#define PACKET_TAG_ENCAP 2 /* encapsulation data */
+#define PACKET_TAG_ESP 3 /* ESP information */
+#define PACKET_TAG_PF 11 /* packet filter */
+#define PACKET_TAG_ALTQ_QID 12 /* ALTQ queue id */
+
+#define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 16
+#define PACKET_TAG_IPSEC_IN_DONE 17
+#define PACKET_TAG_IPSEC_OUT_DONE 18
+#define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 19 /* NIC IPsec crypto req'ed */
+#define PACKET_TAG_IPSEC_IN_COULD_DO_CRYPTO 20 /* NIC notifies IPsec */
+#define PACKET_TAG_IPSEC_PENDING_TDB 21 /* Reminder to do IPsec */
+
+#define PACKET_TAG_IPSEC_SOCKET 22 /* IPSEC socket ref */
+#define PACKET_TAG_IPSEC_HISTORY 23 /* IPSEC history */
+
+#define PACKET_TAG_IPSEC_NAT_T_PORTS 25 /* two uint16_t */
+
+#define PACKET_TAG_INET6 26 /* IPv6 info */
+
+#define PACKET_TAG_ECO_RETRYPARMS 27 /* Econet retry parameters */
+
+#define PACKET_TAG_TUNNEL_INFO 28 /* tunnel identification and
+ * protocol callback, for
+ * loop detection/recovery
+ */
+
+/*
+ * Return the number of bytes in the mbuf chain, m.
+ */
+static __inline u_int
+m_length(const struct mbuf *m)
+{
+ const struct mbuf *m0;
+ u_int pktlen;
+
+ if ((m->m_flags & M_PKTHDR) != 0)
+ return m->m_pkthdr.len;
+
+ pktlen = 0;
+ for (m0 = m; m0 != NULL; m0 = m0->m_next)
+ pktlen += m0->m_len;
+ return pktlen;
+}
+
+void m_print(const struct mbuf *, const char *, void (*)(const char *, ...)
+ __printflike(1, 2));
+
+#endif /* _KERNEL */
+#endif /* !_SYS_MBUF_H_ */
--- /dev/null
+/* $NetBSD: midiio.h,v 1.15 2008/04/28 20:24:11 martin Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (augustss@NetBSD.org) and (native API structures
+ * and macros) Chapman Flack (chap@NetBSD.org).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MIDIIO_H_
+#define _SYS_MIDIIO_H_
+
+/*
+ * The API defined here produces events compatible with the OSS MIDI API at
+ * the binary level.
+ */
+
+#include <machine/endian_machdep.h>
+
+/*
+ * ioctl() commands for /dev/midi##
+ * XXX is directly frobbing an MPU401 even supported? isn't it just run
+ * in UART mode?
+ */
+typedef struct {
+ unsigned char cmd;
+ char nr_args, nr_returns;
+ unsigned char data[30];
+} mpu_command_rec;
+
+#define MIDI_PRETIME _IOWR('m', 0, int)
+#define MIDI_MPUMODE _IOWR('m', 1, int)
+#define MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec)
+
+
+/* The MPU401 command acknowledge and active sense command */
+#define MIDI_ACK 0xfe
+
+
+/* Sequencer */
+#define SEQUENCER_RESET _IO ('Q', 0)
+#define SEQUENCER_SYNC _IO ('Q', 1)
+#define SEQUENCER_INFO _IOWR('Q', 2, struct synth_info)
+#define SEQUENCER_CTRLRATE _IOWR('Q', 3, int)
+#define SEQUENCER_GETOUTCOUNT _IOR ('Q', 4, int)
+#define SEQUENCER_GETINCOUNT _IOR ('Q', 5, int)
+/*#define SEQUENCER_PERCMODE _IOW ('Q', 6, int)*/
+/*#define SEQUENCER_TESTMIDI _IOW ('Q', 8, int)*/
+#define SEQUENCER_RESETSAMPLES _IOW ('Q', 9, int)
+/*
+ * The sequencer at present makes no distinction between a 'synth' and a 'midi'.
+ * This is actually a cleaner layering than OSS: devices that are onboard
+ * synths just attach midi(4) via midisyn and present an ordinary MIDI face to
+ * the system. At present the same number is returned for NRSYNTHS and NRMIDIS
+ * but don't believe both, or you'll think you have twice as many devices as
+ * you really have. The MIDI_INFO ioctl isn't implemented; use SEQUENCER_INFO
+ * (which corresponds to OSS's SYNTH_INFO) to get information on any kind of
+ * device, though the struct synth_info it uses has some members that only
+ * pertain to synths (and get filled in with fixed, probably wrong values,
+ * anyway).
+ */
+#define SEQUENCER_NRSYNTHS _IOR ('Q',10, int)
+#define SEQUENCER_NRMIDIS _IOR ('Q',11, int)
+/*#define SEQUENCER_MIDI_INFO _IOWR('Q',12, struct midi_info)*/
+#define SEQUENCER_THRESHOLD _IOW ('Q',13, int)
+#define SEQUENCER_MEMAVL _IOWR('Q',14, int)
+/*#define SEQUENCER_FM_4OP_ENABLE _IOW ('Q',15, int)*/
+#define SEQUENCER_PANIC _IO ('Q',17)
+#define SEQUENCER_OUTOFBAND _IOW ('Q',18, struct seq_event_rec)
+#define SEQUENCER_GETTIME _IOR ('Q',19, int)
+/*#define SEQUENCER_ID _IOWR('Q',20, struct synth_info)*/
+/*#define SEQUENCER_CONTROL _IOWR('Q',21, struct synth_control)*/
+/*#define SEQUENCER_REMOVESAMPLE _IOWR('Q',22, struct remove_sample)*/
+
+#if 0
+typedef struct synth_control {
+ int devno; /* Synthesizer # */
+ char data[4000]; /* Device specific command/data record */
+} synth_control;
+
+typedef struct remove_sample {
+ int devno; /* Synthesizer # */
+ int bankno; /* MIDI bank # (0=General MIDI) */
+ int instrno; /* MIDI instrument number */
+} remove_sample;
+#endif
+
+#define CMDSIZE 8
+typedef struct seq_event_rec {
+ u_char arr[CMDSIZE];
+} seq_event_rec;
+
+struct synth_info {
+ char name[30];
+ int device;
+ int synth_type;
+#define SYNTH_TYPE_FM 0
+#define SYNTH_TYPE_SAMPLE 1
+#define SYNTH_TYPE_MIDI 2
+
+ int synth_subtype;
+#define SYNTH_SUB_FM_TYPE_ADLIB 0x00
+#define SYNTH_SUB_FM_TYPE_OPL3 0x01
+#define SYNTH_SUB_MIDI_TYPE_MPU401 0x401
+
+#define SYNTH_SUB_SAMPLE_TYPE_BASIC 0x10
+#define SYNTH_SUB_SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
+
+ int nr_voices;
+ int instr_bank_size;
+ u_int capabilities;
+#define SYNTH_CAP_OPL3 0x00000002
+#define SYNTH_CAP_INPUT 0x00000004
+};
+
+/* Sequencer timer */
+#define SEQUENCER_TMR_TIMEBASE _IOWR('T', 1, int)
+#define SEQUENCER_TMR_START _IO ('T', 2)
+#define SEQUENCER_TMR_STOP _IO ('T', 3)
+#define SEQUENCER_TMR_CONTINUE _IO ('T', 4)
+#define SEQUENCER_TMR_TEMPO _IOWR('T', 5, int)
+#define SEQUENCER_TMR_SOURCE _IOWR('T', 6, int)
+# define SEQUENCER_TMR_INTERNAL 0x00000001
+#if 0
+# define SEQUENCER_TMR_EXTERNAL 0x00000002
+# define SEQUENCER_TMR_MODE_MIDI 0x00000010
+# define SEQUENCER_TMR_MODE_FSK 0x00000020
+# define SEQUENCER_TMR_MODE_CLS 0x00000040
+# define SEQUENCER_TMR_MODE_SMPTE 0x00000080
+#endif
+#define SEQUENCER_TMR_METRONOME _IOW ('T', 7, int)
+#define SEQUENCER_TMR_SELECT _IOW ('T', 8, int)
+
+
+#define MIDI_CTRL_BANK_SELECT_MSB 0
+#define MIDI_CTRL_MODULATION_MSB 1
+#define MIDI_CTRL_BREATH_MSB 2
+#define MIDI_CTRL_FOOT_MSB 4
+#define MIDI_CTRL_PORTAMENTO_TIME_MSB 5
+#define MIDI_CTRL_DATA_ENTRY_MSB 6
+#define MIDI_CTRL_CHANNEL_VOLUME_MSB 7
+#define MIDI_CTRL_BALANCE_MSB 8
+#define MIDI_CTRL_PAN_MSB 10
+#define MIDI_CTRL_EXPRESSION_MSB 11
+#define MIDI_CTRL_EFFECT_1_MSB 12
+#define MIDI_CTRL_EFFECT_2_MSB 13
+#define MIDI_CTRL_GENERAL_PURPOSE_1_MSB 16
+#define MIDI_CTRL_GENERAL_PURPOSE_2_MSB 17
+#define MIDI_CTRL_GENERAL_PURPOSE_3_MSB 18
+#define MIDI_CTRL_GENERAL_PURPOSE_4_MSB 19
+#define MIDI_CTRL_BANK_SELECT_LSB 32
+#define MIDI_CTRL_MODULATION_LSB 33
+#define MIDI_CTRL_BREATH_LSB 34
+#define MIDI_CTRL_FOOT_LSB 36
+#define MIDI_CTRL_PORTAMENTO_TIME_LSB 37
+#define MIDI_CTRL_DATA_ENTRY_LSB 38
+#define MIDI_CTRL_CHANNEL_VOLUME_LSB 39
+#define MIDI_CTRL_BALANCE_LSB 40
+#define MIDI_CTRL_PAN_LSB 42
+#define MIDI_CTRL_EXPRESSION_LSB 43
+#define MIDI_CTRL_EFFECT_1_LSB 44
+#define MIDI_CTRL_EFFECT_2_LSB 45
+#define MIDI_CTRL_GENERAL_PURPOSE_1_LSB 48
+#define MIDI_CTRL_GENERAL_PURPOSE_2_LSB 49
+#define MIDI_CTRL_GENERAL_PURPOSE_3_LSB 50
+#define MIDI_CTRL_GENERAL_PURPOSE_4_LSB 51
+#define MIDI_CTRL_HOLD_1 64
+#define MIDI_CTRL_PORTAMENTO 65
+#define MIDI_CTRL_SOSTENUTO 66
+#define MIDI_CTRL_SOFT_PEDAL 67
+#define MIDI_CTRL_LEGATO 68
+#define MIDI_CTRL_HOLD_2 69
+#define MIDI_CTRL_SOUND_VARIATION 70
+#define MIDI_CTRL_HARMONIC_INTENSITY 71
+#define MIDI_CTRL_RELEASE_TIME 72
+#define MIDI_CTRL_ATTACK_TIME 73
+#define MIDI_CTRL_BRIGHTNESS 74
+#define MIDI_CTRL_DECAY_TIME 75
+#define MIDI_CTRL_VIBRATO_RATE 76
+#define MIDI_CTRL_VIBRATO_DEPTH 77
+#define MIDI_CTRL_VIBRATO_DELAY 78
+#define MIDI_CTRL_VIBRATO_DECAY MIDI_CTRL_VIBRATO_DELAY /*deprecated*/
+#define MIDI_CTRL_SOUND_10 79
+#define MIDI_CTRL_GENERAL_PURPOSE_5 80
+#define MIDI_CTRL_GENERAL_PURPOSE_6 81
+#define MIDI_CTRL_GENERAL_PURPOSE_7 82
+#define MIDI_CTRL_GENERAL_PURPOSE_8 83
+#define MIDI_CTRL_PORTAMENTO_CONTROL 84
+#define MIDI_CTRL_EFFECT_DEPTH_1 91
+#define MIDI_CTRL_EFFECT_DEPTH_2 92
+#define MIDI_CTRL_EFFECT_DEPTH_3 93
+#define MIDI_CTRL_EFFECT_DEPTH_4 94
+#define MIDI_CTRL_EFFECT_DEPTH_5 95
+#define MIDI_CTRL_RPN_INCREMENT 96
+#define MIDI_CTRL_RPN_DECREMENT 97
+#define MIDI_CTRL_NRPN_LSB 98
+#define MIDI_CTRL_NRPN_MSB 99
+#define MIDI_CTRL_RPN_LSB 100
+#define MIDI_CTRL_RPN_MSB 101
+#define MIDI_CTRL_SOUND_OFF 120
+#define MIDI_CTRL_RESET 121
+#define MIDI_CTRL_LOCAL 122
+#define MIDI_CTRL_NOTES_OFF 123
+#define MIDI_CTRL_ALLOFF MIDI_CTRL_NOTES_OFF /*deprecated*/
+#define MIDI_CTRL_OMNI_OFF 124
+#define MIDI_CTRL_OMNI_ON 125
+#define MIDI_CTRL_POLY_OFF 126
+#define MIDI_CTRL_POLY_ON 127
+
+#define MIDI_BEND_NEUTRAL (1<<13)
+
+#define MIDI_RPN_PITCH_BEND_SENSITIVITY 0
+#define MIDI_RPN_CHANNEL_FINE_TUNING 1
+#define MIDI_RPN_CHANNEL_COARSE_TUNING 2
+#define MIDI_RPN_TUNING_PROGRAM_CHANGE 3
+#define MIDI_RPN_TUNING_BANK_SELECT 4
+#define MIDI_RPN_MODULATION_DEPTH_RANGE 5
+
+#define MIDI_NOTEOFF 0x80
+#define MIDI_NOTEON 0x90
+#define MIDI_KEY_PRESSURE 0xA0
+#define MIDI_CTL_CHANGE 0xB0
+#define MIDI_PGM_CHANGE 0xC0
+#define MIDI_CHN_PRESSURE 0xD0
+#define MIDI_PITCH_BEND 0xE0
+#define MIDI_SYSTEM_PREFIX 0xF0
+
+#define MIDI_IS_STATUS(d) ((d) >= 0x80)
+#define MIDI_IS_COMMON(d) ((d) >= 0xf0)
+
+#define MIDI_SYSEX_START 0xF0
+#define MIDI_SYSEX_END 0xF7
+
+#define MIDI_GET_STATUS(d) ((d) & 0xf0)
+#define MIDI_GET_CHAN(d) ((d) & 0x0f)
+
+#define MIDI_HALF_VEL 64
+
+#define SEQ_LOCAL 0x80
+#define SEQ_TIMING 0x81
+#define SEQ_CHN_COMMON 0x92
+#define SEQ_CHN_VOICE 0x93
+#define SEQ_SYSEX 0x94
+#define SEQ_FULLSIZE 0xfd
+
+#define SEQ_MK_CHN_VOICE(e, unit, cmd, chan, key, vel) (\
+ (e)->arr[0] = SEQ_CHN_VOICE, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\
+ (e)->arr[3] = (chan), (e)->arr[4] = (key), (e)->arr[5] = (vel),\
+ (e)->arr[6] = 0, (e)->arr[7] = 0)
+#define SEQ_MK_CHN_COMMON(e, unit, cmd, chan, p1, p2, w14) (\
+ (e)->arr[0] = SEQ_CHN_COMMON, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\
+ (e)->arr[3] = (chan), (e)->arr[4] = (p1), (e)->arr[5] = (p2),\
+ *(short*)&(e)->arr[6] = (w14))
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+/* big endian */
+#define SEQ_PATCHKEY(id) (0xfd00|id)
+#else
+/* little endian */
+#define SEQ_PATCHKEY(id) ((id<<8)|0xfd)
+#endif
+struct sysex_info {
+ uint16_t key; /* Use SYSEX_PATCH or MAUI_PATCH here */
+#define SEQ_SYSEX_PATCH SEQ_PATCHKEY(0x05)
+#define SEQ_MAUI_PATCH SEQ_PATCHKEY(0x06)
+ int16_t device_no; /* Synthesizer number */
+ int32_t len; /* Size of the sysex data in bytes */
+ u_char data[1]; /* Sysex data starts here */
+};
+#define SEQ_SYSEX_HDRSIZE ((u_long)((struct sysex_info *)0)->data)
+
+typedef unsigned char sbi_instr_data[32];
+struct sbi_instrument {
+ uint16_t key; /* FM_PATCH or OPL3_PATCH */
+#define SBI_FM_PATCH SEQ_PATCHKEY(0x01)
+#define SBI_OPL3_PATCH SEQ_PATCHKEY(0x03)
+ int16_t device;
+ int32_t channel;
+ sbi_instr_data operators;
+};
+
+#define TMR_RESET 0 /* beware: not an OSS event */
+#define TMR_WAIT_REL 1 /* Time relative to the prev time */
+#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
+#define TMR_STOP 3
+#define TMR_START 4
+#define TMR_CONTINUE 5
+#define TMR_TEMPO 6
+#define TMR_ECHO 8
+#define TMR_CLOCK 9 /* MIDI clock */
+#define TMR_SPP 10 /* Song position pointer */
+#define TMR_TIMESIG 11 /* Time signature */
+
+/* Old sequencer definitions */
+#define SEQOLD_CMDSIZE 4
+
+#define SEQOLD_NOTEOFF 0
+#define SEQOLD_NOTEON 1
+#define SEQOLD_WAIT TMR_WAIT_ABS
+#define SEQOLD_PGMCHANGE 3
+#define SEQOLD_SYNCTIMER TMR_START
+#define SEQOLD_MIDIPUTC 5
+#define SEQOLD_ECHO TMR_ECHO
+#define SEQOLD_AFTERTOUCH 9
+#define SEQOLD_CONTROLLER 10
+#define SEQOLD_PRIVATE 0xfe
+#define SEQOLD_EXTENDED 0xff
+
+/*
+ * The 'midipitch' data type, used in the kernel between the midisyn layer and
+ * onboard synth drivers, and in userland as parameters to the MIDI Tuning Spec
+ * (RP-012) universal-system-exclusive messages. It is a MIDI key number shifted
+ * left to accommodate 14 bit sub-semitone resolution. In this representation,
+ * tuning and bending adjustments are simple addition and subtraction.
+ */
+typedef int32_t midipitch_t;
+
+/*
+ * Nominal conversions between midipitches and key numbers. (Beware that these
+ * are the nominal, standard correspondences, but whole point of the MIDI Tuning
+ * Spec is that you can set things up so the hardware might render key N at
+ * actual pitch MIDIPITCH_FROM_KEY(N)+c for some correction c.)
+ */
+#define MIDIPITCH_FROM_KEY(k) ((k)<<14)
+#define MIDIPITCH_TO_KEY(mp) (((mp)+(1<<13))>>14)
+
+#define MIDIPITCH_MAX (MIDIPITCH_FROM_KEY(128)-2) /* ...(128)-1 is reserved */
+#define MIDIPITCH_OCTAVE 196608
+#define MIDIPITCH_SEMITONE 16384
+#define MIDIPITCH_CENT 164 /* this, regrettably, is inexact. */
+
+/*
+ * For rendering, convert a midipitch (after all tuning adjustments) to Hz.
+ * The conversion is DEFINED as MIDI key 69.00000 (A) === 440 Hz equal tempered
+ * always. Alternate tunings are obtained by adjusting midipitches.
+ *
+ * The midihz18_t (Hz shifted left for 18-bit sub-Hz resolution) covers the
+ * full midipitch range without losing 21-bit precision, as the lowest midipitch
+ * is ~8 Hz (~3 bits left of radix point, 18 right) and for the highest the
+ * result still fits in a uint32.
+ */
+typedef uint32_t midihz18_t;
+
+#define MIDIHZ18_TO_HZ(h18) ((h18)>>18) /* truncates! ok for dbg msgs maybe */
+
+#ifndef _KERNEL
+/*
+ * With floating point in userland, can also manipulate midipitches as
+ * floating-point fractional MIDI key numbers (tuning adjustments are still
+ * additive), and hz18 as fractional Hz (adjustments don't add in this form).
+ */
+#include <math.h>
+#define MIDIPITCH_TO_FRKEY(mp) (scalbn((mp),-14))
+#define MIDIPITCH_FROM_FRKEY(frk) ((midipitch_t)round(scalbn((frk),14)))
+#define MIDIHZ18_TO_FRHZ(h18) (scalbn((h18),-18))
+#define MIDIHZ18_FROM_FRHZ(frh) ((midihz18_t)round(scalbn((frh),18)))
+
+#define MIDIPITCH_TO_FRHZ(mp) (440*pow(2,(MIDIPITCH_TO_FRKEY((mp))-69)/12))
+#define MIDIPITCH_FROM_FRHZ(fhz) \
+ MIDIPITCH_FROM_FRKEY(69+12*log((fhz)/440)/log(2))
+#define MIDIPITCH_TO_HZ18(mp) MIDIHZ18_FROM_FRHZ(MIDIPITCH_TO_FRHZ((mp)))
+#define MIDIPITCH_FROM_HZ18(h18) MIDIPITCH_FROM_FRHZ(MIDIHZ18_TO_FRHZ((h18)))
+
+#else /* no fp in kernel; only an accurate to-hz18 conversion is implemented */
+
+extern midihz18_t midisyn_mp2hz18(midipitch_t);
+#define MIDIPITCH_TO_HZ18(mp) (midisyn_mp2hz18((mp)))
+
+#endif /* _KERNEL */
+
+
+/*
+ * A native API for the /dev/music sequencer device follows. The event
+ * structures are OSS events at the level of bytes, but for developing or
+ * porting applications some macros and documentation are needed to generate
+ * and dissect the events; here they are. For porting existing OSS applications,
+ * sys/soundcard.h can be extended to supply the usual OSS macros, defining them
+ * in terms of these.
+ */
+
+/*
+ * TODO: determine OSS compatible structures for TMR_RESET and TMR_CLOCK,
+ * OSS values of EV_SYSTEM, SNDCTL_SEQ_ACTSENSE_ENABLE,
+ * SNDCTL_SEQ_TIMING_ENABLE, and SNDCTL_SEQ_RT_ENABLE.
+ * (TMR_RESET may be a NetBSD extension: it is generated in sequencer.c and
+ * has no args. To be corrected if a different definition is found anywhere.)
+ */
+typedef union {
+
+#define _EVT_HDR \
+ uint8_t tag
+
+ _EVT_HDR;
+
+#define _LOCAL_HDR \
+ _EVT_HDR; \
+ uint8_t op
+
+ struct { _LOCAL_HDR; } local;
+
+ struct {
+ _LOCAL_HDR;
+ uint16_t _zero;
+ uint32_t devmask;
+ } l_startaudio;
+
+/* define a constructor for local evts - someday when we support any */
+
+#define _TIMING_HDR \
+ _LOCAL_HDR; \
+ uint16_t _zeroh
+ struct { _TIMING_HDR; } timing;
+
+ struct {
+ _TIMING_HDR;
+ uint32_t divisions;
+ } t_WAIT_REL, t_WAIT_ABS;
+
+ struct {
+ _TIMING_HDR;
+ uint32_t _zero;
+ } t_STOP, t_START, t_CONTINUE, t_RESET;
+
+ struct {
+ _TIMING_HDR;
+ uint32_t bpm; /* unambiguously, (MIDI clocks/minute)/24 */
+ } t_TEMPO;
+
+ struct {
+ _TIMING_HDR;
+ uint32_t cookie;
+ } t_ECHO;
+
+ struct {
+ _TIMING_HDR;
+ uint32_t midibeat; /* in low 14 bits; midibeat: 6 MIDI clocks */
+ } t_SPP;
+
+ struct {
+ _TIMING_HDR;
+#if _BYTE_ORDER == _BIG_ENDIAN
+ uint8_t numerator;
+ uint8_t lg2denom;
+ uint8_t clks_per_click;
+ uint8_t dsq_per_24clks;
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+ uint8_t dsq_per_24clks;
+ uint8_t clks_per_click;
+ uint8_t lg2denom;
+ uint8_t numerator;
+#else
+#error "unexpected _BYTE_ORDER"
+#endif
+ } t_TIMESIG;
+
+ struct { /* use this only to implement OSS compatibility macro */
+ _TIMING_HDR;
+ uint32_t signature;
+ } t_osscompat_timesig;
+
+
+#define _COMMON_HDR \
+ _EVT_HDR; \
+ uint8_t device; \
+ uint8_t op; \
+ uint8_t channel
+
+ struct { _COMMON_HDR; } common;
+
+ struct {
+ _COMMON_HDR;
+ uint8_t controller;
+ uint8_t _zero;
+ uint16_t value;
+ } c_CTL_CHANGE;
+
+ struct {
+ _COMMON_HDR;
+ uint8_t program;
+ uint8_t _zero0;
+ uint16_t _zero1;
+ } c_PGM_CHANGE;
+
+ struct {
+ _COMMON_HDR;
+ uint8_t pressure;
+ uint8_t _zero0;
+ uint16_t _zero1;
+ } c_CHN_PRESSURE;
+
+ struct {
+ _COMMON_HDR;
+ uint8_t _zero0;
+ uint8_t _zero1;
+ uint16_t value;
+ } c_PITCH_BEND;
+
+#define _VOICE_HDR \
+ _COMMON_HDR; \
+ uint8_t key
+
+ struct { _VOICE_HDR; } voice;
+
+ struct {
+ _VOICE_HDR;
+ uint8_t velocity;
+ uint16_t _zero;
+ } c_NOTEOFF, c_NOTEON;
+
+ struct {
+ _VOICE_HDR;
+ uint8_t pressure;
+ uint16_t _zero;
+ } c_KEY_PRESSURE;
+
+ struct {
+ _EVT_HDR;
+ uint8_t device;
+ uint8_t buffer[6];
+ } sysex;
+
+ struct {
+ _EVT_HDR;
+ uint8_t device;
+ uint8_t status;
+ uint8_t data[2];
+ } system;
+
+ struct {
+ _EVT_HDR;
+ uint8_t byte;
+ uint8_t device;
+ uint8_t _zero0;
+ uint32_t _zero1;
+ } putc; /* a seqold event that's still needed at times, ugly as 'tis */
+
+ struct {
+ _EVT_HDR;
+ uint8_t byte[7];
+ } unknown; /* for debug/display */
+
+#undef _VOICE_HDR
+#undef _COMMON_HDR
+#undef _TIMING_HDR
+#undef _LOCAL_HDR
+#undef _EVT_HDR
+
+} __packed seq_event_t;
+
+#define _SEQ_TAG_NOTEOFF SEQ_CHN_VOICE
+#define _SEQ_TAG_NOTEON SEQ_CHN_VOICE
+#define _SEQ_TAG_KEY_PRESSURE SEQ_CHN_VOICE
+
+#define _SEQ_TAG_CTL_CHANGE SEQ_CHN_COMMON
+#define _SEQ_TAG_PGM_CHANGE SEQ_CHN_COMMON
+#define _SEQ_TAG_CHN_PRESSURE SEQ_CHN_COMMON
+#define _SEQ_TAG_PITCH_BEND SEQ_CHN_COMMON
+
+#if __STDC_VERSION__ >= 199901L
+
+#define SEQ_MK_EVENT(_member,_tag,...) \
+(seq_event_t){ ._member = { .tag = (_tag), __VA_ARGS__ } }
+
+#define SEQ_MK_TIMING(_op,...) \
+SEQ_MK_EVENT(t_##_op, SEQ_TIMING, .op = TMR_##_op, __VA_ARGS__)
+
+#define SEQ_MK_CHN(_op,...) \
+SEQ_MK_EVENT(c_##_op, _SEQ_TAG_##_op, .op = MIDI_##_op, __VA_ARGS__)
+
+#define SEQ_MK_SYSEX(_dev,...) \
+SEQ_MK_EVENT(sysex, 0x94, .device=(_dev), \
+ .buffer={0xff, 0xff, 0xff, 0xff, 0xff, 0xff, __VA_ARGS__})
+
+#else /* assume gcc 2.95.3 */
+
+#define SEQ_MK_EVENT(_member,_tag,_args...) \
+(seq_event_t){ ._member = { .tag = (_tag), _args } }
+
+#define SEQ_MK_TIMING(_op,_args...) \
+SEQ_MK_EVENT(t_##_op, SEQ_TIMING, .op = TMR_##_op, _args)
+
+#define SEQ_MK_CHN(_op,_args...) \
+SEQ_MK_EVENT(c_##_op, _SEQ_TAG_##_op, .op = MIDI_##_op, _args)
+
+#define SEQ_MK_SYSEX(_dev,_args...) \
+SEQ_MK_EVENT(sysex, 0x94, .device=(_dev), \
+ .buffer={0xff, 0xff, 0xff, 0xff, 0xff, 0xff, _args})
+
+#endif /* c99 vs. gcc 2.95.3 */
+
+#if 0
+#include <fcntl.h>
+#include <stdio.h>
+int
+main(int argc, char **argv)
+{
+ int i;
+ int fd;
+ seq_event_t e;
+
+ /* simple usage example (add a buffer to reduce syscall overhead) */
+ fd = open("/dev/music", O_RDWR);
+ write(fd, &SEQ_MK_TIMING(START), sizeof (seq_event_t));
+
+ read(fd, &e, sizeof e);
+ switch ( e.tag ) {
+ case SEQ_CHN_VOICE:
+ switch ( e.voice.op ) {
+ case MIDI_NOTEON:
+ printf("Note on, dev=%d chn=%d key=%d vel=%d\n",
+ e.c_NOTEON.device, e.c_NOTEON.channel,
+ e.c_NOTEON.key, e.c_NOTEON.velocity);
+ }
+ }
+
+ /* all the macros: */
+ e = SEQ_MK_TIMING(START);
+ e = SEQ_MK_TIMING(STOP);
+ e = SEQ_MK_TIMING(CONTINUE);
+ /*
+ * Wait until the specified number of divisions from the timer start
+ * (abs) or the preceding event (rel). The number of divisions to a
+ * beat or to a MIDI clock is determined by the timebase (set by
+ * ioctl). The tempo is expressed in beats per minute, where a beat
+ * is always 24 MIDI clocks (and usually equated to a quarter note,
+ * but that can be changed with timesig)--that is, tempo is
+ * (MIDI clocks per minute)/24. The timebase is the number of divisions
+ * in a beat--that is, the number of divisions that make up 24 MIDI
+ * clocks--so the timebase is 24*(divisions per MIDI clock). The MThd
+ * header in a SMF gives the 'natural' timebase for the file; if the
+ * timebase is set accordingly, then the delay values appearing in the
+ * tracks are in terms of divisions, and can be used as WAIT_REL
+ * arguments without modification.
+ */
+ e = SEQ_MK_TIMING(WAIT_ABS, .divisions=192);
+ e = SEQ_MK_TIMING(WAIT_REL, .divisions=192);
+ /*
+ * The 'beat' in bpm is 24 MIDI clocks (usually a quarter note but
+ * changeable with timesig).
+ */
+ e = SEQ_MK_TIMING(TEMPO, .bpm=84);
+ /*
+ * An ECHO event on output appears on input at the appointed time; the
+ * cookie can be anything of interest to the application. Can be used
+ * in schemes to get some control over latency.
+ */
+ e = SEQ_MK_TIMING(ECHO, .cookie=0xfeedface);
+ /*
+ * A midibeat is smaller than a beat. It is six MIDI clocks, or a fourth
+ * of a beat, or a sixteenth note if the beat is a quarter. SPP is a
+ * request to position at the requested midibeat from the start of the
+ * sequence. [sequencer does not at present implement SPP]
+ */
+ e = SEQ_MK_TIMING(SPP, .midibeat=128);
+ /*
+ * numerator and lg2denom describe the time signature as it would
+ * appear on a staff, where lg2denom of 0,1,2,3... corresponds to
+ * denominator of 1,2,4,8... respectively. So the example below
+ * corresponds to 4/4. dsq_per_24clks defines the relationship of
+ * MIDI clocks to note values, by specifying the number of
+ * demisemiquavers (32nd notes) represented by 24 MIDI clocks.
+ * The default is 8 demisemiquavers, or a quarter note.
+ * clks_per_click can configure a metronome (for example, the MPU401
+ * had such a feature in intelligent mode) to click every so many
+ * MIDI clocks. The 24 in this example would give a click every quarter
+ * note. [sequencer does not at present implement TIMESIG]
+ */
+ e = SEQ_MK_TIMING(TIMESIG, .numerator=4, .lg2denom=2,
+ .clks_per_click=24, .dsq_per_24clks=8);
+ /*
+ * This example declares 6/8 time where the beat (24 clocks) is the
+ * eighth note, but the metronome clicks every dotted quarter (twice
+ * per measure):
+ */
+ e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3,
+ .clks_per_click=72, .dsq_per_24clks=4);
+ /*
+ * An alternate declaration for 6/8 where the beat (24 clocks) is now
+ * the dotted quarter and corresponds to the metronome click:
+ */
+ e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3,
+ .clks_per_click=24, .dsq_per_24clks=12);
+ /*
+ * It would also be possible to keep the default correspondence of
+ * 24 clocks to the quarter note (8 dsq), and still click the metronome
+ * each dotted quarter:
+ */
+ e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3,
+ .clks_per_click=36, .dsq_per_24clks=8);
+
+ e = SEQ_MK_CHN(NOTEON, .device=1, .channel=0, .key=60, .velocity=64);
+ e = SEQ_MK_CHN(NOTEOFF, .device=1, .channel=0, .key=60, .velocity=64);
+ e = SEQ_MK_CHN(KEY_PRESSURE, .device=1, .channel=0, .key=60,
+ .pressure=64);
+
+ /*
+ * sequencer does not at present implement CTL_CHANGE well. The API
+ * provides for a 14-bit value where you give the controller index
+ * of the controller MSB and sequencer will split the 14-bit value to
+ * the controller MSB and LSB for you--but it doesn't; it ignores the
+ * high bits of value and writes the low bits whether you have specified
+ * MSB or LSB. That would not be hard to fix but for the fact that OSS
+ * itself seems to suffer from the same mixup (and its behavior differs
+ * with whether the underlying device is an onboard synth or a MIDI
+ * link!) so there is surely a lot of code that relies on it being
+ * broken :(.
+ * (Note: as the OSS developers have ceased development of the
+ * /dev/music API as of OSS4, it would be possible given a complete
+ * list of the events defined in OSS4 to add some new ones for native
+ * use without fear of future conflict, such as a better ctl_change.)
+ */
+ e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0,
+ .controller=MIDI_CTRL_EXPRESSION_MSB, .value=8192);/*XX*/
+ /*
+ * The way you really have to do it:
+ */
+ e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0,
+ .controller=MIDI_CTRL_EXPRESSION_MSB, .value=8192>>7);
+ e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0,
+ .controller=MIDI_CTRL_EXPRESSION_LSB, .value=8192&0x7f);
+
+ e = SEQ_MK_CHN(PGM_CHANGE, .device=1, .channel=0, .program=51);
+ e = SEQ_MK_CHN(CHN_PRESSURE, .device=1, .channel=0, .pressure=64);
+ e = SEQ_MK_CHN(PITCH_BEND, .device=1, .channel=0, .value=8192);
+
+ /*
+ * A SYSEX event carries up to six bytes of a system exclusive message.
+ * The first such message must begin with MIDI_SYSEX_START (0xf0), the
+ * last must end with MIDI_SYSEX_END (0xf7), and only the last may carry
+ * fewer than 6 bytes. To supply message bytes in the macro, you must
+ * prefix the first with [0]= as shown. The macro's first argument is
+ * the device.
+ */
+ e = SEQ_MK_SYSEX(1,[0]=MIDI_SYSEX_START,1,2,MIDI_SYSEX_END);
+ /*
+ * In some cases it may be easier to use the macro only to initialize
+ * the event, and fill in the message bytes later. The code that fills
+ * in the message does not need to store 0xff following the SYSEX_END.
+ */
+ e = SEQ_MK_SYSEX(1);
+ for ( i = 0; i < 3; ++ i )
+ e.sysex.buffer[i] = i;
+ /*
+ * It would be nice to think the old /dev/sequencer MIDIPUTC event
+ * obsolete, but it is still needed (absent any better API) by any MIDI
+ * file player that will implement the ESCAPED events that may occur in
+ * SMF. Sorry. Here's how to use it:
+ */
+ e = SEQ_MK_EVENT(putc, SEQOLD_MIDIPUTC, .device=1, .byte=42);
+
+ printf("confirm event size: %d (should be 8)\n", sizeof (seq_event_t));
+ return 0;
+}
+#endif /* 0 */
+
+#endif /* !_SYS_MIDIIO_H_ */
--- /dev/null
+/* $NetBSD: module.h,v 1.31 2012/08/07 01:19:06 jnemeth Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MODULE_H_
+#define _SYS_MODULE_H_
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/uio.h>
+
+#define MAXMODNAME 32
+#define MAXMODDEPS 10
+
+/* Module classes, provided only for system boot and cosmetic purposes. */
+typedef enum modclass {
+ MODULE_CLASS_ANY,
+ MODULE_CLASS_MISC,
+ MODULE_CLASS_VFS,
+ MODULE_CLASS_DRIVER,
+ MODULE_CLASS_EXEC,
+ MODULE_CLASS_SECMODEL
+} modclass_t;
+
+/* Module sources: where did it come from? */
+typedef enum modsrc {
+ MODULE_SOURCE_KERNEL,
+ MODULE_SOURCE_BOOT,
+ MODULE_SOURCE_FILESYS
+} modsrc_t;
+
+/* Commands passed to module control routine. */
+typedef enum modcmd {
+ MODULE_CMD_INIT, /* mandatory */
+ MODULE_CMD_FINI, /* mandatory */
+ MODULE_CMD_STAT, /* optional */
+ MODULE_CMD_AUTOUNLOAD, /* optional */
+} modcmd_t;
+
+#ifdef _KERNEL
+
+#include <sys/mutex.h>
+
+#include <prop/proplib.h>
+
+/* Module header structure. */
+typedef struct modinfo {
+ u_int mi_version;
+ modclass_t mi_class;
+ int (*mi_modcmd)(modcmd_t, void *);
+ const char *mi_name;
+ const char *mi_required;
+} const modinfo_t;
+
+/* Per module information, maintained by kern_module.c */
+typedef struct module {
+ u_int mod_refcnt;
+ const modinfo_t *mod_info;
+ struct kobj *mod_kobj;
+ TAILQ_ENTRY(module) mod_chain;
+ struct module *mod_required[MAXMODDEPS];
+ u_int mod_nrequired;
+ modsrc_t mod_source;
+ time_t mod_autotime;
+ void *mod_ctf;
+ u_int mod_fbtentries; /* DTrace FBT entrie count */
+ int mod_flags;
+#define MODFLG_MUST_FORCE 0x01
+#define MODFLG_AUTO_LOADED 0x02
+
+} module_t;
+
+/*
+ * Per-module linkage. Loadable modules have a `link_set_modules' section
+ * containing only one entry, pointing to the module's modinfo_t record.
+ * For the kernel, `link_set_modules' can contain multiple entries and
+ * records all modules built into the kernel at link time.
+ */
+#define MODULE(class, name, required) \
+static int name##_modcmd(modcmd_t, void *); \
+static const modinfo_t name##_modinfo = { \
+ .mi_version = __NetBSD_Version__, \
+ .mi_class = (class), \
+ .mi_modcmd = name##_modcmd, \
+ .mi_name = #name, \
+ .mi_required = (required) \
+}; \
+__link_set_add_rodata(modules, name##_modinfo);
+
+TAILQ_HEAD(modlist, module);
+
+extern struct vm_map *module_map;
+extern u_int module_count;
+extern u_int module_builtinlist;
+extern struct modlist module_list;
+extern struct modlist module_builtins;
+extern u_int module_gen;
+
+void module_init(void);
+void module_start_unload_thread(void);
+void module_builtin_require_force(void);
+void module_init_md(void);
+void module_init_class(modclass_t);
+int module_prime(const char *, void *, size_t);
+
+bool module_compatible(int, int);
+int module_load(const char *, int, prop_dictionary_t, modclass_t);
+int module_builtin_add(modinfo_t * const *, size_t, bool);
+int module_builtin_remove(modinfo_t *, bool);
+int module_autoload(const char *, modclass_t);
+int module_unload(const char *);
+int module_hold(const char *);
+void module_rele(const char *);
+int module_find_section(const char *, void **, size_t *);
+void module_thread_kick(void);
+void module_load_vfs_init(void);
+
+void module_whatis(uintptr_t, void (*)(const char *, ...)
+ __printflike(1, 2));
+void module_print_list(void (*)(const char *, ...) __printflike(1, 2));
+
+#ifdef _MODULE_INTERNAL
+extern
+int (*module_load_vfs_vec)(const char *, int, bool, module_t *,
+ prop_dictionary_t *);
+int module_load_vfs(const char *, int, bool, module_t *,
+ prop_dictionary_t *);
+void module_error(const char *, ...) __printflike(1, 2);
+void module_print(const char *, ...) __printflike(1, 2);
+#endif /* _MODULE_INTERNAL */
+
+#define MODULE_BASE_SIZE 64
+extern char module_base[MODULE_BASE_SIZE];
+extern char *module_machine;
+
+#else /* _KERNEL */
+
+#include <stdint.h>
+
+#endif /* _KERNEL */
+
+typedef struct modctl_load {
+ const char *ml_filename;
+
+#define MODCTL_NO_PROP 0x2
+#define MODCTL_LOAD_FORCE 0x1
+ int ml_flags;
+
+ const char *ml_props;
+ size_t ml_propslen;
+} modctl_load_t;
+
+typedef enum modctl {
+ MODCTL_LOAD, /* modctl_load_t *ml */
+ MODCTL_UNLOAD, /* char *name */
+ MODCTL_STAT, /* struct iovec *buffer */
+ MODCTL_EXISTS /* enum: 0: load, 1: autoload */
+} modctl_t;
+
+/*
+ * This structure intentionally has the same layout for 32 and 64
+ * bit builds.
+ */
+typedef struct modstat {
+ char ms_name[MAXMODNAME];
+ char ms_required[MAXMODNAME * MAXMODDEPS];
+ uint64_t ms_addr;
+ modsrc_t ms_source;
+ modclass_t ms_class;
+ u_int ms_size;
+ u_int ms_refcnt;
+ u_int ms_reserved[4];
+} modstat_t;
+
+int modctl(int, void *);
+
+#endif /* !_SYS_MODULE_H_ */
--- /dev/null
+/* $NetBSD: mqueue.h,v 1.16 2011/11/21 04:36:05 christos Exp $ */
+
+/*
+ * Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MQUEUE_H_
+#define _SYS_MQUEUE_H_
+
+/* Maximal number of mqueue descriptors, that process could open */
+#define MQ_OPEN_MAX 512
+
+/* Maximal priority of the message */
+#define MQ_PRIO_MAX 32
+
+struct mq_attr {
+ long mq_flags; /* Flags of message queue */
+ long mq_maxmsg; /* Maximum number of messages */
+ long mq_msgsize; /* Maximum size of the message */
+ long mq_curmsgs; /* Count of the queued messages */
+};
+
+/* Internal kernel data */
+#ifdef _KERNEL
+
+#include <sys/condvar.h>
+#include <sys/mutex.h>
+#include <sys/queue.h>
+#include <sys/selinfo.h>
+#include <sys/types.h>
+#include <sys/param.h>
+
+/*
+ * Flags below are used in mq_flags for internal purposes.
+ * This is permitted according to POSIX.
+ */
+
+/* Message queue is unlinked */
+#define MQ_UNLINKED 0x10000000
+/* There are receive-waiters */
+#define MQ_RECEIVE 0x20000000
+
+/* Maximal length of mqueue name */
+#define MQ_NAMELEN (KERNEL_NAME_MAX + 1)
+
+/* Default size of the message */
+#define MQ_DEF_MSGSIZE 1024
+
+/* Size/bits and index of reserved queue */
+#define MQ_PQSIZE 32
+#define MQ_PQRESQ 0
+
+/* Structure of the message queue. */
+typedef struct mqueue {
+ char * mq_name;
+ kmutex_t mq_mtx;
+ kcondvar_t mq_send_cv;
+ kcondvar_t mq_recv_cv;
+ struct mq_attr mq_attrib;
+ /* Notification */
+ struct selinfo mq_rsel;
+ struct selinfo mq_wsel;
+ struct sigevent mq_sig_notify;
+ struct proc * mq_notify_proc;
+ /* Permissions */
+ mode_t mq_mode;
+ uid_t mq_euid;
+ gid_t mq_egid;
+ /* Reference counter, queue array and bitmap */
+ u_int mq_refcnt;
+ TAILQ_HEAD(, mq_msg) mq_head[1 + MQ_PQSIZE];
+ uint32_t mq_bitmap;
+ /* Entry of the global list */
+ LIST_ENTRY(mqueue) mq_list;
+ /* Time stamps */
+ struct timespec mq_atime;
+ struct timespec mq_mtime;
+ struct timespec mq_btime;
+} mqueue_t;
+
+/* Structure of the message. */
+typedef struct mq_msg {
+ TAILQ_ENTRY(mq_msg) msg_queue;
+ size_t msg_len;
+ u_int msg_prio;
+ uint8_t msg_ptr[1];
+} mq_msg_t;
+
+/* Prototypes */
+void mqueue_print_list(void (*pr)(const char *, ...) __printflike(1, 2));
+int mq_send1(mqd_t, const char *, size_t, u_int, struct timespec *);
+int mq_recv1(mqd_t, void *, size_t, u_int *, struct timespec *, ssize_t *);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_MQUEUE_H_ */
--- /dev/null
+/* $NetBSD: msg.h,v 1.24 2009/01/19 19:39:41 christos Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * SVID compatible msg.h file
+ *
+ * Author: Daniel Boulet
+ *
+ * Copyright 1993 Daniel Boulet and RTMX Inc.
+ *
+ * This system call was implemented by Daniel Boulet under contract from RTMX.
+ *
+ * Redistribution and use in source forms, with and without modification,
+ * are permitted provided that this entire comment appears intact.
+ *
+ * Redistribution in binary form may occur without any restrictions.
+ * Obviously, it would be nice if you gave credit where credit is due
+ * but requiring it would be too onerous.
+ *
+ * This software is provided ``AS IS'' without any warranties of any kind.
+ */
+
+#ifndef _SYS_MSG_H_
+#define _SYS_MSG_H_
+
+#include <sys/featuretest.h>
+#include <sys/ipc.h>
+#ifdef _KERNEL
+#include <sys/condvar.h>
+#include <sys/mutex.h>
+#endif
+
+#ifdef _KERNEL
+struct __msg {
+ struct __msg *msg_next; /* next msg in the chain */
+ long msg_type; /* type of this message */
+ /* >0 -> type of this message */
+ /* 0 -> free header */
+ u_short msg_ts; /* size of this message */
+ short msg_spot; /* location of start of msg in buffer */
+};
+#endif /* _KERNEL */
+
+#define MSG_NOERROR 010000 /* don't complain about too long msgs */
+
+typedef unsigned long msgqnum_t;
+typedef size_t msglen_t;
+
+struct msqid_ds {
+ struct ipc_perm msg_perm; /* operation permission strucure */
+ msgqnum_t msg_qnum; /* number of messages in the queue */
+ msglen_t msg_qbytes; /* max # of bytes in the queue */
+ pid_t msg_lspid; /* process ID of last msgsend() */
+ pid_t msg_lrpid; /* process ID of last msgrcv() */
+ time_t msg_stime; /* time of last msgsend() */
+ time_t msg_rtime; /* time of last msgrcv() */
+ time_t msg_ctime; /* time of last change */
+
+ /*
+ * These members are private and used only in the internal
+ * implementation of this interface.
+ */
+ struct __msg *_msg_first; /* first message in the queue */
+ struct __msg *_msg_last; /* last message in the queue */
+ msglen_t _msg_cbytes; /* # of bytes currently in queue */
+};
+
+#if defined(_NETBSD_SOURCE)
+/*
+ * Based on the configuration parameters described in an SVR2 (yes, two)
+ * config(1m) man page.
+ *
+ * Each message is broken up and stored in segments that are msgssz bytes
+ * long. For efficiency reasons, this should be a power of two. Also,
+ * it doesn't make sense if it is less than 8 or greater than about 256.
+ * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
+ * two between 8 and 1024 inclusive (and panic's if it isn't).
+ */
+struct msginfo {
+ int32_t msgmax; /* max chars in a message */
+ int32_t msgmni; /* max message queue identifiers */
+ int32_t msgmnb; /* max chars in a queue */
+ int32_t msgtql; /* max messages in system */
+ int32_t msgssz; /* size of a message segment
+ (see notes above) */
+ int32_t msgseg; /* number of message segments */
+};
+
+/* Warning: 64-bit structure padding is needed here */
+struct msgid_ds_sysctl {
+ struct ipc_perm_sysctl msg_perm;
+ uint64_t msg_qnum;
+ uint64_t msg_qbytes;
+ uint64_t _msg_cbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ time_t msg_stime;
+ time_t msg_rtime;
+ time_t msg_ctime;
+ int32_t pad;
+};
+struct msg_sysctl_info {
+ struct msginfo msginfo;
+ struct msgid_ds_sysctl msgids[1];
+};
+#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
+
+#ifdef _KERNEL
+
+#ifndef MSGSSZ
+#define MSGSSZ 8 /* Each segment must be 2^N long */
+#endif
+#ifndef MSGSEG
+#define MSGSEG 2048 /* must be less than 32767 */
+#endif
+#undef MSGMAX /* ALWAYS compute MGSMAX! */
+#define MSGMAX (MSGSSZ*MSGSEG)
+#ifndef MSGMNB
+#define MSGMNB 2048 /* max # of bytes in a queue */
+#endif
+#ifndef MSGMNI
+#define MSGMNI 40
+#endif
+#ifndef MSGTQL
+#define MSGTQL 40
+#endif
+
+/*
+ * macros to convert between msqid_ds's and msqid's.
+ */
+#define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm._seq << 16) & 0xffff0000))
+#define MSQID_IX(id) ((id) & 0xffff)
+#define MSQID_SEQ(id) (((id) >> 16) & 0xffff)
+
+/*
+ * Stuff allocated in machdep.h
+ */
+struct msgmap {
+ short next; /* next segment in buffer */
+ /* -1 -> available */
+ /* 0..(MSGSEG-1) -> index of next segment */
+};
+
+typedef struct kmsq {
+ struct msqid_ds msq_u;
+ kcondvar_t msq_cv;
+} kmsq_t;
+
+extern struct msginfo msginfo;
+extern kmsq_t *msqs; /* MSGMNI queues */
+extern kmutex_t msgmutex;
+
+#define MSG_LOCKED 01000 /* Is this msqid_ds locked? */
+
+#define SYSCTL_FILL_MSG(src, dst) do { \
+ SYSCTL_FILL_PERM((src).msg_perm, (dst).msg_perm); \
+ (dst).msg_qnum = (src).msg_qnum; \
+ (dst).msg_qbytes = (src).msg_qbytes; \
+ (dst)._msg_cbytes = (src)._msg_cbytes; \
+ (dst).msg_lspid = (src).msg_lspid; \
+ (dst).msg_lrpid = (src).msg_lrpid; \
+ (dst).msg_stime = (src).msg_stime; \
+ (dst).msg_rtime = (src).msg_rtime; \
+ (dst).msg_ctime = (src).msg_ctime; \
+} while (/*CONSTCOND*/ 0)
+
+#endif /* _KERNEL */
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int msgctl(int, int, struct msqid_ds *) __RENAME(__msgctl50);
+int msgget(key_t, int);
+int msgsnd(int, const void *, size_t, int);
+ssize_t msgrcv(int, void *, size_t, long, int);
+__END_DECLS
+#else
+#include <sys/systm.h>
+
+struct proc;
+
+void msginit(void);
+int msgctl1(struct lwp *, int, int, struct msqid_ds *);
+int msgsnd1(struct lwp *, int, const char *, size_t, int, size_t,
+ copyin_t);
+int msgrcv1(struct lwp *, int, char *, size_t, long, int, size_t,
+ copyout_t, register_t *);
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_MSG_H_ */
--- /dev/null
+/* $NetBSD: msgbuf.h,v 1.15 2007/11/07 00:19:08 ad Exp $ */
+
+/*
+ * Copyright (c) 1981, 1984, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_MSGBUF_H_
+#define _SYS_MSGBUF_H_
+
+struct kern_msgbuf {
+#define MSG_MAGIC 0x063061
+ long msg_magic;
+ long msg_bufx; /* write pointer */
+ long msg_bufr; /* read pointer */
+ long msg_bufs; /* real msg_bufc size (bytes) */
+ char msg_bufc[1]; /* buffer */
+};
+
+#ifdef _KERNEL
+extern int msgbufmapped; /* is the message buffer mapped */
+extern int msgbufenabled; /* is logging to the buffer enabled */
+extern struct kern_msgbuf *msgbufp; /* the mapped buffer, itself. */
+
+void initmsgbuf(void *, size_t);
+void loginit(void);
+void logputchar(int);
+#endif
+
+#endif /* !_SYS_MSGBUF_H_ */
--- /dev/null
+/* $NetBSD: namei.h,v 1.82 2012/10/13 17:47:11 dholland Exp $ */
+
+
+/*
+ * WARNING: GENERATED FILE. DO NOT EDIT
+ * (edit namei.src and run make namei in src/sys/sys)
+ * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp
+ * from: NetBSD: namei.src,v 1.27 2012/10/13 17:46:50 dholland Exp
+ */
+
+/*
+ * Copyright (c) 1985, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)namei.h 8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef _SYS_NAMEI_H_
+#define _SYS_NAMEI_H_
+
+#include <sys/queue.h>
+#include <sys/mutex.h>
+
+#ifdef _KERNEL
+#include <sys/kauth.h>
+
+/*
+ * Abstraction for a single pathname.
+ *
+ * This contains both the pathname string and (eventually) all
+ * metadata that determines how the path is to be interpreted.
+ * It is an opaque structure; the implementation is in vfs_lookup.c.
+ *
+ * To call namei, first set up a pathbuf with pathbuf_create or
+ * pathbuf_copyin, then do NDINIT(), then call namei, then AFTER THE
+ * STRUCT NAMEIDATA IS DEAD, call pathbuf_destroy. Don't destroy the
+ * pathbuf before you've finished using the nameidata, or mysterious
+ * bad things may happen.
+ *
+ * pathbuf_assimilate is like pathbuf_create but assumes ownership of
+ * the string buffer passed in, which MUST BE of size PATH_MAX and
+ * have been allocated with PNBUF_GET(). This should only be used when
+ * absolutely necessary; e.g. nfsd uses it for loading paths from
+ * mbufs.
+ */
+struct pathbuf;
+
+struct pathbuf *pathbuf_create(const char *path);
+struct pathbuf *pathbuf_assimilate(char *path);
+int pathbuf_copyin(const char *userpath, struct pathbuf **ret);
+void pathbuf_destroy(struct pathbuf *);
+
+/* get a copy of the (current) path string */
+void pathbuf_copystring(const struct pathbuf *, char *buf, size_t maxlen);
+
+/* hold a reference copy of the original path string */
+const char *pathbuf_stringcopy_get(struct pathbuf *);
+void pathbuf_stringcopy_put(struct pathbuf *, const char *);
+
+// XXX remove this
+int pathbuf_maybe_copyin(const char *userpath, enum uio_seg seg, struct pathbuf **ret);
+
+/*
+ * Encapsulation of namei parameters.
+ */
+struct nameidata {
+ /*
+ * Arguments to namei/lookup.
+ */
+ struct vnode *ni_startdir; /* starting dir, cwd if null */
+ struct pathbuf *ni_pathbuf; /* pathname container */
+ char *ni_pnbuf; /* extra pathname buffer ref (XXX) */
+ /*
+ * Arguments to lookup.
+ */
+ struct vnode *ni_rootdir; /* logical root directory */
+ struct vnode *ni_erootdir; /* emulation root directory */
+ /*
+ * Results: returned from/manipulated by lookup
+ */
+ struct vnode *ni_vp; /* vnode of result */
+ struct vnode *ni_dvp; /* vnode of intermediate directory */
+ /*
+ * Shared between namei and lookup/commit routines.
+ */
+ size_t ni_pathlen; /* remaining chars in path */
+ const char *ni_next; /* next location in pathname */
+ unsigned int ni_loopcnt; /* count of symlinks encountered */
+ /*
+ * Lookup parameters: this structure describes the subset of
+ * information from the nameidata structure that is passed
+ * through the VOP interface.
+ */
+ struct componentname {
+ /*
+ * Arguments to lookup.
+ */
+ uint32_t cn_nameiop; /* namei operation */
+ uint32_t cn_flags; /* flags to namei */
+ kauth_cred_t cn_cred; /* credentials */
+ /*
+ * Shared between lookup and commit routines.
+ */
+ const char *cn_nameptr; /* pointer to looked up name */
+ size_t cn_namelen; /* length of looked up comp */
+ u_long cn_hash; /* hash val of looked up name */
+ size_t cn_consume; /* chars to consume in lookup */
+ } ni_cnd;
+};
+
+/*
+ * namei operations
+ */
+#define LOOKUP 0 /* perform name lookup only */
+#define CREATE 1 /* setup for file creation */
+#define DELETE 2 /* setup for file deletion */
+#define RENAME 3 /* setup for file renaming */
+#define OPMASK 3 /* mask for operation */
+/*
+ * namei operational modifier flags, stored in ni_cnd.cn_flags
+ */
+#define LOCKLEAF 0x00000004 /* lock inode on return */
+#define LOCKPARENT 0x00000008 /* want parent vnode returned locked */
+#define TRYEMULROOT 0x00000010 /* try relative to emulation root
+ first */
+#define NOCACHE 0x00000020 /* name must not be left in cache */
+#define FOLLOW 0x00000040 /* follow symbolic links */
+#define NOFOLLOW 0x00000000 /* do not follow symbolic links
+ (pseudo) */
+#define EMULROOTSET 0x00000080 /* emulation root already
+ in ni_erootdir */
+#define NOCHROOT 0x01000000 /* no chroot on abs path lookups */
+#define MODMASK 0x010000fc /* mask of operational modifiers */
+/*
+ * Namei parameter descriptors.
+ */
+#define NOCROSSMOUNT 0x0000100 /* do not cross mount points */
+#define RDONLY 0x0000200 /* lookup with read-only semantics */
+#define ISDOTDOT 0x0002000 /* current component name is .. */
+#define MAKEENTRY 0x0004000 /* entry is to be added to name cache */
+#define ISLASTCN 0x0008000 /* this is last component of pathname */
+#define ISWHITEOUT 0x0020000 /* found whiteout */
+#define DOWHITEOUT 0x0040000 /* do whiteouts */
+#define REQUIREDIR 0x0080000 /* must be a directory */
+#define CREATEDIR 0x0200000 /* trailing slashes are ok */
+#define INRENAME 0x0400000 /* operation is a part of ``rename'' */
+#define INRELOOKUP 0x0800000 /* set while inside relookup() */
+#define PARAMASK 0x0eee300 /* mask of parameter descriptors */
+
+/*
+ * Initialization of a nameidata structure.
+ */
+#define NDINIT(ndp, op, flags, pathbuf) { \
+ (ndp)->ni_cnd.cn_nameiop = op; \
+ (ndp)->ni_cnd.cn_flags = flags; \
+ (ndp)->ni_startdir = NULL; \
+ (ndp)->ni_pathbuf = pathbuf; \
+ (ndp)->ni_cnd.cn_cred = kauth_cred_get(); \
+}
+
+/*
+ * Use this to set the start directory for openat()-type operations.
+ */
+#define NDAT(ndp, dir) { \
+ (ndp)->ni_startdir = (dir); \
+}
+
+#endif
+
+/*
+ * This structure describes the elements in the cache of recent
+ * names looked up by namei. NCHNAMLEN is sized to make structure
+ * size a power of two to optimize allocations. Minimum reasonable
+ * size is 15.
+ */
+
+#define NCHNAMLEN 31 /* maximum name segment length we bother with */
+
+/*
+ * Namecache entry. This structure is arranged so that frequently
+ * accessed and mostly read-only data is toward the front, with
+ * infrequently accessed data and the lock towards the rear. The
+ * lock is then more likely to be in a seperate cache line.
+ */
+struct namecache {
+ LIST_ENTRY(namecache) nc_hash; /* hash chain */
+ LIST_ENTRY(namecache) nc_vhash; /* directory hash chain */
+ struct vnode *nc_dvp; /* vnode of parent of name */
+ struct vnode *nc_vp; /* vnode the name refers to */
+ int nc_flags; /* copy of componentname's ISWHITEOUT */
+ char nc_nlen; /* length of name */
+ char nc_name[NCHNAMLEN]; /* segment name */
+ void *nc_gcqueue; /* queue for garbage collection */
+ TAILQ_ENTRY(namecache) nc_lru; /* psuedo-lru chain */
+ LIST_ENTRY(namecache) nc_dvlist;
+ LIST_ENTRY(namecache) nc_vlist;
+ kmutex_t nc_lock; /* lock on this entry */
+ int nc_hittime; /* last time scored a hit */
+};
+
+#ifdef _KERNEL
+#include <sys/pool.h>
+
+struct mount;
+struct cpu_info;
+
+extern pool_cache_t pnbuf_cache; /* pathname buffer cache */
+
+#define PNBUF_GET() pool_cache_get(pnbuf_cache, PR_WAITOK)
+#define PNBUF_PUT(pnb) pool_cache_put(pnbuf_cache, (pnb))
+
+/*
+ * Typesafe flags for namei_simple.
+ *
+ * This encoding is not optimal but serves the important purpose of
+ * not being type-compatible with the regular namei flags.
+ */
+struct namei_simple_flags_type; /* Opaque. */
+typedef const struct namei_simple_flags_type *namei_simple_flags_t; /* Gross. */
+extern const namei_simple_flags_t
+ NSM_NOFOLLOW_NOEMULROOT,
+ NSM_NOFOLLOW_TRYEMULROOT,
+ NSM_FOLLOW_NOEMULROOT,
+ NSM_FOLLOW_TRYEMULROOT;
+
+/*
+ * namei_simple_* - the simple cases of namei, with no struct
+ * nameidata involved.
+ *
+ * namei_simple_kernel takes a kernel-space path as the first argument.
+ * namei_simple_user takes a user-space path as the first argument.
+ *
+ * A namei call can be converted to namei_simple_* if:
+ * - the second arg to NDINIT is LOOKUP;
+ * - it does not need the parent vnode, nd.ni_dvp;
+ * - the only flags it uses are (NO)FOLLOW and TRYEMULROOT;
+ * - it does not do anything else gross with the contents of nd.
+ */
+int namei_simple_kernel(const char *, namei_simple_flags_t, struct vnode **);
+int namei_simple_user(const char *, namei_simple_flags_t, struct vnode **);
+
+int namei(struct nameidata *);
+uint32_t namei_hash(const char *, const char **);
+int lookup_for_nfsd(struct nameidata *, struct vnode *, int neverfollow);
+int lookup_for_nfsd_index(struct nameidata *, struct vnode *);
+int relookup(struct vnode *, struct vnode **, struct componentname *, int);
+void cache_purge1(struct vnode *, const struct componentname *, int);
+#define PURGE_PARENTS 1
+#define PURGE_CHILDREN 2
+#define cache_purge(vp) cache_purge1((vp), NULL, PURGE_PARENTS|PURGE_CHILDREN)
+int cache_lookup(struct vnode *, struct vnode **, struct componentname *);
+int cache_lookup_raw(struct vnode *, struct vnode **,
+ struct componentname *);
+int cache_revlookup(struct vnode *, struct vnode **, char **, char *);
+void cache_enter(struct vnode *, struct vnode *, struct componentname *);
+void nchinit(void);
+void nchreinit(void);
+void cache_cpu_init(struct cpu_info *);
+void cache_purgevfs(struct mount *);
+void namecache_print(struct vnode *, void (*)(const char *, ...)
+ __printflike(1, 2));
+
+#endif
+
+/*
+ * Stats on usefulness of namei caches.
+ * XXX: should be 64-bit counters.
+ */
+struct nchstats {
+ long ncs_goodhits; /* hits that we can really use */
+ long ncs_neghits; /* negative hits that we can use */
+ long ncs_badhits; /* hits we must drop */
+ long ncs_falsehits; /* hits with id mismatch */
+ long ncs_miss; /* misses */
+ long ncs_long; /* long names that ignore cache */
+ long ncs_pass2; /* names found with passes == 2 */
+ long ncs_2passes; /* number of times we attempt it */
+ long ncs_revhits; /* reverse-cache hits */
+ long ncs_revmiss; /* reverse-cache misses */
+};
+
+#ifdef _KERNEL
+extern struct nchstats nchstats;
+#endif
+/* #endif !_SYS_NAMEI_H_ (generated by gennameih.awk) */
+
+/* Definitions match above, but with NAMEI_ prefix */
+#define NAMEI_LOOKUP 0
+#define NAMEI_CREATE 1
+#define NAMEI_DELETE 2
+#define NAMEI_RENAME 3
+#define NAMEI_OPMASK 3
+#define NAMEI_LOCKLEAF 0x00000004
+#define NAMEI_LOCKPARENT 0x00000008
+#define NAMEI_TRYEMULROOT 0x00000010
+#define NAMEI_NOCACHE 0x00000020
+#define NAMEI_FOLLOW 0x00000040
+#define NAMEI_NOFOLLOW 0x00000000
+#define NAMEI_EMULROOTSET 0x00000080
+#define NAMEI_NOCHROOT 0x01000000
+#define NAMEI_MODMASK 0x010000fc
+#define NAMEI_NOCROSSMOUNT 0x0000100
+#define NAMEI_RDONLY 0x0000200
+#define NAMEI_ISDOTDOT 0x0002000
+#define NAMEI_MAKEENTRY 0x0004000
+#define NAMEI_ISLASTCN 0x0008000
+#define NAMEI_ISWHITEOUT 0x0020000
+#define NAMEI_DOWHITEOUT 0x0040000
+#define NAMEI_REQUIREDIR 0x0080000
+#define NAMEI_CREATEDIR 0x0200000
+#define NAMEI_INRENAME 0x0400000
+#define NAMEI_INRELOOKUP 0x0800000
+#define NAMEI_PARAMASK 0x0eee300
+
+#endif /* !_SYS_NAMEI_H_ */
--- /dev/null
+/* $NetBSD: once.h,v 1.5 2008/10/09 10:48:21 pooka Exp $ */
+
+/*-
+ * Copyright (c)2005 YAMAMOTO Takashi,
+ * Copyright (c)2008 Antti Kantee,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_ONCE_H_
+#define _SYS_ONCE_H_
+
+typedef struct {
+ unsigned o_status;
+ int o_error;
+#define ONCE_VIRGIN 0
+#define ONCE_RUNNING 1
+#define ONCE_DONE 2
+} once_t;
+
+void once_init(void);
+int _run_once(once_t *, int (*)(void));
+
+#define ONCE_DECL(o) \
+ once_t (o) = { \
+ .o_status = 0, \
+ };
+
+#define RUN_ONCE(o, fn) \
+ (__predict_true((o)->o_status == ONCE_DONE) ? \
+ ((o)->o_error) : _run_once((o), (fn)))
+
+#endif /* _SYS_ONCE_H_ */
--- /dev/null
+/* $NetBSD: optstr.h,v 1.3 2008/04/28 20:24:11 martin Exp $ */
+
+/*-
+ * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julio M. Merino Vidal.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_OPTSTR_H_)
+#define _SYS_OPTSTR_H_
+
+/*
+ * Prototypes for functions defined in sys/kern/subr_optstr.c.
+ */
+bool optstr_get(const char *, const char *, char *, size_t);
+
+#endif /* !defined(_SYS_OPTSTR_H_) */
--- /dev/null
+/* $NetBSD: pax.h,v 1.11 2007/12/27 15:21:53 elad Exp $ */
+
+/*-
+ * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PAX_H_
+#define _SYS_PAX_H_
+
+#include <uvm/uvm_extern.h>
+
+struct lwp;
+struct exec_package;
+struct vmspace;
+
+#ifdef PAX_ASLR
+/*
+ * We stick this here because we need it in kern/exec_elf32.c for now.
+ */
+#ifndef PAX_ASLR_DELTA_EXEC_LEN
+#define PAX_ASLR_DELTA_EXEC_LEN 12
+#endif
+#endif /* PAX_ASLR */
+
+void pax_init(void);
+void pax_adjust(struct lwp *, uint32_t);
+
+void pax_mprotect(struct lwp *, vm_prot_t *, vm_prot_t *);
+int pax_segvguard(struct lwp *, struct vnode *, const char *, bool);
+
+#define PAX_ASLR_DELTA(delta, lsb, len) \
+ (((delta) & ((1UL << (len)) - 1)) << (lsb))
+bool pax_aslr_active(struct lwp *);
+void pax_aslr_init(struct lwp *, struct vmspace *);
+void pax_aslr_stack(struct lwp *, struct exec_package *, u_long *);
+void pax_aslr(struct lwp *, vaddr_t *, vaddr_t, int);
+
+#endif /* !_SYS_PAX_H_ */
--- /dev/null
+/* $NetBSD: pcq.h,v 1.1 2008/11/11 20:17:27 matt Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PCQ_H_
+#define _SYS_PCQ_H_
+
+#include <sys/kmem.h>
+
+typedef struct pcq pcq_t;
+
+#ifdef _KERNEL
+bool pcq_put(pcq_t *, void *);
+void * pcq_peek(pcq_t *);
+void * pcq_get(pcq_t *);
+size_t pcq_maxitems(pcq_t *);
+pcq_t * pcq_create(size_t, km_flag_t);
+void pcq_destroy(pcq_t *);
+#endif /* _KERNEL */
+
+#endif /* _SYS_PCQ_H_ */
+
--- /dev/null
+/* $NetBSD: pcu.h,v 1.9 2012/04/18 13:42:11 yamt Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mindaugas Rasiukevicius.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PCU_H_
+#define _SYS_PCU_H_
+
+#if !defined(_KERNEL) && !defined(_KMEMUSER)
+#error "not supposed to be exposed to userland"
+#endif
+
+#ifndef _KERNEL
+#include <stdbool.h>
+#endif
+
+/*
+ * Default: no PCU for MD.
+ */
+#ifndef PCU_UNIT_COUNT
+#define PCU_UNIT_COUNT 0
+#endif
+
+#if PCU_UNIT_COUNT > 0
+
+/*
+ * pcu_state_save(lwp)
+ * save the current CPU's state into the given LWP's MD storage.
+ *
+ * pcu_state_load(lwp, used)
+ * load PCU state from the given LWP's MD storage to the current CPU.
+ * the 'used' argument is true if it isn't the first time the LWP uses
+ * the PCU.
+ *
+ * pcu_state_release(lwp)
+ * tell MD code detect the next use of the PCU on the LWP, and call
+ * pcu_load().
+ */
+
+typedef struct {
+ u_int pcu_id;
+ void (*pcu_state_save)(lwp_t *);
+ void (*pcu_state_load)(lwp_t *, bool);
+ void (*pcu_state_release)(lwp_t *);
+} pcu_ops_t;
+
+void pcu_switchpoint(lwp_t *);
+void pcu_discard_all(lwp_t *);
+void pcu_save_all(lwp_t *);
+
+void pcu_load(const pcu_ops_t *);
+void pcu_save(const pcu_ops_t *);
+void pcu_discard(const pcu_ops_t *);
+bool pcu_used_p(const pcu_ops_t *);
+
+#else
+#define pcu_switchpoint(l)
+#define pcu_discard_all(l)
+#define pcu_save_all(l)
+#endif
+
+#endif
--- /dev/null
+/* $NetBSD: percpu.h,v 1.3 2008/04/09 05:11:20 thorpej Exp $ */
+
+/*-
+ * Copyright (c)2007,2008 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PERCPU_H_
+#define _SYS_PERCPU_H_
+
+#include <sys/percpu_types.h>
+
+void percpu_init(void);
+void percpu_init_cpu(struct cpu_info *);
+percpu_t *percpu_alloc(size_t);
+void percpu_free(percpu_t *, size_t);
+void *percpu_getref(percpu_t *);
+void percpu_putref(percpu_t *);
+
+typedef void (*percpu_callback_t)(void *, void *, struct cpu_info *);
+void percpu_foreach(percpu_t *, percpu_callback_t, void *);
+
+/* low-level api; don't use unless necessary */
+void percpu_traverse_enter(void);
+void percpu_traverse_exit(void);
+void *percpu_getptr_remote(percpu_t *, struct cpu_info *);
+
+#endif /* _SYS_PERCPU_H_ */
--- /dev/null
+/* $NetBSD: percpu_types.h,v 1.1 2008/01/14 12:40:02 yamt Exp $ */
+
+/*-
+ * Copyright (c)2007,2008 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PERCPU_TYPES_H_
+#define _SYS_PERCPU_TYPES_H_
+
+#include <sys/types.h>
+
+struct cpu_info;
+typedef struct percpu percpu_t;
+
+typedef struct percpu_cpu {
+ size_t pcc_size;
+ void *pcc_data;
+} percpu_cpu_t;
+
+#endif /* _SYS_PERCPU_TYPES_H_ */
--- /dev/null
+/* $NetBSD: pipe.h,v 1.32 2009/12/20 09:36:06 dsl Exp $ */
+
+/*
+ * Copyright (c) 1996 John S. Dyson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Absolutely no warranty of function or purpose is made by the author
+ * John S. Dyson.
+ * 4. This work was done expressly for inclusion into FreeBSD. Other use
+ * is allowed if this notation is included.
+ * 5. Modifications may be freely made to this file if the above conditions
+ * are met.
+ *
+ * $FreeBSD: src/sys/sys/pipe.h,v 1.18 2002/02/27 07:35:59 alfred Exp $
+ */
+
+#ifndef _SYS_PIPE_H_
+#define _SYS_PIPE_H_
+
+#include <sys/selinfo.h> /* for struct selinfo */
+
+#include <uvm/uvm_extern.h>
+
+/*
+ * Pipe buffer size, keep moderate in value, pipes take kva space.
+ */
+#ifndef PIPE_SIZE
+#define PIPE_SIZE 16384
+#endif
+
+#ifndef BIG_PIPE_SIZE
+#define BIG_PIPE_SIZE (4*PIPE_SIZE)
+#endif
+
+/*
+ * Maximum size of kva for direct write transfer. If the amount
+ * of data in buffer is larger, it would be transferred in chunks of this
+ * size. This kva memory is freed after use if amount of pipe kva memory
+ * is bigger than limitpipekva.
+ */
+#ifndef PIPE_DIRECT_CHUNK
+#define PIPE_DIRECT_CHUNK (1*1024*1024)
+#endif
+
+/*
+ * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
+ * than PIPE_BUF.
+ */
+#ifndef PIPE_MINDIRECT
+#define PIPE_MINDIRECT 8192
+#endif
+
+/*
+ * Pipe buffer information.
+ * Separate in, out, cnt are used to simplify calculations.
+ * Buffered write is active when the buffer.cnt field is set.
+ */
+struct pipebuf {
+ size_t cnt; /* number of chars currently in buffer */
+ u_int in; /* in pointer */
+ u_int out; /* out pointer */
+ size_t size; /* size of buffer */
+ void * buffer; /* kva of buffer */
+};
+
+/*
+ * Information to support direct transfers between processes for pipes.
+ */
+struct pipemapping {
+ vaddr_t kva; /* kernel virtual address */
+ vsize_t cnt; /* number of chars in buffer */
+ voff_t pos; /* current position within page */
+ int npages; /* how many pages allocated */
+ struct vm_page **pgs; /* pointers to the pages */
+ u_int egen; /* emap generation number */
+};
+
+/*
+ * Bits in pipe_state.
+ */
+#define PIPE_ASYNC 0x001 /* Async I/O */
+#define PIPE_EOF 0x010 /* Pipe is in EOF condition */
+#define PIPE_SIGNALR 0x020 /* Do selwakeup() on read(2) */
+#define PIPE_DIRECTW 0x040 /* Pipe in direct write mode setup */
+#define PIPE_DIRECTR 0x080 /* Pipe direct read request (setup complete) */
+#define PIPE_LOCKFL 0x100 /* Process has exclusive access to
+ pointers/data. */
+#define PIPE_LWANT 0x200 /* Process wants exclusive access to
+ pointers/data. */
+#define PIPE_RESTART 0x400 /* Return ERESTART to blocked syscalls */
+
+/*
+ * Per-pipe data structure.
+ * Two of these are linked together to produce bi-directional pipes.
+ */
+struct pipe {
+ kmutex_t *pipe_lock; /* pipe mutex */
+ kcondvar_t pipe_rcv; /* cv for readers */
+ kcondvar_t pipe_wcv; /* cv for writers */
+ kcondvar_t pipe_draincv; /* cv for close */
+ kcondvar_t pipe_lkcv; /* locking */
+ struct pipebuf pipe_buffer; /* data storage */
+ struct pipemapping pipe_map; /* pipe mapping for direct I/O */
+ struct selinfo pipe_sel; /* for compat with select */
+ struct timespec pipe_atime; /* time of last access */
+ struct timespec pipe_mtime; /* time of last modify */
+ struct timespec pipe_btime; /* time of creation */
+ pid_t pipe_pgid; /* process group for sigio */
+ struct pipe *pipe_peer; /* link with other direction */
+ u_int pipe_state; /* pipe status info */
+ int pipe_busy; /* busy flag, to handle rundown */
+ vaddr_t pipe_kmem; /* preallocated PIPE_SIZE buffer */
+};
+
+/*
+ * KERN_PIPE subtypes
+ */
+#define KERN_PIPE_MAXKVASZ 1 /* maximum kva size */
+#define KERN_PIPE_LIMITKVA 2 /* */
+#define KERN_PIPE_MAXBIGPIPES 3 /* maximum # of "big" pipes */
+#define KERN_PIPE_NBIGPIPES 4 /* current number of "big" p. */
+#define KERN_PIPE_KVASIZE 5 /* current pipe kva size */
+#define KERN_PIPE_MAXID 6
+
+#define CTL_PIPE_NAMES { \
+ { 0, 0 }, \
+ { "maxkvasz", CTLTYPE_INT }, \
+ { "maxloankvasz", CTLTYPE_INT }, \
+ { "maxbigpipes", CTLTYPE_INT }, \
+ { "nbigpipes", CTLTYPE_INT }, \
+ { "kvasize", CTLTYPE_INT }, \
+}
+
+#ifdef _KERNEL
+int sysctl_dopipe(int *, u_int, void *, size_t *, void *, size_t);
+void pipe_init(void);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_PIPE_H_ */
--- /dev/null
+/* $NetBSD: pmc.h,v 1.5 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Copyright (c) 2002 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Allen Briggs for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PMC_H_
+#define _SYS_PMC_H_
+
+struct pmc_counter_cfg {
+ pmc_evid_t event_id; /* What event to configure */
+ pmc_ctr_t reset_value; /* Value to set counter to */
+ uint32_t flags; /* PMC_FLAG_* */
+};
+
+#if defined(_KERNEL)
+
+/*
+ * The following functions are defined in machine/pmc.h as either
+ * functions or macros.
+ *
+ * int pmc_get_num_counters(void);
+ * int pmc_get_counter_type(int ctr);
+ *
+ * void pmc_save_context(struct proc *p);
+ * void pmc_restore_context(struct proc *p);
+ * void pmc_process_exit(struct proc *p);
+ *
+ * int pmc_enable_counter(struct proc *p, int ctr);
+ * int pmc_disable_counter(struct proc *p, int ctr);
+ * int pmc_counter_isrunning(struct proc *p, int ctr);
+ * int pmc_counter_isconfigured(struct proc *p, int ctr);
+ *
+ * int pmc_configure_counter(struct proc *p, int ctr, pmc_counter_cfg *cfg);
+ *
+ * int pmc_get_counter_value(struct proc *p, int ctr, int flags,
+ * uint64_t *pval);
+ *
+ * int pmc_accumulate(struct proc *p_parent, struct proc *p_exiting);
+ *
+ * int pmc_alloc_kernel_counter(int ctr, struct pmc_counter_cfg *cfg);
+ * int pmc_free_kernel_counter(int ctr);
+ *
+ * int pmc_start_profiling(int ctr, struct pmc_counter_cfg *cfg);
+ * int pmc_stop_profiling(int ctr);
+ *
+ * int PMC_ENABLED(struct proc *p);
+ */
+
+#define PMC_VALUE_FLAGS_CHILDREN 0x00000001
+
+#endif /* _KERNEL */
+
+#include <machine/pmc.h>
+
+#define PMC_OP_START 1
+#define PMC_OP_STOP 2
+#define PMC_OP_CONFIGURE 3
+#define PMC_OP_PROFSTART 4
+#define PMC_OP_PROFSTOP 5
+int pmc_control(int ctr, int operation, void *args);
+
+#define PMC_INFO_NCOUNTERS 1
+#define PMC_INFO_CPUCTR_TYPE 2
+#define PMC_INFO_COUNTER_VALUE 3
+#define PMC_INFO_ACCUMULATED_COUNTER_VALUE 4
+int pmc_get_info(int ctr, int request, void *data);
+
+#endif /* !_SYS_PMC_H_ */
--- /dev/null
+/* $NetBSD: pmf.h,v 1.18 2010/02/24 22:38:10 dyoung Exp $ */
+
+/*-
+ * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PMF_H
+#define _SYS_PMF_H
+
+#ifdef _KERNEL
+
+#include <sys/types.h>
+#include <sys/device_if.h>
+
+typedef enum {
+ PMFE_DISPLAY_ON,
+ PMFE_DISPLAY_REDUCED,
+ PMFE_DISPLAY_STANDBY,
+ PMFE_DISPLAY_SUSPEND,
+ PMFE_DISPLAY_OFF,
+ PMFE_DISPLAY_BRIGHTNESS_UP,
+ PMFE_DISPLAY_BRIGHTNESS_DOWN,
+ PMFE_AUDIO_VOLUME_UP,
+ PMFE_AUDIO_VOLUME_DOWN,
+ PMFE_AUDIO_VOLUME_TOGGLE,
+ PMFE_CHASSIS_LID_CLOSE,
+ PMFE_CHASSIS_LID_OPEN
+} pmf_generic_event_t;
+
+struct pmf_qual {
+ const device_suspensor_t *pq_suspensor;
+ devact_level_t pq_actlvl;
+};
+
+typedef struct pmf_qual pmf_qual_t;
+extern const pmf_qual_t * const PMF_Q_NONE;
+extern const pmf_qual_t * const PMF_Q_SELF;
+extern const pmf_qual_t * const PMF_Q_DRVCTL;
+
+extern const device_suspensor_t
+ * const device_suspensor_self,
+ * const device_suspensor_system,
+ * const device_suspensor_drvctl;
+
+void pmf_init(void);
+
+bool pmf_event_inject(device_t, pmf_generic_event_t);
+bool pmf_event_register(device_t, pmf_generic_event_t,
+ void (*)(device_t), bool);
+void pmf_event_deregister(device_t, pmf_generic_event_t,
+ void (*)(device_t), bool);
+
+bool pmf_set_platform(const char *, const char *);
+const char *pmf_get_platform(const char *);
+
+bool pmf_system_resume(const pmf_qual_t *);
+bool pmf_system_bus_resume(const pmf_qual_t *);
+bool pmf_system_suspend(const pmf_qual_t *);
+void pmf_system_shutdown(int);
+
+bool pmf_device_register1(device_t,
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, const pmf_qual_t *),
+ bool (*)(device_t, int));
+/* compatibility */
+#define pmf_device_register(__d, __s, __r) \
+ pmf_device_register1((__d), (__s), (__r), NULL)
+
+void pmf_device_deregister(device_t);
+bool pmf_device_suspend(device_t, const pmf_qual_t *);
+bool pmf_device_resume(device_t, const pmf_qual_t *);
+
+bool pmf_device_recursive_suspend(device_t, const pmf_qual_t *);
+bool pmf_device_recursive_resume(device_t, const pmf_qual_t *);
+bool pmf_device_descendants_resume(device_t, const pmf_qual_t *);
+bool pmf_device_subtree_resume(device_t, const pmf_qual_t *);
+
+bool pmf_device_descendants_release(device_t, const pmf_qual_t *);
+bool pmf_device_subtree_release(device_t, const pmf_qual_t *);
+
+struct ifnet;
+void pmf_class_network_register(device_t, struct ifnet *);
+
+bool pmf_class_input_register(device_t);
+bool pmf_class_display_register(device_t);
+
+void pmf_qual_recursive_copy(pmf_qual_t *, const pmf_qual_t *);
+void pmf_self_suspensor_init(device_t, device_suspensor_t *,
+ pmf_qual_t *);
+
+static inline const device_suspensor_t *
+pmf_qual_suspension(const pmf_qual_t *pq)
+{
+ return pq->pq_suspensor;
+}
+
+static inline devact_level_t
+pmf_qual_depth(const pmf_qual_t *pq)
+{
+ return pq->pq_actlvl;
+}
+
+static inline bool
+pmf_qual_descend_ok(const pmf_qual_t *pq)
+{
+ return pq->pq_actlvl == DEVACT_LEVEL_FULL;
+}
+
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_PMF_H */
--- /dev/null
+/* $NetBSD: pool.h,v 1.75 2012/06/05 22:51:47 jym Exp $ */
+
+/*-
+ * Copyright (c) 1997, 1998, 1999, 2000, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg; by Jason R. Thorpe of the Numerical Aerospace
+ * Simulation Facility, NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_POOL_H_
+#define _SYS_POOL_H_
+
+#ifdef _KERNEL
+#define __POOL_EXPOSE
+#endif
+
+#ifdef __POOL_EXPOSE
+#include <sys/param.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+#include <sys/tree.h>
+#include <sys/callback.h>
+
+#define POOL_PADDR_INVALID ((paddr_t) -1)
+
+struct pool;
+
+struct pool_allocator {
+ void *(*pa_alloc)(struct pool *, int);
+ void (*pa_free)(struct pool *, void *);
+ unsigned int pa_pagesz;
+
+ /* The following fields are for internal use only. */
+ kmutex_t pa_lock;
+ TAILQ_HEAD(, pool) pa_list; /* list of pools using this allocator */
+ uint32_t pa_refcnt; /* number of pools using this allocator */
+ int pa_pagemask;
+ int pa_pageshift;
+};
+
+LIST_HEAD(pool_pagelist,pool_item_header);
+
+struct pool {
+ TAILQ_ENTRY(pool)
+ pr_poollist;
+ struct pool_pagelist
+ pr_emptypages; /* Empty pages */
+ struct pool_pagelist
+ pr_fullpages; /* Full pages */
+ struct pool_pagelist
+ pr_partpages; /* Partially-allocated pages */
+ struct pool_item_header *pr_curpage;
+ struct pool *pr_phpool; /* Pool item header pool */
+ struct pool_cache *pr_cache; /* Cache for this pool */
+ unsigned int pr_size; /* Size of item */
+ unsigned int pr_align; /* Requested alignment, must be 2^n */
+ unsigned int pr_itemoffset; /* Align this offset in item */
+ unsigned int pr_minitems; /* minimum # of items to keep */
+ unsigned int pr_minpages; /* same in page units */
+ unsigned int pr_maxpages; /* maximum # of pages to keep */
+ unsigned int pr_npages; /* # of pages allocated */
+ unsigned int pr_itemsperpage;/* # items that fit in a page */
+ unsigned int pr_slack; /* unused space in a page */
+ unsigned int pr_nitems; /* number of available items in pool */
+ unsigned int pr_nout; /* # items currently allocated */
+ unsigned int pr_hardlimit; /* hard limit to number of allocated
+ items */
+ unsigned int pr_refcnt; /* ref count for pagedaemon, etc */
+ struct pool_allocator *pr_alloc;/* back-end allocator */
+ TAILQ_ENTRY(pool) pr_alloc_list;/* link on allocator's pool list */
+
+ /* Drain hook. */
+ void (*pr_drain_hook)(void *, int);
+ void *pr_drain_hook_arg;
+
+ const char *pr_wchan; /* tsleep(9) identifier */
+ unsigned int pr_flags; /* r/w flags */
+ unsigned int pr_roflags; /* r/o flags */
+#define PR_WAITOK 0x01 /* Note: matches KM_SLEEP */
+#define PR_NOWAIT 0x02 /* Note: matches KM_NOSLEEP */
+#define PR_WANTED 0x04
+#define PR_PHINPAGE 0x40
+#define PR_LOGGING 0x80
+#define PR_LIMITFAIL 0x100 /* even if waiting, fail if we hit limit */
+#define PR_RECURSIVE 0x200 /* pool contains pools, for vmstat(8) */
+#define PR_NOTOUCH 0x400 /* don't use free items to keep internal state*/
+#define PR_NOALIGN 0x800 /* don't assume backend alignment */
+#define PR_LARGECACHE 0x1000 /* use large cache groups */
+
+ /*
+ * `pr_lock' protects the pool's data structures when removing
+ * items from or returning items to the pool, or when reading
+ * or updating read/write fields in the pool descriptor.
+ *
+ * We assume back-end page allocators provide their own locking
+ * scheme. They will be called with the pool descriptor _unlocked_,
+ * since the page allocators may block.
+ */
+ kmutex_t pr_lock;
+ kcondvar_t pr_cv;
+ int pr_ipl;
+
+ SPLAY_HEAD(phtree, pool_item_header) pr_phtree;
+
+ int pr_maxcolor; /* Cache colouring */
+ int pr_curcolor;
+ int pr_phoffset; /* Offset in page of page header */
+
+ /*
+ * Warning message to be issued, and a per-time-delta rate cap,
+ * if the hard limit is reached.
+ */
+ const char *pr_hardlimit_warning;
+ struct timeval pr_hardlimit_ratecap;
+ struct timeval pr_hardlimit_warning_last;
+
+ /*
+ * Instrumentation
+ */
+ unsigned long pr_nget; /* # of successful requests */
+ unsigned long pr_nfail; /* # of unsuccessful requests */
+ unsigned long pr_nput; /* # of releases */
+ unsigned long pr_npagealloc; /* # of pages allocated */
+ unsigned long pr_npagefree; /* # of pages released */
+ unsigned int pr_hiwat; /* max # of pages in pool */
+ unsigned long pr_nidle; /* # of idle pages */
+
+ /*
+ * Diagnostic aides.
+ */
+ void *pr_freecheck;
+ void *pr_qcache;
+};
+
+/*
+ * Cache group sizes, assuming 4-byte paddr_t on !_LP64.
+ * All groups will be aligned to CACHE_LINE_SIZE.
+ */
+#ifdef _LP64
+#define PCG_NOBJECTS_NORMAL 15 /* 256 byte group */
+#define PCG_NOBJECTS_LARGE 63 /* 1024 byte group */
+#else
+#define PCG_NOBJECTS_NORMAL 14 /* 124 byte group */
+#define PCG_NOBJECTS_LARGE 62 /* 508 byte group */
+#endif
+
+typedef struct pcgpair {
+ void *pcgo_va; /* object virtual address */
+ paddr_t pcgo_pa; /* object physical address */
+} pcgpair_t;
+
+/* The pool cache group. */
+typedef struct pool_cache_group {
+ struct pool_cache_group *pcg_next; /* link to next group */
+ u_int pcg_avail; /* # available objects */
+ u_int pcg_size; /* max number objects */
+ pcgpair_t pcg_objects[1]; /* the objects */
+} pcg_t;
+
+typedef struct pool_cache_cpu {
+ uint64_t cc_misses;
+ uint64_t cc_hits;
+ struct pool_cache_group *cc_current;
+ struct pool_cache_group *cc_previous;
+ struct pool_cache *cc_cache;
+ int cc_ipl;
+ int cc_cpuindex;
+#ifdef _KERNEL
+ ipl_cookie_t cc_iplcookie;
+#endif
+} pool_cache_cpu_t;
+
+struct pool_cache {
+ /* Pool layer. */
+ struct pool pc_pool;
+
+ /* Cache layer. */
+ kmutex_t pc_lock; /* locks cache layer */
+ TAILQ_ENTRY(pool_cache)
+ pc_cachelist; /* entry on global cache list */
+ pcg_t *pc_emptygroups;/* list of empty cache groups */
+ pcg_t *pc_fullgroups; /* list of full cache groups */
+ pcg_t *pc_partgroups; /* groups for reclamation */
+ struct pool *pc_pcgpool; /* Pool of cache groups */
+ int pc_pcgsize; /* Use large cache groups? */
+ int pc_ncpu; /* number cpus set up */
+ int (*pc_ctor)(void *, void *, int);
+ void (*pc_dtor)(void *, void *);
+ void *pc_arg; /* for ctor/ctor */
+ uint64_t pc_hits; /* cache layer hits */
+ uint64_t pc_misses; /* cache layer misses */
+ uint64_t pc_contended; /* contention events on cache */
+ unsigned int pc_nempty; /* empty groups in cache */
+ unsigned int pc_nfull; /* full groups in cache */
+ unsigned int pc_npart; /* partial groups in cache */
+ unsigned int pc_refcnt; /* ref count for pagedaemon, etc */
+ void *pc_freecheck;
+
+ /* CPU layer. */
+ pool_cache_cpu_t pc_cpu0 __aligned(CACHE_LINE_SIZE);
+ void *pc_cpus[MAXCPUS] __aligned(CACHE_LINE_SIZE);
+};
+
+#endif /* __POOL_EXPOSE */
+
+typedef struct pool_cache *pool_cache_t;
+
+#ifdef _KERNEL
+/*
+ * pool_allocator_kmem is the default that all pools get unless
+ * otherwise specified. pool_allocator_nointr is provided for
+ * pools that know they will never be accessed in interrupt
+ * context.
+ */
+extern struct pool_allocator pool_allocator_kmem;
+extern struct pool_allocator pool_allocator_nointr;
+extern struct pool_allocator pool_allocator_meta;
+#ifdef POOL_SUBPAGE
+/* The above are subpage allocators in this case. */
+extern struct pool_allocator pool_allocator_kmem_fullpage;
+extern struct pool_allocator pool_allocator_nointr_fullpage;
+#endif
+
+void pool_subsystem_init(void);
+
+void pool_init(struct pool *, size_t, u_int, u_int,
+ int, const char *, struct pool_allocator *, int);
+void pool_destroy(struct pool *);
+
+void pool_set_drain_hook(struct pool *,
+ void (*)(void *, int), void *);
+
+void *pool_get(struct pool *, int);
+void pool_put(struct pool *, void *);
+int pool_reclaim(struct pool *);
+
+int pool_prime(struct pool *, int);
+void pool_setlowat(struct pool *, int);
+void pool_sethiwat(struct pool *, int);
+void pool_sethardlimit(struct pool *, int, const char *, int);
+bool pool_drain(struct pool **);
+
+/*
+ * Debugging and diagnostic aides.
+ */
+void pool_printit(struct pool *, const char *,
+ void (*)(const char *, ...) __printflike(1, 2));
+void pool_printall(const char *, void (*)(const char *, ...)
+ __printflike(1, 2));
+int pool_chk(struct pool *, const char *);
+
+/*
+ * Pool cache routines.
+ */
+pool_cache_t pool_cache_init(size_t, u_int, u_int, u_int, const char *,
+ struct pool_allocator *, int, int (*)(void *, void *, int),
+ void (*)(void *, void *), void *);
+void pool_cache_bootstrap(pool_cache_t, size_t, u_int, u_int, u_int,
+ const char *, struct pool_allocator *, int,
+ int (*)(void *, void *, int), void (*)(void *, void *),
+ void *);
+void pool_cache_destroy(pool_cache_t);
+void pool_cache_bootstrap_destroy(pool_cache_t);
+void *pool_cache_get_paddr(pool_cache_t, int, paddr_t *);
+void pool_cache_put_paddr(pool_cache_t, void *, paddr_t);
+void pool_cache_destruct_object(pool_cache_t, void *);
+void pool_cache_invalidate(pool_cache_t);
+bool pool_cache_reclaim(pool_cache_t);
+void pool_cache_set_drain_hook(pool_cache_t,
+ void (*)(void *, int), void *);
+void pool_cache_setlowat(pool_cache_t, int);
+void pool_cache_sethiwat(pool_cache_t, int);
+void pool_cache_sethardlimit(pool_cache_t, int, const char *, int);
+void pool_cache_cpu_init(struct cpu_info *);
+
+#define pool_cache_get(pc, f) pool_cache_get_paddr((pc), (f), NULL)
+#define pool_cache_put(pc, o) pool_cache_put_paddr((pc), (o), \
+ POOL_PADDR_INVALID)
+
+void pool_whatis(uintptr_t, void (*)(const char *, ...)
+ __printflike(1, 2));
+#endif /* _KERNEL */
+
+#endif /* _SYS_POOL_H_ */
--- /dev/null
+/* $NetBSD: power.h,v 1.17 2012/07/15 18:31:35 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Definitions for power management.
+ */
+
+#ifndef _SYS_POWER_H_
+#define _SYS_POWER_H_
+
+#include <sys/ioccom.h>
+
+#ifndef _KERNEL
+#include <stdint.h>
+#endif
+
+/*
+ * Power Switches:
+ *
+ * Power switches are devices on the system that are used by the system
+ * operator to cause certain types of power management events to happen.
+ * This may be the closing of a laptop lid, the pressing of a power button,
+ * or some other type of user-initiated hardware event.
+ *
+ * We define the following types of power switches:
+ *
+ * Power button This is the "on/off" button on a system,
+ * or another button which provides a similar
+ * function. If there is no power management
+ * daemon present, an event on this button will
+ * cause a semi-graceful shutdown of the system
+ * to occur. This kind of button doesn't keep
+ * state; we only know (care) if an event occurs.
+ *
+ * Reset button This is the "reset" button on a system, or
+ * another button which provides a similar
+ * function. If there is no power management
+ * daemon present, an event on this button will
+ * cause a semi-graceful reboot of the system
+ * to occur. This kind of button doesn't keep
+ * state; we only know (care) if an event occurs.
+ *
+ * Sleep button This is a button which is dedicated to a
+ * "sleep" function. This kind of button doesn't
+ * keep state; we only know (care) if an event
+ * occurs.
+ *
+ * Lid switch This is e.g. the lid of a laptop. This kind
+ * of switch has state. We know if it is open
+ * or closed.
+ *
+ */
+
+#define PSWITCH_TYPE_POWER 0 /* power button */
+#define PSWITCH_TYPE_SLEEP 1 /* sleep button */
+#define PSWITCH_TYPE_LID 2 /* lid switch */
+#define PSWITCH_TYPE_RESET 3 /* reset button */
+#define PSWITCH_TYPE_ACADAPTER 4 /* AC adapter presence */
+#define PSWITCH_TYPE_HOTKEY 5 /* hotkey button */
+#define PSWITCH_HK_DISPLAY_CYCLE "display-cycle"
+#define PSWITCH_HK_LOCK_SCREEN "lock-screen"
+#define PSWITCH_HK_BATTERY_INFO "battery-info"
+#define PSWITCH_HK_EJECT_BUTTON "eject-button"
+#define PSWITCH_HK_ZOOM_BUTTON "zoom-button"
+#define PSWITCH_HK_VENDOR_BUTTON "vendor-button"
+
+#define PSWITCH_EVENT_PRESSED 0 /* button pressed, lid closed, AC off */
+#define PSWITCH_EVENT_RELEASED 1 /* button released, lid open, AC on */
+
+/*
+ * This structure describes the state of a power switch.
+ */
+struct pswitch_state {
+ char psws_name[16]; /* power switch name */
+ int32_t psws_type; /* type of switch (qualifier) */
+ int32_t psws_state; /* state of the switch/event */
+};
+
+/*
+ * envsys(4) events:
+ *
+ * envsys events are sent by the sysmon envsys framework when
+ * a warning or critical condition happens in a sensor.
+ *
+ * We define the folowing types of envsys events:
+ *
+ * sensor temperature To handle temperature sensors.
+ *
+ * sensor voltage To handle voltage sensors (AC/DC).
+ *
+ * sensor power To handle power sensors (W/Ampere).
+ *
+ * sensor resistance To handle resistance sensors (Ohms).
+ *
+ * sensor battery To handle battery sensors (Ah/Wh).
+ *
+ * sensor fan To handle fan sensors.
+ *
+ * sensor drive To handle drive sensors.
+ *
+ * sensor indicator To handle indicator/integer sensors.
+ */
+
+#define PENVSYS_TYPE_TEMP 10
+#define PENVSYS_TYPE_VOLTAGE 11
+#define PENVSYS_TYPE_POWER 12
+#define PENVSYS_TYPE_RESISTANCE 13
+#define PENVSYS_TYPE_BATTERY 14
+#define PENVSYS_TYPE_FAN 15
+#define PENVSYS_TYPE_DRIVE 16
+#define PENVSYS_TYPE_INDICATOR 17
+
+/*
+ * The following events apply for temperatures, power, resistance,
+ * voltages, battery and fan sensors:
+ *
+ * PENVSYS_EVENT_CRITICAL A critical limit.
+ *
+ * PENVSYS_EVENT_CRITOVER A critical over limit.
+ *
+ * PENVSYS_EVENT_CRITUNDER A critical under limit.
+ *
+ * PENVSYS_EVENT_WARNOVER A warning under limit.
+ *
+ * PENVSYS_EVENT_WARNUNDER A warning over limit.
+ *
+ * The folowing event applies to all sensors, when the state is
+ * valid or the warning or critical limit is not valid anymore:
+ *
+ * PENVSYS_EVENT_NORMAL Normal state in the sensor.
+ */
+
+#define PENVSYS_EVENT_NORMAL 90
+#define PENVSYS_EVENT_CRITICAL 100
+#define PENVSYS_EVENT_CRITOVER 110
+#define PENVSYS_EVENT_CRITUNDER 120
+#define PENVSYS_EVENT_WARNOVER 130
+#define PENVSYS_EVENT_WARNUNDER 140
+
+/*
+ * The following events apply for battery sensors:
+ *
+ * PENVSYS_EVENT_BATT_CRIT User critical capacity.
+ *
+ * PENVSYS_EVENT_BATT_WARN User warning capacity.
+ *
+ * PENVSYS_EVENT_BATT_HIGH User high capacity.
+ *
+ * PENVSYS_EVENT_BATT_MAX User maximum capacity.
+ *
+ * PENVSYS_EVENT_LOW_POWER AC Adapter is OFF and all batteries
+ * are discharged.
+ */
+
+#define PENVSYS_EVENT_BATT_CRIT 170
+#define PENVSYS_EVENT_BATT_WARN 175
+#define PENVSYS_EVENT_BATT_HIGH 177
+#define PENVSYS_EVENT_BATT_MAX 178
+#define PENVSYS_EVENT_LOW_POWER 180
+
+/*
+ * The following event apply for battery state and drive sensors:
+ *
+ * PENVSYS_EVENT_STATE_CHANGED State has changed.
+ *
+ */
+#define PENVSYS_EVENT_STATE_CHANGED 190
+
+/*
+ * The following events are used internally to associate multiple
+ * external states with a single event monitor
+ */
+#define PENVSYS_EVENT_LIMITS 200
+#define PENVSYS_EVENT_CAPACITY 210
+
+/*
+ * The following pseudo-event is used to force refreshing of a
+ * sensor that provides rnd(4) entropy, even if the sensor is not
+ * otherwise being monitored.
+ */
+#define PENVSYS_EVENT_NULL 220
+
+/*
+ * This structure defines the properties of an envsys event.
+ */
+struct penvsys_state {
+ char pes_dvname[16]; /* device name */
+ char pes_sensname[32]; /* sensor name */
+ char pes_statedesc[64]; /* sensor state description */
+ int32_t pes_type; /* envsys power type */
+};
+
+/*
+ * Power management event messages:
+ *
+ * We ensure that a message is always exactly 32 bytes long, so that
+ * userland doesn't need to issue multiple reads to get a single event.
+ */
+#define POWER_EVENT_MSG_SIZE 32
+
+#define POWER_EVENT_SWITCH_STATE_CHANGE 0
+#define POWER_EVENT_ENVSYS_STATE_CHANGE 1
+
+typedef struct power_event {
+ int32_t pev_type; /* power event type */
+ union {
+ int32_t _pev_d_space[(POWER_EVENT_MSG_SIZE /
+ sizeof(int32_t)) - 1];
+
+ /*
+ * This field is used for:
+ *
+ * POWER_EVENT_SWITCH_STATE_CHANGE
+ */
+ struct pswitch_state _pev_d_switch;
+ } _pev_data;
+} power_event_t;
+
+#define pev_switch _pev_data._pev_d_switch
+
+#define POWER_EVENT_RECVDICT _IOWR('P', 1, struct plistref)
+
+/*
+ * POWER_IOC_GET_TYPE:
+ *
+ * Get the power management back-end type.
+ */
+struct power_type {
+ char power_type[32];
+};
+#define POWER_IOC_GET_TYPE _IOR('P', 0, struct power_type)
+#define POWER_IOC_GET_TYPE_WITH_LOSSAGE _IOR('P', 0, sizeof(struct power_type))
+
+#endif /* _SYS_POWER_H_ */
--- /dev/null
+/* $NetBSD: proc.h,v 1.317 2012/07/22 22:40:18 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)proc.h 8.15 (Berkeley) 5/19/95
+ */
+
+#ifndef _SYS_PROC_H_
+#define _SYS_PROC_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_multiprocessor.h"
+#include "opt_kstack.h"
+#include "opt_lockdebug.h"
+#endif
+
+#include <machine/proc.h> /* Machine-dependent proc substruct */
+#include <sys/aio.h>
+#include <sys/rwlock.h>
+#include <sys/mqueue.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/lwp.h>
+#include <sys/queue.h>
+#include <sys/signalvar.h>
+#include <sys/siginfo.h>
+#include <sys/event.h>
+#include <sys/specificdata.h>
+
+#ifndef _KERNEL
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+/*
+ * One structure allocated per session.
+ */
+struct session {
+ int s_count; /* Ref cnt; pgrps in session */
+ u_int s_flags;
+#define S_LOGIN_SET 1 /* s_login set in this session */
+ struct proc *s_leader; /* Session leader */
+ struct vnode *s_ttyvp; /* Vnode of controlling terminal */
+ struct tty *s_ttyp; /* Controlling terminal */
+ char s_login[MAXLOGNAME]; /* Setlogin() name */
+ pid_t s_sid; /* Session ID (pid of leader) */
+};
+
+/*
+ * One structure allocated per process group.
+ */
+struct pgrp {
+ LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members */
+ struct session *pg_session; /* Pointer to session */
+ pid_t pg_id; /* Pgrp id */
+ int pg_jobc; /*
+ * Number of processes qualifying
+ * pgrp for job control
+ */
+};
+
+/*
+ * One structure allocated per emulation.
+ */
+struct exec_package;
+struct ras;
+struct kauth_cred;
+
+struct emul {
+ const char *e_name; /* Symbolic name */
+ const char *e_path; /* Extra emulation path (NULL if none)*/
+#ifndef __HAVE_MINIMAL_EMUL
+ int e_flags; /* Miscellaneous flags, see above */
+ /* Syscall handling function */
+ const int *e_errno; /* Errno array */
+ int e_nosys; /* Offset of the nosys() syscall */
+ int e_nsysent; /* Number of system call entries */
+#endif
+ struct sysent *e_sysent; /* System call array */
+ const char * const *e_syscallnames; /* System call name array */
+ /* Signal sending function */
+ void (*e_sendsig)(const struct ksiginfo *,
+ const sigset_t *);
+ void (*e_trapsignal)(struct lwp *, struct ksiginfo *);
+ int (*e_tracesig)(struct proc *, int);
+ char *e_sigcode; /* Start of sigcode */
+ char *e_esigcode; /* End of sigcode */
+ /* Set registers before execution */
+ struct uvm_object **e_sigobject;/* shared sigcode object */
+ void (*e_setregs)(struct lwp *, struct exec_package *,
+ vaddr_t);
+
+ /* Per-process hooks */
+ void (*e_proc_exec)(struct proc *, struct exec_package *);
+ void (*e_proc_fork)(struct proc *, struct lwp *, int);
+ void (*e_proc_exit)(struct proc *);
+ void (*e_lwp_fork)(struct lwp *, struct lwp *);
+ void (*e_lwp_exit)(struct lwp *);
+
+#ifdef __HAVE_SYSCALL_INTERN
+ void (*e_syscall_intern)(struct proc *);
+#else
+ void (*e_syscall)(void);
+#endif
+ /* Emulation specific sysctl data */
+ struct sysctlnode *e_sysctlovly;
+ int (*e_fault)(struct proc *, vaddr_t, int);
+
+ vaddr_t (*e_vm_default_addr)(struct proc *, vaddr_t, vsize_t);
+
+ /* Emulation-specific hook for userspace page faults */
+ int (*e_usertrap)(struct lwp *, vaddr_t, void *);
+
+ size_t e_ucsize; /* size of ucontext_t */
+ void (*e_startlwp)(void *);
+};
+
+/*
+ * Emulation miscelaneous flags
+ */
+#define EMUL_HAS_SYS___syscall 0x001 /* Has SYS___syscall */
+
+/*
+ * Description of a process.
+ *
+ * This structure contains the information needed to manage a thread of
+ * control, known in UN*X as a process; it has references to substructures
+ * containing descriptions of things that the process uses, but may share
+ * with related processes. The process structure and the substructures
+ * are always addressible except for those marked "(PROC ONLY)" below,
+ * which might be addressible only on a processor on which the process
+ * is running.
+ *
+ * Field markings and the corresponding locks:
+ *
+ * a: p_auxlock
+ * k: ktrace_mutex
+ * l: proc_lock
+ * t: p_stmutex
+ * p: p_lock
+ * (: updated atomically
+ * :: unlocked, stable
+ */
+struct vmspace;
+
+struct proc {
+ LIST_ENTRY(proc) p_list; /* l: List of all processes */
+
+ kmutex_t p_auxlock; /* :: secondary, longer term lock */
+ kmutex_t *p_lock; /* :: general mutex */
+ kmutex_t p_stmutex; /* :: mutex on profiling state */
+ krwlock_t p_reflock; /* p: lock for debugger, procfs */
+ kcondvar_t p_waitcv; /* p: wait, stop CV on children */
+ kcondvar_t p_lwpcv; /* p: wait, stop CV on LWPs */
+
+ /* Substructures: */
+ struct kauth_cred *p_cred; /* p: Master copy of credentials */
+ struct filedesc *p_fd; /* :: Ptr to open files structure */
+ struct cwdinfo *p_cwdi; /* :: cdir/rdir/cmask info */
+ struct pstats *p_stats; /* :: Accounting/stats (PROC ONLY) */
+ struct plimit *p_limit; /* :: Process limits */
+ struct vmspace *p_vmspace; /* :: Address space */
+ struct sigacts *p_sigacts; /* :: Process sigactions */
+ struct aioproc *p_aio; /* p: Asynchronous I/O data */
+ u_int p_mqueue_cnt; /* (: Count of open message queues */
+ specificdata_reference
+ p_specdataref; /* subsystem proc-specific data */
+
+ int p_exitsig; /* l: signal to send to parent on exit */
+ int p_flag; /* p: PK_* flags */
+ int p_sflag; /* p: PS_* flags */
+ int p_slflag; /* s, l: PSL_* flags */
+ int p_lflag; /* l: PL_* flags */
+ int p_stflag; /* t: PST_* flags */
+ char p_stat; /* p: S* process status. */
+ char p_trace_enabled;/* p: cached by syscall_intern() */
+ char p_pad1[2]; /* unused */
+
+ pid_t p_pid; /* :: Process identifier. */
+ LIST_ENTRY(proc) p_pglist; /* l: List of processes in pgrp. */
+ struct proc *p_pptr; /* l: Pointer to parent process. */
+ LIST_ENTRY(proc) p_sibling; /* l: List of sibling processes. */
+ LIST_HEAD(, proc) p_children; /* l: List of children. */
+ LIST_HEAD(, lwp) p_lwps; /* p: List of LWPs. */
+ struct ras *p_raslist; /* a: List of RAS entries */
+
+/* The following fields are all zeroed upon creation in fork. */
+#define p_startzero p_nlwps
+
+ int p_nlwps; /* p: Number of LWPs */
+ int p_nzlwps; /* p: Number of zombie LWPs */
+ int p_nrlwps; /* p: Number running/sleeping LWPs */
+ int p_nlwpwait; /* p: Number of LWPs in lwp_wait1() */
+ int p_ndlwps; /* p: Number of detached LWPs */
+ int p_nlwpid; /* p: Next LWP ID */
+ u_int p_nstopchild; /* l: Count of stopped/dead children */
+ u_int p_waited; /* l: parent has waited on child */
+ struct lwp *p_zomblwp; /* p: detached LWP to be reaped */
+ struct lwp *p_vforklwp; /* p: parent LWP waiting at vfork() */
+
+ /* scheduling */
+ void *p_sched_info; /* p: Scheduler-specific structure */
+ fixpt_t p_estcpu; /* p: Time avg. value of p_cpticks */
+ fixpt_t p_estcpu_inherited; /* p: cpu inherited from children */
+ unsigned int p_forktime;
+ fixpt_t p_pctcpu; /* p: %cpu from dead LWPs */
+
+ struct proc *p_opptr; /* l: save parent during ptrace. */
+ struct ptimers *p_timers; /* Timers: real, virtual, profiling */
+ struct bintime p_rtime; /* p: real time */
+ u_quad_t p_uticks; /* t: Statclock hits in user mode */
+ u_quad_t p_sticks; /* t: Statclock hits in system mode */
+ u_quad_t p_iticks; /* t: Statclock hits processing intr */
+
+ int p_traceflag; /* k: Kernel trace points */
+ void *p_tracep; /* k: Trace private data */
+ struct vnode *p_textvp; /* :: Vnode of executable */
+
+ struct emul *p_emul; /* :: emulation information */
+ void *p_emuldata; /* :: per-proc emul data, or NULL */
+ const struct execsw *p_execsw; /* :: exec package information */
+ struct klist p_klist; /* p: knotes attached to proc */
+
+ LIST_HEAD(, lwp) p_sigwaiters; /* p: LWPs waiting for signals */
+ sigpend_t p_sigpend; /* p: pending signals */
+ struct lcproc *p_lwpctl; /* p, a: _lwp_ctl() information */
+ pid_t p_ppid; /* :: cached parent pid */
+ pid_t p_fpid; /* :: forked pid */
+
+/*
+ * End area that is zeroed on creation
+ */
+#define p_endzero p_startcopy
+
+/*
+ * The following fields are all copied upon creation in fork.
+ */
+#define p_startcopy p_sigctx
+
+ struct sigctx p_sigctx; /* p: Shared signal state */
+
+ u_char p_nice; /* p: Process "nice" value */
+ char p_comm[MAXCOMLEN+1];
+ /* p: basename of last exec file */
+ struct pgrp *p_pgrp; /* l: Pointer to process group */
+
+ vaddr_t p_psstrp; /* :: address of process's ps_strings */
+ u_int p_pax; /* :: PAX flags */
+
+/*
+ * End area that is copied on creation
+ */
+#define p_endcopy p_xstat
+
+ u_short p_xstat; /* p: Exit status for wait; also stop signal */
+ u_short p_acflag; /* p: Acc. flags; see struct lwp also */
+ struct mdproc p_md; /* p: Any machine-dependent fields */
+ vaddr_t p_stackbase; /* :: ASLR randomized stack base */
+ struct kdtrace_proc *p_dtrace; /* :: DTrace-specific data. */
+};
+
+#define p_rlimit p_limit->pl_rlimit
+#define p_session p_pgrp->pg_session
+#define p_pgid p_pgrp->pg_id
+
+/*
+ * Status values.
+ */
+#define SIDL 1 /* Process being created by fork */
+#define SACTIVE 2 /* Process is not stopped */
+#define SDYING 3 /* About to die */
+#define SSTOP 4 /* Process debugging or suspension */
+#define SZOMB 5 /* Awaiting collection by parent */
+#define SDEAD 6 /* Almost a zombie */
+
+#define P_ZOMBIE(p) \
+ ((p)->p_stat == SZOMB || (p)->p_stat == SDYING || (p)->p_stat == SDEAD)
+
+/*
+ * These flags are kept in p_flag and are protected by p_lock. Access from
+ * process context only.
+ */
+#define PK_ADVLOCK 0x00000001 /* Process may hold a POSIX advisory lock */
+#define PK_SYSTEM 0x00000002 /* System process (kthread) */
+#define PK_SYSVSEM 0x00000004 /* Used SysV semaphores */
+#define PK_SUGID 0x00000100 /* Had set id privileges since last exec */
+#define PK_EXEC 0x00004000 /* Process called exec */
+#define PK_NOCLDWAIT 0x00020000 /* No zombies if child dies */
+#define PK_32 0x00040000 /* 32-bit process (used on 64-bit kernels) */
+#define PK_CLDSIGIGN 0x00080000 /* Process is ignoring SIGCHLD */
+#define PK_MARKER 0x80000000 /* Is a dummy marker process */
+
+/*
+ * These flags are kept in p_sflag and are protected by p_lock. Access from
+ * process context only.
+ */
+#define PS_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */
+#define PS_RUMP_LWPEXIT 0x00000400 /* LWPs in RUMP kernel should exit for GC */
+#define PS_WCORE 0x00001000 /* Process needs to dump core */
+#define PS_WEXIT 0x00002000 /* Working on exiting */
+#define PS_STOPFORK 0x00800000 /* Child will be stopped on fork(2) */
+#define PS_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */
+#define PS_STOPEXIT 0x02000000 /* Will be stopped at process exit */
+#define PS_NOTIFYSTOP 0x10000000 /* Notify parent of successful STOP */
+#define PS_STOPPING 0x80000000 /* Transitioning SACTIVE -> SSTOP */
+
+/*
+ * These flags are kept in p_sflag and are protected by the proc_lock
+ * and p_lock. Access from process context only.
+ */
+#define PSL_TRACEFORK 0x00000001 /* traced process wants fork events */
+#define PSL_TRACED 0x00000800 /* Debugged process being traced */
+#define PSL_FSTRACE 0x00010000 /* Debugger process being traced by procfs */
+#define PSL_CHTRACED 0x00400000 /* Child has been traced & reparented */
+#define PSL_SYSCALL 0x04000000 /* process has PT_SYSCALL enabled */
+#define PSL_SYSCALLEMU 0x08000000 /* cancel in-progress syscall */
+
+/*
+ * Kept in p_stflag and protected by p_stmutex.
+ */
+#define PST_PROFIL 0x00000020 /* Has started profiling */
+
+/*
+ * The final set are protected by the proc_lock. Access
+ * from process context only.
+ */
+#define PL_CONTROLT 0x00000002 /* Has a controlling terminal */
+#define PL_PPWAIT 0x00000010 /* Parent is waiting for child exec/exit */
+#define PL_SIGCOMPAT 0x00000200 /* Has used compat signal trampoline */
+#define PL_ORPHANPG 0x20000000 /* Member of an orphaned pgrp */
+
+/*
+ * Macro to compute the exit signal to be delivered.
+ */
+#define P_EXITSIG(p) \
+ (((p)->p_slflag & (PSL_TRACED|PSL_FSTRACE)) ? SIGCHLD : p->p_exitsig)
+
+LIST_HEAD(proclist, proc); /* A list of processes */
+
+/*
+ * This structure associates a proclist with its lock.
+ */
+struct proclist_desc {
+ struct proclist *pd_list; /* The list */
+ /*
+ * XXX Add a pointer to the proclist's lock eventually.
+ */
+};
+
+#ifdef _KERNEL
+
+/*
+ * We use process IDs <= PID_MAX until there are > 16k processes.
+ * NO_PGID is used to represent "no process group" for a tty.
+ */
+#define PID_MAX 30000
+#define NO_PGID ((pid_t)-1)
+
+#define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
+
+/*
+ * Flags passed to fork1().
+ */
+#define FORK_PPWAIT 0x0001 /* Block parent until child exit */
+#define FORK_SHAREVM 0x0002 /* Share vmspace with parent */
+#define FORK_SHARECWD 0x0004 /* Share cdir/rdir/cmask */
+#define FORK_SHAREFILES 0x0008 /* Share file descriptors */
+#define FORK_SHARESIGS 0x0010 /* Share signal actions */
+#define FORK_NOWAIT 0x0020 /* Make init the parent of the child */
+#define FORK_CLEANFILES 0x0040 /* Start with a clean descriptor set */
+#define FORK_SYSTEM 0x0080 /* Fork a kernel thread */
+
+extern struct proc proc0; /* Process slot for swapper */
+extern u_int nprocs; /* Current number of procs */
+extern int maxproc; /* Max number of procs */
+#define vmspace_kernel() (proc0.p_vmspace)
+
+extern kmutex_t *proc_lock;
+extern struct proclist allproc; /* List of all processes */
+extern struct proclist zombproc; /* List of zombie processes */
+
+extern struct proc *initproc; /* Process slots for init, pager */
+
+extern const struct proclist_desc proclists[];
+
+extern struct pool ptimer_pool; /* Memory pool for ptimers */
+
+struct simplelock;
+
+proc_t * proc_find_raw(pid_t);
+proc_t * proc_find(pid_t); /* Find process by ID */
+struct pgrp * pgrp_find(pid_t); /* Find process group by ID */
+
+void procinit(void);
+void procinit_sysctl(void);
+int proc_enterpgrp(struct proc *, pid_t, pid_t, bool);
+void proc_leavepgrp(struct proc *);
+void proc_sesshold(struct session *);
+void proc_sessrele(struct session *);
+void fixjobc(struct proc *, struct pgrp *, int);
+
+int tsleep(wchan_t, pri_t, const char *, int);
+int mtsleep(wchan_t, pri_t, const char *, int, kmutex_t *);
+void wakeup(wchan_t);
+int kpause(const char *, bool, int, kmutex_t *);
+void exit1(struct lwp *, int) __dead;
+int do_sys_wait(int *, int *, int, struct rusage *);
+struct proc *proc_alloc(void);
+void proc0_init(void);
+pid_t proc_alloc_pid(struct proc *);
+void proc_free_pid(pid_t);
+void proc_free_mem(struct proc *);
+void exit_lwps(struct lwp *l);
+int fork1(struct lwp *, int, int, void *, size_t,
+ void (*)(void *), void *, register_t *, struct proc **);
+int pgid_in_session(struct proc *, pid_t);
+void cpu_lwp_fork(struct lwp *, struct lwp *, void *, size_t,
+ void (*)(void *), void *);
+void cpu_lwp_free(struct lwp *, int);
+void cpu_lwp_free2(struct lwp *);
+void cpu_spawn_return(struct lwp*);
+
+#ifdef __HAVE_SYSCALL_INTERN
+void syscall_intern(struct proc *);
+#endif
+
+void child_return(void *);
+
+int proc_isunder(struct proc *, struct lwp *);
+void proc_stop(struct proc *, int, int);
+int proc_uidmatch(kauth_cred_t, kauth_cred_t);
+
+int proc_vmspace_getref(struct proc *, struct vmspace **);
+void proc_crmod_leave(kauth_cred_t, kauth_cred_t, bool);
+void proc_crmod_enter(void);
+
+int proc_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
+void proc_specific_key_delete(specificdata_key_t);
+void proc_initspecific(struct proc *);
+void proc_finispecific(struct proc *);
+void * proc_getspecific(struct proc *, specificdata_key_t);
+void proc_setspecific(struct proc *, specificdata_key_t, void *);
+int proc_compare(const struct proc *, const struct lwp *,
+ const struct proc *, const struct lwp *);
+
+int proclist_foreach_call(struct proclist *,
+ int (*)(struct proc *, void *arg), void *);
+
+static inline struct proc *
+_proclist_skipmarker(struct proc *p0)
+{
+ struct proc *p = p0;
+
+ while (p != NULL && p->p_flag & PK_MARKER)
+ p = LIST_NEXT(p, p_list);
+
+ return p;
+}
+
+/*
+ * PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones.
+ */
+#define PROCLIST_FOREACH(var, head) \
+ for ((var) = LIST_FIRST(head); \
+ ((var) = _proclist_skipmarker(var)) != NULL; \
+ (var) = LIST_NEXT(var, p_list))
+
+#ifdef KSTACK_CHECK_MAGIC
+void kstack_setup_magic(const struct lwp *);
+void kstack_check_magic(const struct lwp *);
+#else
+#define kstack_setup_magic(x)
+#define kstack_check_magic(x)
+#endif
+
+extern struct emul emul_netbsd;
+
+#endif /* _KERNEL */
+
+#if defined(_KMEMUSER) || defined(_KERNEL)
+
+/*
+ * Kernel stack parameters.
+ *
+ * KSTACK_LOWEST_ADDR: return the lowest address of the LWP's kernel stack,
+ * excluding red-zone.
+ *
+ * KSTACK_SIZE: the size kernel stack for a LWP, excluding red-zone.
+ *
+ * if <machine/proc.h> provides the MD definition, it will be used.
+ */
+#ifndef KSTACK_LOWEST_ADDR
+#define KSTACK_LOWEST_ADDR(l) ((void *)ALIGN((struct pcb *)((l)->l_addr) + 1))
+#endif
+#ifndef KSTACK_SIZE
+#define KSTACK_SIZE (USPACE - ALIGN(sizeof(struct pcb)))
+#endif
+
+#endif /* _KMEMUSER || _KERNEL */
+
+#endif /* !_SYS_PROC_H_ */
--- /dev/null
+/* $NetBSD: prot.h,v 1.2 2008/04/29 06:53:03 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PROT_H_
+#define _SYS_PROT_H_
+
+/*
+ * flags that control when do_setres{u,g}id will do anything
+ *
+ * ID_XXX_EQ_YYY means
+ * "allow modifying XXX uid to the given value if the new value of
+ * XXX uid (or gid) equals the current value of YYY uid (or gid)."
+ */
+
+#define ID_E_EQ_E 0x001 /* effective equals effective */
+#define ID_E_EQ_R 0x002 /* effective equals real */
+#define ID_E_EQ_S 0x004 /* effective equals saved */
+#define ID_R_EQ_E 0x010 /* real equals effective */
+#define ID_R_EQ_R 0x020 /* real equals real */
+#define ID_R_EQ_S 0x040 /* real equals saved */
+#define ID_S_EQ_E 0x100 /* saved equals effective */
+#define ID_S_EQ_R 0x200 /* saved equals real */
+#define ID_S_EQ_S 0x400 /* saved equals saved */
+
+int do_setresuid(struct lwp *, uid_t, uid_t, uid_t, u_int);
+int do_setresgid(struct lwp *, gid_t, gid_t, gid_t, u_int);
+
+#endif /* !_SYS_PROT_H_ */
--- /dev/null
+/* $NetBSD: protosw.h,v 1.44 2008/08/06 15:01:24 plunky Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)protosw.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_PROTOSW_H_
+#define _SYS_PROTOSW_H_
+
+/*
+ * Protocol switch table.
+ *
+ * Each protocol has a handle initializing one of these structures,
+ * which is used for protocol-protocol and system-protocol communication.
+ *
+ * A protocol is called through the pr_init entry before any other.
+ * Thereafter it is called every 200ms through the pr_fasttimo entry and
+ * every 500ms through the pr_slowtimo for timer based actions.
+ * The system will call the pr_drain entry if it is low on space and
+ * this should throw away any non-critical data.
+ *
+ * Protocols pass data between themselves as chains of mbufs using
+ * the pr_input and pr_output hooks. Pr_input passes data up (towards
+ * UNIX) and pr_output passes it down (towards the imps); control
+ * information passes up and down on pr_ctlinput and pr_ctloutput.
+ * The protocol is responsible for the space occupied by any the
+ * arguments to these entries and must dispose it.
+ *
+ * The userreq routine interfaces protocols to the system and is
+ * described below.
+ */
+
+struct mbuf;
+struct sockaddr;
+struct socket;
+struct sockopt;
+struct domain;
+struct proc;
+struct lwp;
+
+struct protosw {
+ int pr_type; /* socket type used for */
+ struct domain *pr_domain; /* domain protocol a member of */
+ short pr_protocol; /* protocol number */
+ short pr_flags; /* see below */
+
+/* protocol-protocol hooks */
+ void (*pr_input) /* input to protocol (from below) */
+ (struct mbuf *, ...);
+ int (*pr_output) /* output to protocol (from above) */
+ (struct mbuf *, ...);
+ void *(*pr_ctlinput) /* control input (from below) */
+ (int, const struct sockaddr *, void *);
+ int (*pr_ctloutput) /* control output (from above) */
+ (int, struct socket *, struct sockopt *);
+
+/* user-protocol hook */
+ int (*pr_usrreq) /* user request: see list below */
+ (struct socket *, int, struct mbuf *,
+ struct mbuf *, struct mbuf *, struct lwp *);
+
+/* utility hooks */
+ void (*pr_init) /* initialization hook */
+ (void);
+
+ void (*pr_fasttimo) /* fast timeout (200ms) */
+ (void);
+ void (*pr_slowtimo) /* slow timeout (500ms) */
+ (void);
+ void (*pr_drain) /* flush any excess space possible */
+ (void);
+};
+
+#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
+#define PR_FASTHZ 5 /* 5 fast timeouts per second */
+
+/*
+ * Values for pr_flags.
+ * PR_ADDR requires PR_ATOMIC;
+ * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
+ */
+#define PR_ATOMIC 0x01 /* exchange atomic messages only */
+#define PR_ADDR 0x02 /* addresses given with messages */
+#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
+#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
+#define PR_RIGHTS 0x10 /* passes capabilities */
+#define PR_LISTEN 0x20 /* supports listen(2) and accept(2) */
+#define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */
+#define PR_ABRTACPTDIS 0x80 /* abort on accept(2) to disconnected
+ socket */
+#define PR_PURGEIF 0x100 /* might store struct ifnet pointer;
+ PRU_PURGEIF must be called on ifnet
+ deletion */
+
+/*
+ * The arguments to usrreq are:
+ * (*protosw[].pr_usrreq)(up, req, m, nam, opt, p);
+ * where up is a (struct socket *), req is one of these requests,
+ * m is a optional mbuf chain containing a message,
+ * nam is an optional mbuf chain containing an address,
+ * opt is an optional mbuf containing socket options,
+ * and p is a pointer to the process requesting the action (if any).
+ * The protocol is responsible for disposal of the mbuf chains m and opt,
+ * the caller is responsible for any space held by nam.
+ * A non-zero return from usrreq gives an
+ * UNIX error number which should be passed to higher level software.
+ */
+#define PRU_ATTACH 0 /* attach protocol to up */
+#define PRU_DETACH 1 /* detach protocol from up */
+#define PRU_BIND 2 /* bind socket to address */
+#define PRU_LISTEN 3 /* listen for connection */
+#define PRU_CONNECT 4 /* establish connection to peer */
+#define PRU_ACCEPT 5 /* accept connection from peer */
+#define PRU_DISCONNECT 6 /* disconnect from peer */
+#define PRU_SHUTDOWN 7 /* won't send any more data */
+#define PRU_RCVD 8 /* have taken data; more room now */
+#define PRU_SEND 9 /* send this data */
+#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETACH) */
+#define PRU_CONTROL 11 /* control operations on protocol */
+#define PRU_SENSE 12 /* return status into m */
+#define PRU_RCVOOB 13 /* retrieve out of band data */
+#define PRU_SENDOOB 14 /* send out of band data */
+#define PRU_SOCKADDR 15 /* fetch socket's address */
+#define PRU_PEERADDR 16 /* fetch peer's address */
+#define PRU_CONNECT2 17 /* connect two sockets */
+/* begin for protocols internal use */
+#define PRU_FASTTIMO 18 /* 200ms timeout */
+#define PRU_SLOWTIMO 19 /* 500ms timeout */
+#define PRU_PROTORCV 20 /* receive from below */
+#define PRU_PROTOSEND 21 /* send to below */
+#define PRU_PURGEIF 22 /* purge specified if */
+
+#define PRU_NREQ 23
+
+#ifdef PRUREQUESTS
+static const char * const prurequests[] = {
+ "ATTACH", "DETACH", "BIND", "LISTEN",
+ "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN",
+ "RCVD", "SEND", "ABORT", "CONTROL",
+ "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR",
+ "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO",
+ "PROTORCV", "PROTOSEND", "PURGEIF",
+};
+#endif
+
+/*
+ * The arguments to the ctlinput routine are
+ * (*protosw[].pr_ctlinput)(cmd, sa, arg);
+ * where cmd is one of the commands below, sa is a pointer to a sockaddr,
+ * and arg is an optional void *argument used within a protocol family.
+ */
+#define PRC_IFDOWN 0 /* interface transition */
+#define PRC_ROUTEDEAD 1 /* select new route if possible ??? */
+#define PRC_QUENCH2 3 /* DEC congestion bit says slow down */
+#define PRC_QUENCH 4 /* some one said to slow down */
+#define PRC_MSGSIZE 5 /* message size forced drop */
+#define PRC_HOSTDEAD 6 /* host appears to be down */
+#define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */
+#define PRC_UNREACH_NET 8 /* no route to network */
+#define PRC_UNREACH_HOST 9 /* no route to host */
+#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
+#define PRC_UNREACH_PORT 11 /* bad port # */
+/* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */
+#define PRC_UNREACH_SRCFAIL 13 /* source route failed */
+#define PRC_REDIRECT_NET 14 /* net routing redirect */
+#define PRC_REDIRECT_HOST 15 /* host routing redirect */
+#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
+#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
+#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
+#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
+#define PRC_PARAMPROB 20 /* header incorrect */
+
+#define PRC_NCMDS 21
+
+#define PRC_IS_REDIRECT(cmd) \
+ ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
+
+#ifdef PRCREQUESTS
+static const char * const prcrequests[] = {
+ "IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2",
+ "QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
+ "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
+ "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
+ "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
+ "PARAMPROB"
+};
+#endif
+
+/*
+ * The arguments to ctloutput are:
+ * (*protosw[].pr_ctloutput)(req, so, sopt);
+ * req is one of the actions listed below, so is a (struct socket *),
+ * sopt is a (struct sockopt *)
+ * A non-zero return from usrreq gives an
+ * UNIX error number which should be passed to higher level software.
+ */
+#define PRCO_GETOPT 0
+#define PRCO_SETOPT 1
+
+#define PRCO_NCMDS 2
+
+#ifdef PRCOREQUESTS
+static const char * const prcorequests[] = {
+ "GETOPT", "SETOPT",
+};
+#endif
+
+#ifdef _KERNEL
+/*
+ * Monotonically increasing time values for slow and fast timers.
+ */
+extern u_int pfslowtimo_now;
+extern u_int pffasttimo_now;
+
+#define PRT_SLOW_ARM(t, nticks) (t) = (pfslowtimo_now + (nticks))
+#define PRT_FAST_ARM(t, nticks) (t) = (pffasttimo_now + (nticks))
+
+#define PRT_SLOW_DISARM(t) (t) = 0
+#define PRT_FAST_DISARM(t) (t) = 0
+
+#define PRT_SLOW_ISARMED(t) ((t) != 0)
+#define PRT_FAST_ISARMED(t) ((t) != 0)
+
+#define PRT_SLOW_ISEXPIRED(t) (PRT_SLOW_ISARMED((t)) && (t) <= pfslowtimo_now)
+#define PRT_FAST_ISEXPIRED(t) (PRT_FAST_ISARMED((t)) && (t) <= pffasttimo_now)
+
+struct sockaddr;
+const struct protosw *pffindproto(int, int, int);
+const struct protosw *pffindtype(int, int);
+struct domain *pffinddomain(int);
+void pfctlinput(int, const struct sockaddr *);
+void pfctlinput2(int, const struct sockaddr *, void *);
+
+/*
+ * Wrappers for non-MPSAFE protocols
+ */
+#include <sys/systm.h> /* kernel_lock */
+
+#define PR_WRAP_USRREQ(name) \
+static int \
+name##_wrapper(struct socket *a, int b, struct mbuf *c, \
+ struct mbuf *d, struct mbuf *e, struct lwp *f) \
+{ \
+ int rv; \
+ KERNEL_LOCK(1, NULL); \
+ rv = name(a, b, c, d, e, f); \
+ KERNEL_UNLOCK_ONE(NULL); \
+ return rv; \
+}
+
+#define PR_WRAP_CTLOUTPUT(name) \
+static int \
+name##_wrapper(int a, struct socket *b, \
+ struct sockopt *c) \
+{ \
+ int rv; \
+ KERNEL_LOCK(1, NULL); \
+ rv = name(a, b, c); \
+ KERNEL_UNLOCK_ONE(NULL); \
+ return rv; \
+}
+
+#define PR_WRAP_CTLINPUT(name) \
+static void * \
+name##_wrapper(int a, const struct sockaddr *b, void *c)\
+{ \
+ void *rv; \
+ KERNEL_LOCK(1, NULL); \
+ rv = name(a, b, c); \
+ KERNEL_UNLOCK_ONE(NULL); \
+ return rv; \
+}
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_PROTOSW_H_ */
--- /dev/null
+/* $NetBSD: pserialize.h,v 1.1 2011/07/30 17:01:04 christos Exp $ */
+
+/*-
+ * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PSERIALIZE_H_
+#define _SYS_PSERIALIZE_H_
+
+#ifdef _KERNEL
+
+struct pserialize;
+typedef struct pserialize *pserialize_t;
+
+void pserialize_init(void);
+void pserialize_switchpoint(void);
+
+pserialize_t pserialize_create(void);
+void pserialize_destroy(pserialize_t);
+void pserialize_perform(pserialize_t);
+
+int pserialize_read_enter(void);
+void pserialize_read_exit(int);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_PSERIALIZE_H_ */
--- /dev/null
+/* $NetBSD: pset.h,v 1.3 2008/05/26 17:45:51 rmind Exp $ */
+
+/*
+ * Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_PSET_H_
+#define _SYS_PSET_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/* Types of processor-sets */
+#define PS_NONE 0
+#define PS_MYID -1
+#define PS_QUERY -2
+
+/* ID types for processor-set calls */
+#define P_MYID -1
+#define P_PID 1
+#define P_LWPID 2
+
+/* For compatibility only */
+typedef cpuid_t processorid_t;
+
+__BEGIN_DECLS
+int pset_assign(psetid_t, cpuid_t, psetid_t *);
+int pset_bind(psetid_t, idtype_t, id_t, psetid_t *);
+int pset_create(psetid_t *);
+int pset_destroy(psetid_t);
+__END_DECLS
+
+#ifdef _NETBSD_SOURCE
+int _pset_bind(idtype_t, id_t, id_t, psetid_t, psetid_t *);
+#endif /* _NETBSD_SOURCE */
+
+#ifdef _KERNEL
+
+/* Processor-set structure */
+typedef struct {
+ int ps_flags;
+} pset_info_t;
+
+/* Flags */
+#define PSET_BUSY 0x01
+
+void psets_init(void);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_PSET_H_ */
--- /dev/null
+/* $NetBSD: pty.h,v 1.8 2008/04/28 20:24:11 martin Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_PTY_H_
+#define _SYS_PTY_H_
+
+int pty_isfree(int, int);
+int pty_check(int);
+
+#ifndef NO_DEV_PTM
+void ptmattach(int);
+int pty_fill_ptmget(struct lwp *, dev_t, int, int, void *);
+int pty_grant_slave(struct lwp *, dev_t);
+dev_t pty_makedev(char, int);
+int pty_vn_open(struct vnode *, struct lwp *);
+struct ptm_pty *pty_sethandler(struct ptm_pty *);
+#endif
+
+struct ptm_pty {
+ int (*allocvp)(struct ptm_pty *, struct lwp *, struct vnode **, dev_t,
+ char);
+ int (*makename)(struct ptm_pty *, struct lwp *, char *, size_t, dev_t, char);
+ void (*getvattr)(struct ptm_pty *, struct lwp *, struct vattr *);
+ void *arg;
+};
+
+extern int npty;
+
+#ifdef COMPAT_BSDPTY
+extern struct ptm_pty ptm_bsdpty;
+#endif
+
+#endif /* _SYS_PTY_H_ */
--- /dev/null
+/* $NetBSD: quota.h,v 1.12 2012/01/30 00:56:19 dholland Exp $ */
+/*-
+ * Copyright (c) 2010 Manuel Bouyer
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_QUOTA_H_
+#define _SYS_QUOTA_H_
+
+#include <sys/types.h>
+
+/* quota id types (entities being billed) */
+#define QUOTA_IDTYPE_USER 0
+#define QUOTA_IDTYPE_GROUP 1
+
+/* quota object types (things being limited) */
+#define QUOTA_OBJTYPE_BLOCKS 0
+#define QUOTA_OBJTYPE_FILES 1
+
+/* id value for "default" */
+#define QUOTA_DEFAULTID ((id_t)-1)
+
+/* limit value for "no limit" */
+#define QUOTA_NOLIMIT ((uint64_t)0xffffffffffffffffULL)
+
+/* time value for "no time" */
+#define QUOTA_NOTIME ((time_t)-1)
+
+/*
+ * Semantic restrictions. These are hints applications can use
+ * to help produce comprehensible error diagnostics when something
+ * unsupported is attempted.
+ */
+#define QUOTA_RESTRICT_NEEDSQUOTACHECK 0x1 /* quotacheck(8) required */
+#define QUOTA_RESTRICT_UNIFORMGRACE 0x2 /* grace time is global */
+#define QUOTA_RESTRICT_32BIT 0x4 /* values limited to 2^32 */
+#define QUOTA_RESTRICT_READONLY 0x8 /* updates not supported */
+
+
+/*
+ * Structure used to describe the key part of a quota record.
+ */
+struct quotakey {
+ int qk_idtype; /* type of id (user, group, etc.) */
+ id_t qk_id; /* actual id number */
+ int qk_objtype; /* type of fs object (blocks, files, etc.) */
+};
+
+/*
+ * Structure used to describe the value part of a quota record.
+ */
+struct quotaval {
+ uint64_t qv_hardlimit; /* absolute limit */
+ uint64_t qv_softlimit; /* overflowable limit */
+ uint64_t qv_usage; /* current usage */
+ time_t qv_expiretime; /* time when softlimit grace expires */
+ time_t qv_grace; /* allowed time for overflowing soft limit */
+};
+
+#endif /* _SYS_QUOTA_H_ */
--- /dev/null
+/* $NetBSD: quotactl.h,v 1.35 2012/02/01 05:46:45 dholland Exp $ */
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David A. Holland.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_QUOTACTL_H_
+#define _SYS_QUOTACTL_H_
+
+#include <sys/stdint.h>
+
+/*
+ * Note - this is an internal interface. Application code (and,
+ * really, anything that isn't libquota or inside the kernel) should
+ * use the <quota.h> API instead.
+ */
+
+/* Size of random quota strings */
+#define QUOTA_NAMELEN 32
+
+/*
+ * Structure for QUOTACTL_STAT.
+ */
+struct quotastat {
+ char qs_implname[QUOTA_NAMELEN];
+ int qs_numidtypes;
+ int qs_numobjtypes;
+ unsigned qs_restrictions; /* semantic restriction codes */
+};
+
+/*
+ * Structures for QUOTACTL_IDTYPESTAT and QUOTACTL_OBJTYPESTAT.
+ */
+struct quotaidtypestat {
+ char qis_name[QUOTA_NAMELEN];
+};
+struct quotaobjtypestat {
+ char qos_name[QUOTA_NAMELEN];
+ int qos_isbytes;
+};
+
+/*
+ * Semi-opaque structure for cursors. This holds the cursor state in
+ * userland; the size is exposed only to libquota, not to client code,
+ * and is meant to be large enough to accomodate all likely future
+ * expansion without being unduly bloated, as it will need to be
+ * copied in and out for every call using it.
+ */
+struct quotakcursor {
+ union {
+ char qkc_space[64];
+ uintmax_t __qkc_forcealign;
+ } u;
+};
+
+/* Command codes. */
+#define QUOTACTL_STAT 0
+#define QUOTACTL_IDTYPESTAT 1
+#define QUOTACTL_OBJTYPESTAT 2
+#define QUOTACTL_GET 3
+#define QUOTACTL_PUT 4
+#define QUOTACTL_DELETE 5
+#define QUOTACTL_CURSOROPEN 6
+#define QUOTACTL_CURSORCLOSE 7
+#define QUOTACTL_CURSORSKIPIDTYPE 8
+#define QUOTACTL_CURSORGET 9
+#define QUOTACTL_CURSORATEND 10
+#define QUOTACTL_CURSORREWIND 11
+#define QUOTACTL_QUOTAON 12
+#define QUOTACTL_QUOTAOFF 13
+
+/* Argument encoding. */
+struct quotactl_args {
+ unsigned qc_op;
+ union {
+ struct {
+ struct quotastat *qc_info;
+ } stat;
+ struct {
+ int qc_idtype;
+ struct quotaidtypestat *qc_info;
+ } idtypestat;
+ struct {
+ int qc_objtype;
+ struct quotaobjtypestat *qc_info;
+ } objtypestat;
+ struct {
+ const struct quotakey *qc_key;
+ struct quotaval *qc_val;
+ } get;
+ struct {
+ const struct quotakey *qc_key;
+ const struct quotaval *qc_val;
+ } put;
+ struct {
+ const struct quotakey *qc_key;
+ } delete;
+ struct {
+ struct quotakcursor *qc_cursor;
+ } cursoropen;
+ struct {
+ struct quotakcursor *qc_cursor;
+ } cursorclose;
+ struct {
+ struct quotakcursor *qc_cursor;
+ int qc_idtype;
+ } cursorskipidtype;
+ struct {
+ struct quotakcursor *qc_cursor;
+ struct quotakey *qc_keys;
+ struct quotaval *qc_vals;
+ unsigned qc_maxnum;
+ unsigned *qc_ret;
+ } cursorget;
+ struct {
+ struct quotakcursor *qc_cursor;
+ int *qc_ret; /* really boolean */
+ } cursoratend;
+ struct {
+ struct quotakcursor *qc_cursor;
+ } cursorrewind;
+ struct {
+ int qc_idtype;
+ const char *qc_quotafile;
+ } quotaon;
+ struct {
+ int qc_idtype;
+ } quotaoff;
+ } u;
+};
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+__BEGIN_DECLS
+int __quotactl(const char *, struct quotactl_args *);
+__END_DECLS
+#endif
+
+#endif /* _SYS_QUOTACTL_H_ */
--- /dev/null
+/* $NetBSD: radioio.h,v 1.2 2005/12/26 18:41:36 perry Exp $ */
+/* $OpenBSD: radioio.h,v 1.2 2001/12/05 10:27:05 mickey Exp $ */
+/* $RuOBSD: radioio.h,v 1.4 2001/10/18 16:51:36 pva Exp $ */
+
+/*
+ * Copyright (c) 2001 Maxim Tsyplakov <tm@oganer.net>,
+ * Vladimir Popov <jumbo@narod.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_RADIOIO_H_
+#define _SYS_RADIOIO_H_
+
+#include <sys/param.h>
+
+#define MIN_FM_FREQ 87500
+#define MAX_FM_FREQ 108000
+
+#define IF_FREQ 10700
+
+struct radio_info {
+ int mute;
+ int volume;
+ int stereo;
+ int rfreq; /* reference frequency */
+ int lock; /* locking field strength during an automatic search */
+ uint32_t freq; /* in kHz */
+ uint32_t caps; /* card capabilities */
+#define RADIO_CAPS_DETECT_STEREO (1<<0)
+#define RADIO_CAPS_DETECT_SIGNAL (1<<1)
+#define RADIO_CAPS_SET_MONO (1<<2)
+#define RADIO_CAPS_HW_SEARCH (1<<3)
+#define RADIO_CAPS_HW_AFC (1<<4)
+#define RADIO_CAPS_REFERENCE_FREQ (1<<5)
+#define RADIO_CAPS_LOCK_SENSITIVITY (1<<6)
+#define RADIO_CAPS_RESERVED1 (1<<7)
+#define RADIO_CAPS_RESERVED2 (0xFF<<8)
+#define RADIO_CARD_TYPE (0xFF<<16)
+ uint32_t info;
+#define RADIO_INFO_STEREO (1<<0)
+#define RADIO_INFO_SIGNAL (1<<1)
+};
+
+/* Radio device operations */
+#define RIOCGINFO _IOR('R', 21, struct radio_info) /* get info */
+#define RIOCSINFO _IOWR('R', 22, struct radio_info) /* set info */
+#define RIOCSSRCH _IOW('R', 23, int) /* search up/down */
+
+#endif /* _SYS_RADIOIO_H_ */
--- /dev/null
+/* $NetBSD: radixtree.h,v 1.5 2011/10/25 14:11:27 yamt Exp $ */
+
+/*-
+ * Copyright (c)2011 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_RADIXTREE_H_)
+#define _SYS_RADIXTREE_H_
+
+struct radix_tree {
+ void *t_root;
+ unsigned int t_height;
+};
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/types.h>
+#else /* defined(_KERNEL) || defined(_STANDALONE) */
+#include <stdbool.h>
+#include <stdint.h>
+#endif /* defined(_KERNEL) || defined(_STANDALONE) */
+
+/*
+ * subsystem
+ */
+
+#if defined(_KERNEL)
+void radix_tree_init(void);
+#endif /* defined(_KERNEL) */
+
+/*
+ * tree
+ */
+
+void radix_tree_init_tree(struct radix_tree *);
+void radix_tree_fini_tree(struct radix_tree *);
+bool radix_tree_empty_tree_p(struct radix_tree *);
+
+/*
+ * node
+ */
+
+int radix_tree_insert_node(struct radix_tree *, uint64_t, void *);
+void *radix_tree_replace_node(struct radix_tree *, uint64_t, void *);
+void *radix_tree_remove_node(struct radix_tree *, uint64_t);
+void *radix_tree_lookup_node(struct radix_tree *, uint64_t);
+unsigned int radix_tree_gang_lookup_node(struct radix_tree *, uint64_t,
+ void **, unsigned int);
+unsigned int radix_tree_gang_lookup_node_reverse(struct radix_tree *, uint64_t,
+ void **, unsigned int);
+
+/*
+ * tag
+ */
+
+typedef int radix_tree_tagid_t;
+#define RADIX_TREE_TAG_ID_MAX 2
+bool radix_tree_get_tag(struct radix_tree *, uint64_t, radix_tree_tagid_t);
+void radix_tree_set_tag(struct radix_tree *, uint64_t, radix_tree_tagid_t);
+void radix_tree_clear_tag(struct radix_tree *, uint64_t, radix_tree_tagid_t);
+unsigned int radix_tree_gang_lookup_tagged_node(struct radix_tree *, uint64_t,
+ void **, unsigned int, radix_tree_tagid_t);
+unsigned int radix_tree_gang_lookup_tagged_node_reverse(struct radix_tree *,
+ uint64_t, void **, unsigned int, radix_tree_tagid_t);
+bool radix_tree_empty_tagged_tree_p(struct radix_tree *, radix_tree_tagid_t);
+
+#endif /* !defined(_SYS_RADIXTREE_H_) */
--- /dev/null
+/* $NetBSD: resourcevar.h,v 1.53 2011/06/03 17:58:18 rmind Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_RESOURCEVAR_H_
+#define _SYS_RESOURCEVAR_H_
+
+#if !defined(_KERNEL) && !defined(_KMEMUSER)
+#error "not supposed to be exposed to userland"
+#endif
+
+#include <sys/mutex.h>
+
+/*
+ * Kernel per-process accounting / statistics
+ */
+struct pstats {
+#define pstat_startzero p_ru
+ struct rusage p_ru; /* stats for this proc */
+ struct rusage p_cru; /* sum of stats for reaped children */
+#define pstat_endzero pstat_startcopy
+
+#define pstat_startcopy p_timer
+ struct itimerspec p_timer[3]; /* virtual-time timers */
+
+ struct uprof { /* profile arguments */
+ char * pr_base; /* buffer base */
+ size_t pr_size; /* buffer size */
+ u_long pr_off; /* pc offset */
+ u_int pr_scale; /* pc scaling */
+ u_long pr_addr; /* temp storage for addr until AST */
+ u_long pr_ticks; /* temp storage for ticks until AST */
+ } p_prof;
+#define pstat_endcopy p_start
+ struct timeval p_start; /* starting time */
+};
+
+#ifdef _KERNEL
+
+/*
+ * Process resource limits. Since this structure is moderately large,
+ * but changes infrequently, it is shared copy-on-write after forks.
+ *
+ * When a separate copy is created, then 'pl_writeable' is set to true,
+ * and 'pl_sv_limit' is pointed to the old proc_t::p_limit structure.
+ */
+struct plimit {
+ struct rlimit pl_rlimit[RLIM_NLIMITS];
+ char * pl_corename;
+ size_t pl_cnlen;
+ u_int pl_refcnt;
+ bool pl_writeable;
+ kmutex_t pl_lock;
+ struct plimit * pl_sv_limit;
+};
+
+/* add user profiling from AST XXXSMP */
+#define ADDUPROF(l) \
+ do { \
+ struct proc *_p = (l)->l_proc; \
+ addupc_task((l), \
+ _p->p_stats->p_prof.pr_addr, \
+ _p->p_stats->p_prof.pr_ticks); \
+ _p->p_stats->p_prof.pr_ticks = 0; \
+ } while (/* CONSTCOND */ 0)
+
+extern char defcorename[];
+
+extern int security_setidcore_dump;
+extern char security_setidcore_path[];
+extern uid_t security_setidcore_owner;
+extern gid_t security_setidcore_group;
+extern mode_t security_setidcore_mode;
+
+void addupc_intr(struct lwp *, u_long);
+void addupc_task(struct lwp *, u_long, u_int);
+void calcru(struct proc *, struct timeval *, struct timeval *,
+ struct timeval *, struct timeval *);
+
+struct plimit *lim_copy(struct plimit *);
+void lim_addref(struct plimit *);
+void lim_privatise(struct proc *);
+void lim_setcorename(struct proc *, char *, size_t);
+void lim_free(struct plimit *);
+
+void resource_init(void);
+void ruadd(struct rusage *, struct rusage *);
+void rulwps(proc_t *, struct rusage *);
+struct pstats *pstatscopy(struct pstats *);
+void pstatsfree(struct pstats *);
+extern rlim_t maxdmap;
+extern rlim_t maxsmap;
+
+#endif
+
+#endif /* !_SYS_RESOURCEVAR_H_ */
--- /dev/null
+/* $NetBSD: rnd.h,v 1.33 2012/09/05 18:57:33 tls Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael Graff <explorer@flame.org>. This code uses ideas and
+ * algorithms from the Linux driver written by Ted Ts'o.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_RND_H_
+#define _SYS_RND_H_
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+#endif /* !_KERNEL */
+
+#include <sys/types.h>
+#include <sys/sha1.h>
+
+#ifdef _KERNEL
+#include <sys/mutex.h>
+#include <sys/queue.h>
+#endif
+
+#ifdef _KERNEL
+#include <sys/rngtest.h>
+#endif
+
+#define RND_DEV_RANDOM 0 /* minor devices for random and kinda random */
+#define RND_DEV_URANDOM 1
+
+/*
+ * Exposed "size" of entropy pool, for convenience in load/save
+ * from userspace. Do not assume this is the same as the actual in-kernel
+ * pool size!
+ */
+#define RND_SAVEWORDS 128
+typedef struct {
+ uint32_t entropy;
+ uint8_t data[RND_SAVEWORDS * sizeof(uint32_t)];
+ uint8_t digest[SHA1_DIGEST_LENGTH];
+} rndsave_t;
+
+/* Statistics exposed by RNDGETPOOLSTAT */
+typedef struct
+{
+ uint32_t poolsize;
+ uint32_t threshold;
+ uint32_t maxentropy;
+
+ uint32_t added;
+ uint32_t curentropy;
+ uint32_t removed;
+ uint32_t discarded;
+ uint32_t generated;
+} rndpoolstat_t;
+
+/* Sanitized random source view for userspace */
+typedef struct {
+ char name[16]; /* device name */
+ uint32_t total; /* entropy from this source */
+ uint32_t type; /* type */
+ uint32_t flags; /* flags */
+} rndsource_t;
+
+/*
+ * Flags to control the source. Low byte is type, upper bits are flags.
+ */
+#define RND_FLAG_NO_ESTIMATE 0x00000100 /* don't estimate entropy */
+#define RND_FLAG_NO_COLLECT 0x00000200 /* don't collect entropy */
+
+#define RND_TYPE_UNKNOWN 0 /* unknown source */
+#define RND_TYPE_DISK 1 /* source is physical disk */
+#define RND_TYPE_NET 2 /* source is a network device */
+#define RND_TYPE_TAPE 3 /* source is a tape drive */
+#define RND_TYPE_TTY 4 /* source is a tty device */
+#define RND_TYPE_RNG 5 /* source is a hardware RNG */
+#define RND_TYPE_SKEW 6 /* source is skew between clocks */
+#define RND_TYPE_ENV 7 /* source is temp or fan sensor */
+#define RND_TYPE_VM 8 /* source is VM system events */
+#define RND_TYPE_POWER 9 /* source is power events */
+#define RND_TYPE_MAX 9 /* last type id used */
+
+#ifdef _KERNEL
+/*
+ * Size of entropy pool in 32-bit words. This _MUST_ be a power of 2. Don't
+ * change this unless you really know what you are doing...
+ */
+#ifndef RND_POOLWORDS
+#define RND_POOLWORDS 128
+#endif
+#define RND_POOLBITS (RND_POOLWORDS * 32)
+
+typedef struct krndsource {
+ LIST_ENTRY(krndsource) list; /* the linked list */
+ char name[16]; /* device name */
+ uint32_t last_time; /* last time recorded */
+ uint32_t last_delta; /* last delta value */
+ uint32_t last_delta2; /* last delta2 value */
+ uint32_t total; /* entropy from this source */
+ uint32_t type; /* type */
+ uint32_t flags; /* flags */
+ void *state; /* state information */
+ size_t test_cnt; /* how much test data accumulated? */
+ rngtest_t *test; /* test data for RNG type sources */
+} krndsource_t;
+
+enum rsink_st {
+ RSTATE_IDLE = 0,
+ RSTATE_PENDING,
+ RSTATE_HASBITS
+};
+
+typedef struct rndsink {
+ TAILQ_ENTRY(rndsink) tailq; /* the queue */
+ kmutex_t mtx; /* lock to seed or unregister */
+ enum rsink_st state; /* in-use? filled? */
+ void (*cb)(void *); /* callback function when ready */
+ void *arg; /* callback function argument */
+ char name[16]; /* sink name */
+ size_t len; /* how many bytes wanted/supplied */
+ uint8_t data[64]; /* random data returned here */
+} rndsink_t;
+
+typedef struct {
+ uint32_t cursor; /* current add point in the pool */
+ uint32_t rotate; /* how many bits to rotate by */
+ rndpoolstat_t stats; /* current statistics */
+ uint32_t pool[RND_POOLWORDS]; /* random pool data */
+} rndpool_t;
+
+#define RND_ENABLED(rp) \
+ (((rp)->flags & RND_FLAG_NO_COLLECT) == 0)
+
+void rndpool_init(rndpool_t *);
+void rndpool_init_global(void);
+uint32_t rndpool_get_entropy_count(rndpool_t *);
+void rndpool_get_stats(rndpool_t *, void *, int);
+void rndpool_increment_entropy_count(rndpool_t *, uint32_t);
+uint32_t *rndpool_get_pool(rndpool_t *);
+uint32_t rndpool_get_poolsize(void);
+void rndpool_add_data(rndpool_t *, void *, uint32_t, uint32_t);
+uint32_t rndpool_extract_data(rndpool_t *, void *, uint32_t, uint32_t);
+void rnd_init(void);
+void _rnd_add_uint32(krndsource_t *, uint32_t);
+void rnd_add_data(krndsource_t *, const void *const, uint32_t,
+ uint32_t);
+void rnd_attach_source(krndsource_t *, const char *,
+ uint32_t, uint32_t);
+void rnd_detach_source(krndsource_t *);
+
+void rndsink_attach(rndsink_t *);
+void rndsink_detach(rndsink_t *);
+
+void rnd_seed(void *, size_t);
+
+static inline void
+rnd_add_uint32(krndsource_t *kr, uint32_t val)
+{
+ if (RND_ENABLED(kr)) {
+ _rnd_add_uint32(kr, val);
+ }
+}
+
+extern int rnd_full;
+extern int rnd_filled;
+extern int rnd_initial_entropy;
+
+#endif /* _KERNEL */
+
+#define RND_MAXSTATCOUNT 10 /* 10 sources at once max */
+
+/*
+ * return "count" random entries, starting at "start"
+ */
+typedef struct {
+ uint32_t start;
+ uint32_t count;
+ rndsource_t source[RND_MAXSTATCOUNT];
+} rndstat_t;
+
+/*
+ * return information on a specific source by name
+ */
+typedef struct {
+ char name[16];
+ rndsource_t source;
+} rndstat_name_t;
+
+/*
+ * set/clear device flags. If type is set to 0xff, the name is used
+ * instead. Otherwise, the flags set/cleared apply to all devices of
+ * the specified type, and the name is ignored.
+ */
+typedef struct {
+ char name[16]; /* the name we are adjusting */
+ uint32_t type; /* the type of device we want */
+ uint32_t flags; /* flags to set or clear */
+ uint32_t mask; /* mask for the flags we are setting */
+} rndctl_t;
+
+/*
+ * Add entropy to the pool. len is the data length, in bytes.
+ * entropy is the number of bits of estimated entropy in the data.
+ */
+typedef struct {
+ uint32_t len;
+ uint32_t entropy;
+ u_char data[RND_SAVEWORDS * sizeof(uint32_t)];
+} rnddata_t;
+
+#define RNDGETENTCNT _IOR('R', 101, uint32_t) /* get entropy count */
+#define RNDGETSRCNUM _IOWR('R', 102, rndstat_t) /* get rnd source info */
+#define RNDGETSRCNAME _IOWR('R', 103, rndstat_name_t) /* get src by name */
+#define RNDCTL _IOW('R', 104, rndctl_t) /* set/clear source flags */
+#define RNDADDDATA _IOW('R', 105, rnddata_t) /* add data to the pool */
+#define RNDGETPOOLSTAT _IOR('R', 106, rndpoolstat_t) /* get statistics */
+
+#endif /* !_SYS_RND_H_ */
--- /dev/null
+/* $NetBSD: rngtest.h,v 1.1 2011/11/19 22:51:31 tls Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Thor Lancelot Simon.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _RNGTEST_H
+#define _RNGTEST_H
+
+#include <sys/types.h>
+
+#define FIPS140_RNG_TEST_BITS 20000
+#define FIPS140_RNG_TEST_BYTES (FIPS140_RNG_TEST_BITS / NBBY)
+
+typedef struct {
+ uint8_t rt_b[FIPS140_RNG_TEST_BYTES];
+ int rt_poker[16];
+ int rt_runs[2][7];
+ int rt_nerrs;
+ char rt_name[16];
+} rngtest_t;
+
+int rngtest(rngtest_t *const);
+
+#endif
--- /dev/null
+/* $NetBSD: rpst.h,v 1.3 2011/04/14 15:31:20 yamt Exp $ */
+
+/*-
+ * Copyright (c)2009 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_RPST_H_)
+#define _SYS_RPST_H_
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/types.h>
+#else /* defined(_KERNEL) || defined(_STANDALONE) */
+#include <stdint.h>
+#endif /* defined(_KERNEL) || defined(_STANDALONE) */
+
+struct rpst_tree {
+ struct rpst_node *t_root;
+ unsigned int t_height;
+};
+
+struct rpst_node {
+ struct rpst_node *n_parent;
+ struct rpst_node *n_children[2];
+ uint64_t n_y;
+ uint64_t n_x;
+};
+
+struct rpst_iterator {
+ struct rpst_tree *it_tree;
+ struct rpst_node *it_cur;
+ unsigned int it_idx;
+ unsigned int it_level;
+ uint64_t it_max_y;
+ uint64_t it_min_x;
+ uint64_t it_max_x;
+};
+
+void rpst_init_tree(struct rpst_tree *);
+struct rpst_node *rpst_insert_node(struct rpst_tree *, struct rpst_node *);
+void rpst_remove_node(struct rpst_tree *, struct rpst_node *);
+struct rpst_node *rpst_iterate_first(struct rpst_tree *, uint64_t, uint64_t,
+ uint64_t, struct rpst_iterator *);
+struct rpst_node *rpst_iterate_next(struct rpst_iterator *);
+
+#endif /* !defined(_SYS_RPST_H_) */
--- /dev/null
+/* $NetBSD: scanio.h,v 1.2 1998/02/10 00:25:44 perry Exp $ */
+
+/*
+ * Copyright (c) 1995 Kenneth Stailey. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Kenneth Stailey.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Definitions for PINT scanner drivers
+ */
+
+#ifndef _SYS_SCANIO_H_
+#define _SYS_SCANIO_H_
+
+/*
+ * XXX scancap make this sort of obsolete:
+ *
+ * Some comments about the values in the scan_io struct:
+ *
+ * All user-changeable values have minimum and maximum values for
+ * specific scanner types and are rejected by the special drivers if
+ * they are not in range. For values in the range, the driver selects
+ * the next physically possible setting for the particular scanner.
+ * So it is good practice to issue a SCIOCGET after a SCIOCSET to see
+ * what the driver has chosen.
+ *
+ * Brightness and contrast default to 100 (%) but scanners may support
+ * higher and/or lower values, though the maximum value is 255.
+ * velocity is the scan speed and defaults to 100 (%), only slower
+ * values may be possible.
+ */
+
+struct scan_io {
+ u_long scan_width; /* width in 1/1200ths of an inch */
+ u_long scan_height; /* height in 1/1200ths of an inch */
+#ifdef SCAN_BC
+# define scan_window_width scan_width
+# define scan_window_length scan_height
+#endif
+ u_short scan_x_resolution; /* horizontal resolution in dots-per-inch */
+ u_short scan_y_resolution; /* vertical resolution in dots-per-inch */
+ u_long scan_x_origin; /* horizontal coordinate of upper left corner */
+ u_long scan_y_origin; /* vertical coordinate of upper left corner */
+ u_char scan_image_mode; /* type of image data sent by scanner */
+ u_char scan_brightness; /* brightness control for those to can do it */
+ u_char scan_contrast; /* contrast control for those to can do it */
+ u_char scan_quality; /* speed of scan for instance */
+#ifdef SCAN_BC
+# define scan_velocity scan_quality
+#endif
+ u_long scan_window_size; /* size of window in bytes (ro) */
+ u_long scan_lines; /* number of pixels per column (ro) */
+ u_long scan_pixels_per_line; /* number of pixels per line (ro) */
+ u_short scan_bits_per_pixel; /* number of bits per pixel (ro) */
+ u_char scan_scanner_type; /* type of scanner (ro) */
+};
+
+/*
+ * defines for different commands
+ */
+
+#define SCIOCGET _IOR('S', 1, struct scan_io) /* retrieve parameters */
+#define SCIOCSET _IOW('S', 2, struct scan_io) /* set parameters */
+#define SCIOCRESTART _IO('S', 3) /* restart scan */
+#define SCIOC_USE_ADF _IO('S', 4) /* use ADF as paper source for next scan */
+ /* even after close() */
+#ifdef SCAN_BC
+# define SCAN_GET SCIOCGET
+# define SCAN_SET SCIOCSET
+# define SCAN_REWIND SCIOCRESTART
+# define SCAN_USE_ADF SCIOC_USE_ADF
+#endif
+
+/*
+ * defines for scan_image_mode field
+ */
+
+#define SIM_BINARY_MONOCHROME 0
+#define SIM_DITHERED_MONOCHROME 1
+#define SIM_GRAYSCALE 2
+#define SIM_COLOR 5
+#define SIM_RED 103
+#define SIM_GREEN 104
+#define SIM_BLUE 105
+
+/*
+ * defines for different types of scanners & product names as comments
+ */
+
+#define RICOH_IS410 1 /* Ricoh IS-410 */
+#define FUJITSU_M3096G 2 /* Fujitsu M3096G */
+#ifdef SCAN_BC
+# define FUJITSU 2 /* Fujitsu M3096G (deprecated) */
+#endif
+#define HP_SCANJET_IIC 3 /* HP ScanJet IIc */
+#define RICOH_FS1 4 /* Ricoh FS1 */
+#define SHARP_JX600 5 /* Sharp JX600 */
+#define RICOH_IS50 6 /* Ricoh IS-50 */
+#define IBM_2456 7 /* IBM 2456 */
+#define UMAX_UC630 8 /* UMAX UC630 */
+#define UMAX_UG630 9 /* UMAX UG630 */
+#define MUSTEK_06000CX 10 /* Mustek MFS06000CX */
+#define MUSTEK_12000CX 11 /* Mustek MFS12000CX */
+#define EPSON_ES300C 12 /* epson es300c */
+
+#endif /* _SYS_SCANIO_H_ */
--- /dev/null
+/* $NetBSD: sched.h,v 1.75 2011/11/21 04:36:05 christos Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2000, 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ross Harvey, Jason R. Thorpe, Nathan J. Williams, Andrew Doran and
+ * Daniel Sieger.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_SCHED_H_
+#define _SYS_SCHED_H_
+
+#include <sys/featuretest.h>
+#include <sys/types.h>
+
+#if defined(_KERNEL_OPT)
+#include "opt_multiprocessor.h"
+#include "opt_lockdebug.h"
+#endif
+
+struct sched_param {
+ int sched_priority;
+};
+
+/*
+ * Scheduling policies required by IEEE Std 1003.1-2001
+ */
+#define SCHED_NONE -1
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+
+#if defined(_NETBSD_SOURCE)
+__BEGIN_DECLS
+
+/*
+ * Interface of CPU-sets.
+ */
+typedef struct _cpuset cpuset_t;
+
+#ifndef _KERNEL
+
+#define cpuset_create() _cpuset_create()
+#define cpuset_destroy(c) _cpuset_destroy(c)
+#define cpuset_size(c) _cpuset_size(c)
+#define cpuset_zero(c) _cpuset_zero(c)
+#define cpuset_isset(i, c) _cpuset_isset(i, c)
+#define cpuset_set(i, c) _cpuset_set(i, c)
+#define cpuset_clr(i, c) _cpuset_clr(i, c)
+
+cpuset_t *_cpuset_create(void);
+void _cpuset_destroy(cpuset_t *);
+void _cpuset_zero(cpuset_t *);
+int _cpuset_set(cpuid_t, cpuset_t *);
+int _cpuset_clr(cpuid_t, cpuset_t *);
+int _cpuset_isset(cpuid_t, const cpuset_t *);
+size_t _cpuset_size(const cpuset_t *);
+
+#endif
+
+/*
+ * Internal affinity and scheduling calls.
+ */
+int _sched_getaffinity(pid_t, lwpid_t, size_t, cpuset_t *);
+int _sched_setaffinity(pid_t, lwpid_t, size_t, const cpuset_t *);
+int _sched_getparam(pid_t, lwpid_t, int *, struct sched_param *);
+int _sched_setparam(pid_t, lwpid_t, int, const struct sched_param *);
+__END_DECLS
+
+/*
+ * CPU states.
+ * XXX Not really scheduler state, but no other good place to put
+ * it right now, and it really is per-CPU.
+ */
+#define CP_USER 0
+#define CP_NICE 1
+#define CP_SYS 2
+#define CP_INTR 3
+#define CP_IDLE 4
+#define CPUSTATES 5
+
+#if defined(_KERNEL) || defined(_KMEMUSER)
+
+#include <sys/mutex.h>
+#include <sys/time.h>
+
+/*
+ * Per-CPU scheduler state. Field markings and the corresponding locks:
+ *
+ * s: splsched, may only be safely accessed by the CPU itself
+ * m: spc_mutex
+ * (: unlocked, stable
+ * c: cpu_lock
+ */
+struct schedstate_percpu {
+ /* First set of data is likely to be accessed by other CPUs. */
+ kmutex_t *spc_mutex; /* (: lock on below, runnable LWPs */
+ kmutex_t *spc_lwplock; /* (: general purpose lock for LWPs */
+ struct lwp *spc_migrating; /* (: migrating LWP */
+ pri_t spc_curpriority;/* m: usrpri of curlwp */
+ pri_t spc_maxpriority;/* m: highest priority queued */
+ psetid_t spc_psid; /* c: processor-set ID */
+ time_t spc_lastmod; /* c: time of last cpu state change */
+
+ /* For the most part, this set of data is CPU-private. */
+ void *spc_sched_info;/* (: scheduler-specific structure */
+ volatile int spc_flags; /* s: flags; see below */
+ u_int spc_schedticks; /* s: ticks for schedclock() */
+ uint64_t spc_cp_time[CPUSTATES];/* s: CPU state statistics */
+ int spc_ticks; /* s: ticks until sched_tick() */
+ int spc_pscnt; /* s: prof/stat counter */
+ int spc_psdiv; /* s: prof/stat divisor */
+};
+
+/* spc_flags */
+#define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */
+#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */
+#define SPCF_OFFLINE 0x0004 /* CPU marked offline */
+#define SPCF_RUNNING 0x0008 /* CPU is running */
+#define SPCF_NOINTR 0x0010 /* shielded from interrupts */
+
+#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD)
+
+#endif /* defined(_KERNEL) || defined(_KMEMUSER) */
+
+/*
+ * Flags passed to the Linux-compatible __clone(2) system call.
+ */
+#define CLONE_CSIGNAL 0x000000ff /* signal to be sent at exit */
+#define CLONE_VM 0x00000100 /* share address space */
+#define CLONE_FS 0x00000200 /* share "file system" info */
+#define CLONE_FILES 0x00000400 /* share file descriptors */
+#define CLONE_SIGHAND 0x00000800 /* share signal actions */
+#define CLONE_PID 0x00001000 /* share process ID */
+#define CLONE_PTRACE 0x00002000 /* ptrace(2) continues on
+ child */
+#define CLONE_VFORK 0x00004000 /* parent blocks until child
+ exits */
+
+#endif /* _NETBSD_SOURCE */
+
+#ifdef _KERNEL
+
+extern int schedhz; /* ideally: 16 */
+
+struct proc;
+struct cpu_info;
+
+/*
+ * Common Scheduler Interface.
+ */
+
+/* Scheduler initialization */
+void runq_init(void);
+void synch_init(void);
+void sched_init(void);
+void sched_rqinit(void);
+void sched_cpuattach(struct cpu_info *);
+
+/* Time-driven events */
+void sched_tick(struct cpu_info *);
+void schedclock(struct lwp *);
+void sched_schedclock(struct lwp *);
+void sched_pstats(void);
+void sched_lwp_stats(struct lwp *);
+void sched_pstats_hook(struct lwp *, int);
+
+/* Runqueue-related functions */
+bool sched_curcpu_runnable_p(void);
+void sched_dequeue(struct lwp *);
+void sched_enqueue(struct lwp *, bool);
+struct lwp * sched_nextlwp(void);
+void sched_oncpu(struct lwp *);
+void sched_newts(struct lwp *);
+
+/* Priority adjustment */
+void sched_nice(struct proc *, int);
+
+/* Handlers of fork and exit */
+void sched_proc_fork(struct proc *, struct proc *);
+void sched_proc_exit(struct proc *, struct proc *);
+void sched_lwp_fork(struct lwp *, struct lwp *);
+void sched_lwp_collect(struct lwp *);
+
+void sched_slept(struct lwp *);
+void sched_wakeup(struct lwp *);
+
+void setrunnable(struct lwp *);
+void sched_setrunnable(struct lwp *);
+
+struct cpu_info *sched_takecpu(struct lwp *);
+void sched_print_runqueue(void (*pr)(const char *, ...)
+ __printflike(1, 2));
+
+/* Dispatching */
+bool kpreempt(uintptr_t);
+void preempt(void);
+void yield(void);
+int mi_switch(struct lwp *);
+void updatertime(lwp_t *, const struct bintime *);
+void sched_idle(void);
+void suspendsched(void);
+
+int do_sched_setparam(pid_t, lwpid_t, int, const struct sched_param *);
+int do_sched_getparam(pid_t, lwpid_t, int *, struct sched_param *);
+
+#endif /* _KERNEL */
+#endif /* _SYS_SCHED_H_ */
--- /dev/null
+/* $NetBSD: scsiio.h,v 1.12 2007/03/04 06:03:41 christos Exp $ */
+
+#ifndef _SYS_SCSIIO_H_
+#define _SYS_SCSIIO_H_
+
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#define SENSEBUFLEN 48
+
+typedef struct scsireq {
+ u_long flags; /* info about the request status and type */
+ u_long timeout;
+ u_char cmd[16]; /* 12 is actually the max */
+ u_char cmdlen;
+ void * databuf; /* address in user space of buffer */
+ u_long datalen; /* size of user buffer (request) */
+ u_long datalen_used; /* size of user buffer (used)*/
+ u_char sense[SENSEBUFLEN]; /* returned sense will be in here */
+ u_char senselen; /* sensedata request size (MAX of SENSEBUFLEN)*/
+ u_char senselen_used; /* return value only */
+ u_char status; /* what the scsi status was from the adapter */
+ u_char retsts; /* the return status for the command */
+ int error; /* error bits */
+} scsireq_t;
+
+/* bit definitions for flags */
+#define SCCMD_READ 0x00000001
+#define SCCMD_WRITE 0x00000002
+#define SCCMD_IOV 0x00000004
+#define SCCMD_ESCAPE 0x00000010
+#define SCCMD_TARGET 0x00000020
+
+
+/* definitions for the return status (retsts) */
+#define SCCMD_OK 0x00
+#define SCCMD_TIMEOUT 0x01
+#define SCCMD_BUSY 0x02
+#define SCCMD_SENSE 0x03
+#define SCCMD_UNKNOWN 0x04
+
+#define SCIOCCOMMAND _IOWR('Q', 1, scsireq_t)
+
+#define SC_DB_CMDS 0x00000001 /* show all scsi cmds and errors */
+#define SC_DB_FLOW 0x00000002 /* show routines entered */
+#define SC_DB_FLOW2 0x00000004 /* show path INSIDE routines */
+#define SC_DB_DMA 0x00000008 /* show DMA segments etc */
+#define SCIOCDEBUG _IOW('Q', 2, int) /* from 0 to 15 */
+
+struct oscsi_addr {
+ int scbus; /* -1 if wildcard */
+ int target; /* -1 if wildcard */
+ int lun; /* -1 if wildcard */
+};
+
+struct scsi_addr {
+ int type; /* bus type */
+#define TYPE_SCSI 0
+#define TYPE_ATAPI 1
+ union {
+ struct oscsi_addr scsi;
+ struct _atapi {
+ int atbus; /* -1 if wildcard */
+ int drive; /* -1 if wildcard */
+ } atapi;
+ } addr;
+};
+
+/*
+ * SCSI device ioctls
+ */
+
+#define SCIOCIDENTIFY _IOR('Q', 4, struct scsi_addr) /* where are you? */
+#define OSCIOCIDENTIFY _IOR('Q', 4, struct oscsi_addr)
+#define SCIOCDECONFIG _IO('Q', 5) /* please disappear */
+#define SCIOCRECONFIG _IO('Q', 6) /* please check again */
+#define SCIOCRESET _IO('Q', 7) /* reset the device */
+
+/*
+ * SCSI bus ioctls
+ */
+
+/* Scan bus for new devices. */
+struct scbusioscan_args {
+ int sa_target; /* target to scan; -1 for wildcard */
+ int sa_lun; /* lun to scan; -1 for wildcard */
+};
+#define SCBUSIOSCAN _IOW('U', 0, struct scbusioscan_args)
+
+#define SCBUSIORESET _IO('U', 1) /* reset SCSI bus */
+
+struct scbusiodetach_args {
+ int sa_target; /* target to scan; -1 for wildcard */
+ int sa_lun; /* lun to scan; -1 for wildcard */
+};
+#define SCBUSIODETACH _IOW('U', 2, struct scbusiodetach_args)
+
+/* enable/disable device properties */
+struct scbusaccel_args {
+ int sa_target; /* target to set property on */
+ int sa_lun; /* lun to set property on */
+ int sa_flags; /* flags to set or clear */
+};
+#define SC_ACCEL_SYNC 0x01 /* enable sync mode */
+#define SC_ACCEL_WIDE 0x02 /* enable wide transfers */
+#define SC_ACCEL_TAGS 0x04 /* enable tagged queuing */
+#define SCBUSACCEL _IOW('U', 2, struct scbusaccel_args)
+
+#define SCBUSIOLLSCAN _IO('U', 3) /* perform low-level scan */
+
+#endif /* _SYS_SCSIIO_H_ */
--- /dev/null
+/* $NetBSD: sdt.h,v 1.2 2011/12/08 22:27:36 dholland Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by CoyotePoint Systems, Inc. It was developed under contract to
+ * CoyotePoint by Darran Hunt.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SDT_H_
+#define _SDT_H_
+
+/* should be stdint.h, but this works transparently for both user and kernel */
+#include <sys/stdint.h>
+
+#if defined(_KERNEL_OPT)
+#include "opt_dtrace.h"
+#endif
+
+#define SDT_MAX_PROVIDER 1024 /* max number of SDT providers */
+#define SDT_MAX_ARGS 5 /* max number of probe arguments */
+#define SDT_MAX_NAME_SIZE 64 /* max size of provider name */
+
+typedef struct {
+ int created; /* boolean: probe created? */
+ int enabled; /* boolean: probe enabled? */
+ int id; /* dtrace provided probe id */
+ const char *provider; /* provider name */
+ const char *module; /* module name */
+ const char *function; /* function name */
+ const char *name; /* probe name */
+ const char *argv[SDT_MAX_ARGS]; /* probe argument types */
+ const char *argx[SDT_MAX_ARGS]; /* probe argument xlate types */
+} sdt_probe_t;
+
+
+/*
+ * This type definition must match that of dtrace_probe. It is defined this
+ * way to avoid having to rely on CDDL code.
+ */
+typedef void (*sdt_probe_func_t)(u_int32_t, uintptr_t arg0, uintptr_t arg1,
+ uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
+
+/*
+ * The hook for the probe function. See kern_sdt.c which defaults this to
+ * it's own stub. The 'sdt' provider will set it to dtrace_probe when it
+ * loads.
+ */
+extern sdt_probe_func_t sdt_probe_func;
+
+
+#define SDT_NAME(prov, mod, func, name) \
+ prov##_##mod##_##func##_##name
+
+#ifdef KDTRACE_HOOKS
+/*
+ * SDT_PROBE_DEFINE(prov, mod, func, name,
+ * arg0, argx0, arg1, argx1,
+ * arg2, argx2, arg3, argx3, arg4, argx4)
+ *
+ * prov - provider name
+ * mod - module name
+ * func - function name
+ * name - probe name
+ * arg0 - arg4, argument types as strings, or NULL.
+ * argx0 - argx4, translation types for arg0 - arg4
+ *
+ * e.g. SDT_PROBE_DEFINE(l7, l7lb, l7lb_create_node,
+ * "void *", NULL,
+ * NULL, NULL, NULL, NULL,
+ * NULL, NULL, NULL NULL, )
+ *
+ * This is used in the target module to define probes to be used.
+ * The translation type should be set to NULL if not used.
+ */
+#define SDT_PROBE_DEFINE(prov, mod, func, name, \
+ arg0, argx0, arg1, argx1, arg2, argx2, \
+ arg3, argx3, arg4, argx4) \
+ sdt_probe_t SDT_NAME(prov, mod, func, name) = { \
+ 0, 0, 0, #prov, #mod, #func, #name, \
+ { arg0, arg1, arg2, arg3, arg4 }, \
+ { NULL, NULL, NULL, NULL, NULL } \
+ }
+
+/* Use this in this module to declare probes defined in the kernel. */
+#define SDT_PROBE_DECLARE(prov, mod, func, name) \
+ extern sdt_probe_t SDT_NAME(prov, mod, func, name);
+
+/* Use this in the target modules to provide instrumentation points */
+#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
+ if (__predict_false(SDT_NAME(prov, mod, func, name).enabled)) { \
+ (*sdt_probe_func)(SDT_NAME(prov, mod, func, name).id, \
+ (uintptr_t)(arg0), (uintptr_t)(arg1), (uintptr_t)(arg2), \
+ (uintptr_t)(arg3), (uintptr_t)(arg4)); \
+ }
+#else
+#define SDT_PROBE_DEFINE(prov, mod, func, name, \
+ arg0, argx0, arg1, argx1, arg2, argx2, \
+ arg3, argx3, arg4, argx4)
+#define SDT_PROBE_DECLARE(prov, mod, func, name)
+#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
+#endif
+
+void sdt_init(void *);
+void sdt_exit(void);
+
+#endif
--- /dev/null
+/* $NetBSD: selinfo.h,v 1.8 2010/07/08 12:23:31 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)select.h 8.2 (Berkeley) 1/4/94
+* from: NetBSD: select.h,v 1.21 2005/03/10 00:25:45 kleink Exp
+ */
+
+#ifndef _SYS_SELINFO_H_
+#define _SYS_SELINFO_H_
+
+#include <sys/event.h> /* for struct klist */
+
+/*
+ * Used to maintain information about processes that wish to be
+ * notified when I/O becomes possible.
+ */
+struct selinfo {
+ struct klist sel_klist; /* knotes attached to this selinfo */
+ void *sel_cluster; /* current cluster association */
+ struct lwp *sel_lwp; /* first LWP to be notified */
+ uintptr_t sel_fdinfo; /* selected descriptor by first LWP */
+ SLIST_ENTRY(selinfo) sel_chain; /* entry on LWP's list of selinfo */
+ uint32_t sel_collision; /* mask of colliding cpus */
+ uint32_t sel_reserved[3];/* reserved for future expansion */
+};
+
+#endif /* !_SYS_SELINFO_H_ */
--- /dev/null
+/* $NetBSD: signalvar.h,v 1.83 2012/02/19 21:07:00 rmind Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)signalvar.h 8.6 (Berkeley) 2/19/95
+ */
+
+#ifndef _SYS_SIGNALVAR_H_
+#define _SYS_SIGNALVAR_H_
+
+#include <sys/siginfo.h>
+#include <sys/queue.h>
+#include <sys/mutex.h>
+
+/*
+ * Kernel signal definitions and data structures,
+ * not exported to user programs.
+ */
+
+/*
+ * Queue of signals.
+ */
+typedef CIRCLEQ_HEAD(ksiginfoq, ksiginfo) ksiginfoq_t;
+
+/*
+ * Process signal actions, possibly shared between processes.
+ */
+struct sigacts {
+ struct sigact_sigdesc {
+ struct sigaction sd_sigact;
+ const void *sd_tramp;
+ int sd_vers;
+ } sa_sigdesc[NSIG]; /* disposition of signals */
+
+ int sa_refcnt; /* reference count */
+ kmutex_t sa_mutex; /* lock on sa_refcnt */
+};
+
+/*
+ * Pending signals, per LWP and per process.
+ */
+typedef struct sigpend {
+ ksiginfoq_t sp_info;
+ sigset_t sp_set;
+} sigpend_t;
+
+/*
+ * Process signal state.
+ */
+struct sigctx {
+ int ps_signo; /* for core dump/debugger XXX */
+ int ps_code; /* for core dump/debugger XXX */
+ int ps_lwp; /* for core dump/debugger XXX */
+ void *ps_sigcode; /* address of signal trampoline */
+ sigset_t ps_sigignore; /* Signals being ignored. */
+ sigset_t ps_sigcatch; /* Signals being caught by user. */
+};
+
+#ifndef __minix
+/* additional signal action values, used only temporarily/internally */
+#define SIG_CATCH (void (*)(int))2
+#endif
+
+/*
+ * get signal action for process and signal; currently only for current process
+ */
+#define SIGACTION(p, sig) (p->p_sigacts->sa_sigdesc[(sig)].sd_sigact)
+#define SIGACTION_PS(ps, sig) (ps->sa_sigdesc[(sig)].sd_sigact)
+
+/*
+ * Signal properties and actions.
+ * The array below categorizes the signals and their default actions
+ * according to the following properties:
+ */
+#define SA_KILL 0x0001 /* terminates process by default */
+#define SA_CORE 0x0002 /* ditto and coredumps */
+#define SA_STOP 0x0004 /* suspend process */
+#define SA_TTYSTOP 0x0008 /* ditto, from tty */
+#define SA_IGNORE 0x0010 /* ignore by default */
+#define SA_CONT 0x0020 /* continue if suspended */
+#define SA_CANTMASK 0x0040 /* non-maskable, catchable */
+#define SA_NORESET 0x0080 /* not reset when caught */
+#define SA_TOLWP 0x0100 /* to LWP that generated, if local */
+#define SA_TOALL 0x0200 /* always to all LWPs */
+
+#ifdef _KERNEL
+
+#include <sys/systm.h> /* for copyin_t/copyout_t */
+
+extern sigset_t contsigmask, sigcantmask;
+
+struct vnode;
+
+/*
+ * Machine-independent functions:
+ */
+int coredump_netbsd(struct lwp *, void *);
+void execsigs(struct proc *);
+int issignal(struct lwp *);
+void pgsignal(struct pgrp *, int, int);
+void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
+void postsig(int);
+void psignal(struct proc *, int);
+void kpsignal(struct proc *, struct ksiginfo *, void *);
+void child_psignal(struct proc *, int);
+void siginit(struct proc *);
+void trapsignal(struct lwp *, struct ksiginfo *);
+void sigexit(struct lwp *, int);
+void killproc(struct proc *, const char *);
+void setsigvec(struct proc *, int, struct sigaction *);
+int killpg1(struct lwp *, struct ksiginfo *, int, int);
+void proc_unstop(struct proc *p);
+
+int sigaction1(struct lwp *, int, const struct sigaction *,
+ struct sigaction *, const void *, int);
+int sigprocmask1(struct lwp *, int, const sigset_t *, sigset_t *);
+void sigpending1(struct lwp *, sigset_t *);
+void sigsuspendsetup(struct lwp *, const sigset_t *);
+void sigsuspendteardown(struct lwp *);
+int sigsuspend1(struct lwp *, const sigset_t *);
+int sigaltstack1(struct lwp *, const struct sigaltstack *,
+ struct sigaltstack *);
+int sigismasked(struct lwp *, int);
+
+int sigget(sigpend_t *, ksiginfo_t *, int, const sigset_t *);
+void sigclear(sigpend_t *, const sigset_t *, ksiginfoq_t *);
+void sigclearall(struct proc *, const sigset_t *, ksiginfoq_t *);
+
+void kpsignal2(struct proc *, ksiginfo_t *);
+
+void signal_init(void);
+
+struct sigacts *sigactsinit(struct proc *, int);
+void sigactsunshare(struct proc *);
+void sigactsfree(struct sigacts *);
+
+void kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *);
+void sendsig_reset(struct lwp *, int);
+void sendsig(const struct ksiginfo *, const sigset_t *);
+
+ksiginfo_t *ksiginfo_alloc(struct proc *, ksiginfo_t *, int);
+void ksiginfo_free(ksiginfo_t *);
+void ksiginfo_queue_drain0(ksiginfoq_t *);
+
+struct sys_____sigtimedwait50_args;
+int sigtimedwait1(struct lwp *, const struct sys_____sigtimedwait50_args *,
+ register_t *, copyin_t, copyout_t, copyin_t, copyout_t);
+
+void signotify(struct lwp *);
+int sigispending(struct lwp *, int);
+
+/*
+ * Machine-dependent functions:
+ */
+void sendsig_sigcontext(const struct ksiginfo *, const sigset_t *);
+void sendsig_siginfo(const struct ksiginfo *, const sigset_t *);
+
+extern struct pool ksiginfo_pool;
+
+/*
+ * Modularity / compatibility.
+ */
+extern void (*sendsig_sigcontext_vec)(const struct ksiginfo *,
+ const sigset_t *);
+extern int (*coredump_vec)(struct lwp *, const char *);
+
+/*
+ * firstsig:
+ *
+ * Return the first signal in a signal set.
+ */
+static inline int
+firstsig(const sigset_t *ss)
+{
+ int sig;
+
+ sig = ffs(ss->__bits[0]);
+ if (sig != 0)
+ return (sig);
+#if NSIG > 33
+ sig = ffs(ss->__bits[1]);
+ if (sig != 0)
+ return (sig + 32);
+#endif
+#if NSIG > 65
+ sig = ffs(ss->__bits[2]);
+ if (sig != 0)
+ return (sig + 64);
+#endif
+#if NSIG > 97
+ sig = ffs(ss->__bits[3]);
+ if (sig != 0)
+ return (sig + 96);
+#endif
+ return (0);
+}
+
+static inline void
+ksiginfo_queue_init(ksiginfoq_t *kq)
+{
+ CIRCLEQ_INIT(kq);
+}
+
+static inline void
+ksiginfo_queue_drain(ksiginfoq_t *kq)
+{
+ if (!CIRCLEQ_EMPTY(kq))
+ ksiginfo_queue_drain0(kq);
+}
+
+#endif /* _KERNEL */
+
+#ifdef _KERNEL
+#ifdef SIGPROP
+const int sigprop[NSIG] = {
+ 0, /* 0 unused */
+ SA_KILL, /* 1 SIGHUP */
+ SA_KILL, /* 2 SIGINT */
+ SA_KILL|SA_CORE, /* 3 SIGQUIT */
+ SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP, /* 4 SIGILL */
+ SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP, /* 5 SIGTRAP */
+ SA_KILL|SA_CORE, /* 6 SIGABRT */
+ SA_KILL|SA_CORE|SA_TOLWP, /* 7 SIGEMT */
+ SA_KILL|SA_CORE|SA_TOLWP, /* 8 SIGFPE */
+ SA_KILL|SA_CANTMASK|SA_TOALL, /* 9 SIGKILL */
+ SA_KILL|SA_CORE|SA_TOLWP, /* 10 SIGBUS */
+ SA_KILL|SA_CORE|SA_TOLWP, /* 11 SIGSEGV */
+ SA_KILL|SA_CORE|SA_TOLWP, /* 12 SIGSYS */
+ SA_KILL, /* 13 SIGPIPE */
+ SA_KILL, /* 14 SIGALRM */
+ SA_KILL, /* 15 SIGTERM */
+ SA_IGNORE, /* 16 SIGURG */
+ SA_STOP|SA_CANTMASK|SA_TOALL, /* 17 SIGSTOP */
+ SA_STOP|SA_TTYSTOP|SA_TOALL, /* 18 SIGTSTP */
+ SA_IGNORE|SA_CONT|SA_TOALL, /* 19 SIGCONT */
+ SA_IGNORE, /* 20 SIGCHLD */
+ SA_STOP|SA_TTYSTOP|SA_TOALL, /* 21 SIGTTIN */
+ SA_STOP|SA_TTYSTOP|SA_TOALL, /* 22 SIGTTOU */
+ SA_IGNORE, /* 23 SIGIO */
+ SA_KILL, /* 24 SIGXCPU */
+ SA_KILL, /* 25 SIGXFSZ */
+ SA_KILL, /* 26 SIGVTALRM */
+ SA_KILL, /* 27 SIGPROF */
+ SA_IGNORE, /* 28 SIGWINCH */
+ SA_IGNORE, /* 29 SIGINFO */
+ SA_KILL, /* 30 SIGUSR1 */
+ SA_KILL, /* 31 SIGUSR2 */
+ SA_IGNORE|SA_NORESET, /* 32 SIGPWR */
+ SA_KILL, /* 33 SIGRTMIN + 0 */
+ SA_KILL, /* 34 SIGRTMIN + 1 */
+ SA_KILL, /* 35 SIGRTMIN + 2 */
+ SA_KILL, /* 36 SIGRTMIN + 3 */
+ SA_KILL, /* 37 SIGRTMIN + 4 */
+ SA_KILL, /* 38 SIGRTMIN + 5 */
+ SA_KILL, /* 39 SIGRTMIN + 6 */
+ SA_KILL, /* 40 SIGRTMIN + 7 */
+ SA_KILL, /* 41 SIGRTMIN + 8 */
+ SA_KILL, /* 42 SIGRTMIN + 9 */
+ SA_KILL, /* 43 SIGRTMIN + 10 */
+ SA_KILL, /* 44 SIGRTMIN + 11 */
+ SA_KILL, /* 45 SIGRTMIN + 12 */
+ SA_KILL, /* 46 SIGRTMIN + 13 */
+ SA_KILL, /* 47 SIGRTMIN + 14 */
+ SA_KILL, /* 48 SIGRTMIN + 15 */
+ SA_KILL, /* 49 SIGRTMIN + 16 */
+ SA_KILL, /* 50 SIGRTMIN + 17 */
+ SA_KILL, /* 51 SIGRTMIN + 18 */
+ SA_KILL, /* 52 SIGRTMIN + 19 */
+ SA_KILL, /* 53 SIGRTMIN + 20 */
+ SA_KILL, /* 54 SIGRTMIN + 21 */
+ SA_KILL, /* 55 SIGRTMIN + 22 */
+ SA_KILL, /* 56 SIGRTMIN + 23 */
+ SA_KILL, /* 57 SIGRTMIN + 24 */
+ SA_KILL, /* 58 SIGRTMIN + 25 */
+ SA_KILL, /* 59 SIGRTMIN + 26 */
+ SA_KILL, /* 60 SIGRTMIN + 27 */
+ SA_KILL, /* 61 SIGRTMIN + 28 */
+ SA_KILL, /* 62 SIGRTMIN + 29 */
+ SA_KILL, /* 63 SIGRTMIN + 30 */
+};
+#undef SIGPROP
+#else
+extern const int sigprop[NSIG];
+#endif /* SIGPROP */
+#endif /* _KERNEL */
+#endif /* !_SYS_SIGNALVAR_H_ */
--- /dev/null
+/* $NetBSD: simplelock.h,v 1.8 2008/04/28 20:24:11 martin Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2000, 2006, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ross Harvey.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code contains ideas from software contributed to Berkeley by
+ * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
+ * System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)lock.h 8.12 (Berkeley) 5/19/95
+ */
+
+#ifndef _SYS_SIMPLELOCK_H_
+#define _SYS_SIMPLELOCK_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_multiprocessor.h"
+#include "opt_lockdebug.h"
+#endif
+
+#include <machine/types.h>
+#include <machine/lock.h>
+
+/*
+ * The simple lock. Provides a simple spinning mutex. Note the
+ * member which is used in atomic operations must be aligned in
+ * order for it to work on the widest range of processor types.
+ */
+struct simplelock {
+ __cpu_simple_lock_t lock_data;
+#ifdef __CPU_SIMPLE_LOCK_PAD
+ /*
+ * For binary compatibility where the lock word has been
+ * made shorter.
+ */
+ uint8_t lock_pad[3];
+#endif
+};
+
+#define SIMPLELOCK_INITIALIZER { .lock_data = __SIMPLELOCK_UNLOCKED }
+
+#ifdef _KERNEL
+
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
+#define simple_lock_init(alp) __cpu_simple_lock_init(&(alp)->lock_data)
+#define simple_lock(alp) __cpu_simple_lock(&(alp)->lock_data)
+#define simple_lock_held(alp) (__SIMPLELOCK_LOCKED_P(&(alp)->lock_data))
+#define simple_lock_try(alp) __cpu_simple_lock_try(&(alp)->lock_data)
+#define simple_unlock(alp) __cpu_simple_unlock(&(alp)->lock_data)
+#else
+#define simple_lock_nothing(alp) \
+do { \
+ (void)alp; \
+} while (0);
+#define simple_lock_init(alp) simple_lock_nothing(alp)
+#define simple_lock(alp) simple_lock_nothing(alp)
+#define simple_lock_held(alp) 1
+#define simple_lock_try(alp) 1
+#define simple_unlock(alp) simple_lock_nothing(alp)
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_SIMPLELOCK_H_ */
--- /dev/null
+/* $NetBSD: sleepq.h,v 1.22 2012/02/19 21:07:00 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe and Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SLEEPQ_H_
+#define _SYS_SLEEPQ_H_
+
+#include <sys/lwp.h>
+#include <sys/mutex.h>
+#include <sys/pool.h>
+#include <sys/queue.h>
+#include <sys/sched.h>
+#include <sys/syncobj.h>
+
+/*
+ * Generic sleep queues.
+ */
+
+#define SLEEPTAB_HASH_SHIFT 7
+#define SLEEPTAB_HASH_SIZE (1 << SLEEPTAB_HASH_SHIFT)
+#define SLEEPTAB_HASH_MASK (SLEEPTAB_HASH_SIZE - 1)
+#define SLEEPTAB_HASH(wchan) (((uintptr_t)(wchan) >> 8) & SLEEPTAB_HASH_MASK)
+
+TAILQ_HEAD(sleepq, lwp);
+
+typedef struct sleepq sleepq_t;
+
+typedef struct sleeptab {
+ struct {
+ kmutex_t *st_mutex;
+ sleepq_t st_queue;
+ } st_queues[SLEEPTAB_HASH_SIZE];
+} sleeptab_t;
+
+void sleepq_init(sleepq_t *);
+void sleepq_remove(sleepq_t *, lwp_t *);
+void sleepq_enqueue(sleepq_t *, wchan_t, const char *, syncobj_t *);
+void sleepq_unsleep(lwp_t *, bool);
+void sleepq_timeout(void *);
+lwp_t *sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *);
+int sleepq_abort(kmutex_t *, int);
+void sleepq_changepri(lwp_t *, pri_t);
+void sleepq_lendpri(lwp_t *, pri_t);
+int sleepq_block(int, bool);
+
+void sleeptab_init(sleeptab_t *);
+
+extern sleeptab_t sleeptab;
+
+/*
+ * Return non-zero if it is unsafe to sleep.
+ *
+ * XXX This only exists because panic() is broken.
+ */
+static inline bool
+sleepq_dontsleep(lwp_t *l)
+{
+ extern int cold;
+
+ return cold || (doing_shutdown && (panicstr || CURCPU_IDLE_P()));
+}
+
+/*
+ * Find the correct sleep queue for the specified wait channel. This
+ * acquires and holds the per-queue interlock.
+ */
+static inline sleepq_t *
+sleeptab_lookup(sleeptab_t *st, wchan_t wchan, kmutex_t **mp)
+{
+ sleepq_t *sq;
+
+ sq = &st->st_queues[SLEEPTAB_HASH(wchan)].st_queue;
+ *mp = st->st_queues[SLEEPTAB_HASH(wchan)].st_mutex;
+ mutex_spin_enter(*mp);
+ return sq;
+}
+
+static inline kmutex_t *
+sleepq_hashlock(wchan_t wchan)
+{
+ kmutex_t *mp;
+
+ mp = sleeptab.st_queues[SLEEPTAB_HASH(wchan)].st_mutex;
+ mutex_spin_enter(mp);
+ return mp;
+}
+
+/*
+ * Prepare to block on a sleep queue, after which any interlock can be
+ * safely released.
+ */
+static inline void
+sleepq_enter(sleepq_t *sq, lwp_t *l, kmutex_t *mp)
+{
+
+ /*
+ * Acquire the per-LWP mutex and lend it ours sleep queue lock.
+ * Once interlocked, we can release the kernel lock.
+ */
+ lwp_lock(l);
+ lwp_unlock_to(l, mp);
+ KERNEL_UNLOCK_ALL(NULL, &l->l_biglocks);
+}
+
+/*
+ * Turnstiles, specialized sleep queues for use by kernel locks.
+ */
+
+typedef struct turnstile {
+ LIST_ENTRY(turnstile) ts_chain; /* link on hash chain */
+ struct turnstile *ts_free; /* turnstile free list */
+ wchan_t ts_obj; /* lock object */
+ sleepq_t ts_sleepq[2]; /* sleep queues */
+ u_int ts_waiters[2]; /* count of waiters */
+
+ /* priority inheritance */
+ pri_t ts_eprio;
+ lwp_t *ts_inheritor;
+ SLIST_ENTRY(turnstile) ts_pichain;
+} turnstile_t;
+
+typedef struct tschain {
+ kmutex_t *tc_mutex; /* mutex on structs & queues */
+ LIST_HEAD(, turnstile) tc_chain; /* turnstile chain */
+} tschain_t;
+
+#define TS_READER_Q 0 /* reader sleep queue */
+#define TS_WRITER_Q 1 /* writer sleep queue */
+
+#define TS_WAITERS(ts, q) \
+ (ts)->ts_waiters[(q)]
+
+#define TS_ALL_WAITERS(ts) \
+ ((ts)->ts_waiters[TS_READER_Q] + \
+ (ts)->ts_waiters[TS_WRITER_Q])
+
+#define TS_FIRST(ts, q) (TAILQ_FIRST(&(ts)->ts_sleepq[(q)]))
+
+#ifdef _KERNEL
+
+void turnstile_init(void);
+turnstile_t *turnstile_lookup(wchan_t);
+void turnstile_exit(wchan_t);
+void turnstile_block(turnstile_t *, int, wchan_t, syncobj_t *);
+void turnstile_wakeup(turnstile_t *, int, int, lwp_t *);
+void turnstile_print(volatile void *, void (*)(const char *, ...)
+ __printflike(1, 2));
+void turnstile_unsleep(lwp_t *, bool);
+void turnstile_changepri(lwp_t *, pri_t);
+
+extern pool_cache_t turnstile_cache;
+extern turnstile_t turnstile0;
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_SLEEPQ_H_ */
--- /dev/null
+/* $NetBSD: socketvar.h,v 1.129 2012/02/01 02:27:23 matt Exp $ */
+
+/*-
+ * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
+ */
+
+#ifndef _SYS_SOCKETVAR_H_
+#define _SYS_SOCKETVAR_H_
+
+#include <sys/select.h>
+#include <sys/selinfo.h> /* for struct selinfo */
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+
+#if !defined(_KERNEL)
+struct uio;
+struct lwp;
+struct uidinfo;
+#else
+#include <sys/uidinfo.h>
+#endif
+
+TAILQ_HEAD(soqhead, socket);
+
+/*
+ * Variables for socket buffering.
+ */
+struct sockbuf {
+ struct selinfo sb_sel; /* process selecting read/write */
+ struct mowner *sb_mowner; /* who owns data for this sockbuf */
+ struct socket *sb_so; /* back pointer to socket */
+ kcondvar_t sb_cv; /* notifier */
+ /* When re-zeroing this struct, we zero from sb_startzero to the end */
+#define sb_startzero sb_cc
+ u_long sb_cc; /* actual chars in buffer */
+ u_long sb_hiwat; /* max actual char count */
+ u_long sb_mbcnt; /* chars of mbufs used */
+ u_long sb_mbmax; /* max chars of mbufs to use */
+ long sb_lowat; /* low water mark */
+ struct mbuf *sb_mb; /* the mbuf chain */
+ struct mbuf *sb_mbtail; /* the last mbuf in the chain */
+ struct mbuf *sb_lastrecord; /* first mbuf of last record in
+ socket buffer */
+ int sb_flags; /* flags, see below */
+ int sb_timeo; /* timeout for read/write */
+ u_long sb_overflowed; /* # of drops due to full buffer */
+};
+
+#ifndef SB_MAX
+#define SB_MAX (256*1024) /* default for max chars in sockbuf */
+#endif
+
+#define SB_LOCK 0x01 /* lock on data queue */
+#define SB_NOTIFY 0x04 /* someone is waiting for data/space */
+#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
+#define SB_UPCALL 0x20 /* someone wants an upcall */
+#define SB_NOINTR 0x40 /* operations not interruptible */
+#define SB_KNOTE 0x100 /* kernel note attached */
+#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
+
+/*
+ * Kernel structure per socket.
+ * Contains send and receive buffer queues,
+ * handle on protocol and pointer to protocol
+ * private data and error information.
+ */
+struct socket {
+ kmutex_t * volatile so_lock; /* pointer to lock on structure */
+ kcondvar_t so_cv; /* notifier */
+ short so_type; /* generic type, see socket.h */
+ short so_options; /* from socket call, see socket.h */
+ u_short so_linger; /* time to linger while closing */
+ short so_state; /* internal state flags SS_*, below */
+ int so_unused; /* used to be so_nbio */
+ void *so_pcb; /* protocol control block */
+ const struct protosw *so_proto; /* protocol handle */
+/*
+ * Variables for connection queueing.
+ * Socket where accepts occur is so_head in all subsidiary sockets.
+ * If so_head is 0, socket is not related to an accept.
+ * For head socket so_q0 queues partially completed connections,
+ * while so_q is a queue of connections ready to be accepted.
+ * If a connection is aborted and it has so_head set, then
+ * it has to be pulled out of either so_q0 or so_q.
+ * We allow connections to queue up based on current queue lengths
+ * and limit on number of queued connections for this socket.
+ */
+ struct socket *so_head; /* back pointer to accept socket */
+ struct soqhead *so_onq; /* queue (q or q0) that we're on */
+ struct soqhead so_q0; /* queue of partial connections */
+ struct soqhead so_q; /* queue of incoming connections */
+ TAILQ_ENTRY(socket) so_qe; /* our queue entry (q or q0) */
+ short so_q0len; /* partials on so_q0 */
+ short so_qlen; /* number of connections on so_q */
+ short so_qlimit; /* max number queued connections */
+ short so_timeo; /* connection timeout */
+ u_short so_error; /* error affecting connection */
+ u_short so_aborting; /* references from soabort() */
+ pid_t so_pgid; /* pgid for signals */
+ u_long so_oobmark; /* chars to oob mark */
+ struct sockbuf so_snd; /* send buffer */
+ struct sockbuf so_rcv; /* receive buffer */
+
+ void *so_internal; /* Space for svr4 stream data */
+ void (*so_upcall) (struct socket *, void *, int, int);
+ void * so_upcallarg; /* Arg for above */
+ int (*so_send) (struct socket *, struct mbuf *,
+ struct uio *, struct mbuf *,
+ struct mbuf *, int, struct lwp *);
+ int (*so_receive) (struct socket *,
+ struct mbuf **,
+ struct uio *, struct mbuf **,
+ struct mbuf **, int *);
+ struct mowner *so_mowner; /* who owns mbufs for this socket */
+ struct uidinfo *so_uidinfo; /* who opened the socket */
+ gid_t so_egid; /* creator effective gid */
+ pid_t so_cpid; /* creator pid */
+ struct so_accf {
+ struct accept_filter *so_accept_filter;
+ void *so_accept_filter_arg; /* saved filter args */
+ char *so_accept_filter_str; /* saved user args */
+ } *so_accf;
+ kauth_cred_t so_cred; /* socket credentials */
+};
+
+#define SB_EMPTY_FIXUP(sb) \
+do { \
+ KASSERT(solocked((sb)->sb_so)); \
+ if ((sb)->sb_mb == NULL) { \
+ (sb)->sb_mbtail = NULL; \
+ (sb)->sb_lastrecord = NULL; \
+ } \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Socket state bits.
+ */
+#define SS_NOFDREF 0x001 /* no file table ref any more */
+#define SS_ISCONNECTED 0x002 /* socket connected to a peer */
+#define SS_ISCONNECTING 0x004 /* in process of connecting to peer */
+#define SS_ISDISCONNECTING 0x008 /* in process of disconnecting */
+#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */
+#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */
+#define SS_RCVATMARK 0x040 /* at mark on input */
+#define SS_ISABORTING 0x080 /* aborting fd references - close() */
+#define SS_RESTARTSYS 0x100 /* restart blocked system calls */
+#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */
+
+#define SS_ASYNC 0x100 /* async i/o notify */
+#define SS_ISCONFIRMING 0x200 /* deciding to accept connection req */
+#define SS_MORETOCOME 0x400 /*
+ * hint from sosend to lower layer;
+ * more data coming
+ */
+#define SS_ISAPIPE 0x1000 /* socket is implementing a pipe */
+#define SS_NBIO 0x2000 /* socket is in non blocking I/O */
+
+#ifdef _KERNEL
+
+struct accept_filter {
+ char accf_name[16];
+ void (*accf_callback)
+ (struct socket *, void *, int, int);
+ void * (*accf_create)
+ (struct socket *, char *);
+ void (*accf_destroy)
+ (struct socket *);
+ LIST_ENTRY(accept_filter) accf_next;
+ u_int accf_refcnt;
+};
+
+struct sockopt {
+ int sopt_level; /* option level */
+ int sopt_name; /* option name */
+ size_t sopt_size; /* data length */
+ void * sopt_data; /* data pointer */
+ uint8_t sopt_buf[sizeof(int)]; /* internal storage */
+};
+
+extern u_long sb_max;
+extern int somaxkva;
+extern int sock_loan_thresh;
+extern kmutex_t *softnet_lock;
+
+struct mbuf;
+struct sockaddr;
+struct lwp;
+struct msghdr;
+struct stat;
+struct knote;
+
+struct mbuf *getsombuf(struct socket *, int);
+
+/*
+ * File operations on sockets.
+ */
+int soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+int soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+int soo_fcntl(file_t *, u_int cmd, void *);
+int soo_ioctl(file_t *, u_long cmd, void *);
+int soo_poll(file_t *, int);
+int soo_kqfilter(file_t *, struct knote *);
+int soo_close(file_t *);
+int soo_stat(file_t *, struct stat *);
+void soo_restart(file_t *);
+void sbappend(struct sockbuf *, struct mbuf *);
+void sbappendstream(struct sockbuf *, struct mbuf *);
+int sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
+ struct mbuf *);
+int sbappendaddrchain(struct sockbuf *, const struct sockaddr *,
+ struct mbuf *, int);
+int sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *);
+void sbappendrecord(struct sockbuf *, struct mbuf *);
+void sbcheck(struct sockbuf *);
+void sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *);
+struct mbuf *
+ sbcreatecontrol(void *, int, int, int);
+void sbdrop(struct sockbuf *, int);
+void sbdroprecord(struct sockbuf *);
+void sbflush(struct sockbuf *);
+void sbinsertoob(struct sockbuf *, struct mbuf *);
+void sbrelease(struct sockbuf *, struct socket *);
+int sbreserve(struct sockbuf *, u_long, struct socket *);
+int sbwait(struct sockbuf *);
+int sb_max_set(u_long);
+void soinit(void);
+void soinit1(void);
+void soinit2(void);
+int soabort(struct socket *);
+int soaccept(struct socket *, struct mbuf *);
+int sofamily(const struct socket *);
+int sobind(struct socket *, struct mbuf *, struct lwp *);
+void socantrcvmore(struct socket *);
+void socantsendmore(struct socket *);
+int soclose(struct socket *);
+int soconnect(struct socket *, struct mbuf *, struct lwp *);
+int soconnect2(struct socket *, struct socket *);
+int socreate(int, struct socket **, int, int, struct lwp *,
+ struct socket *);
+int fsocreate(int, struct socket **, int, int, struct lwp *, int *);
+int sodisconnect(struct socket *);
+void sofree(struct socket *);
+int sogetopt(struct socket *, struct sockopt *);
+void sohasoutofband(struct socket *);
+void soisconnected(struct socket *);
+void soisconnecting(struct socket *);
+void soisdisconnected(struct socket *);
+void soisdisconnecting(struct socket *);
+int solisten(struct socket *, int, struct lwp *);
+struct socket *
+ sonewconn(struct socket *, int);
+void soqinsque(struct socket *, struct socket *, int);
+int soqremque(struct socket *, int);
+int soreceive(struct socket *, struct mbuf **, struct uio *,
+ struct mbuf **, struct mbuf **, int *);
+int soreserve(struct socket *, u_long, u_long);
+void sorflush(struct socket *);
+int sosend(struct socket *, struct mbuf *, struct uio *,
+ struct mbuf *, struct mbuf *, int, struct lwp *);
+int sosetopt(struct socket *, struct sockopt *);
+int so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t);
+int soshutdown(struct socket *, int);
+void sorestart(struct socket *);
+void sowakeup(struct socket *, struct sockbuf *, int);
+int sockargs(struct mbuf **, const void *, size_t, int);
+int sopoll(struct socket *, int);
+struct socket *soget(bool);
+void soput(struct socket *);
+bool solocked(struct socket *);
+bool solocked2(struct socket *, struct socket *);
+int sblock(struct sockbuf *, int);
+void sbunlock(struct sockbuf *);
+int sowait(struct socket *, bool, int);
+void solockretry(struct socket *, kmutex_t *);
+void sosetlock(struct socket *);
+void solockreset(struct socket *, kmutex_t *);
+
+void sockopt_init(struct sockopt *, int, int, size_t);
+void sockopt_destroy(struct sockopt *);
+int sockopt_set(struct sockopt *, const void *, size_t);
+int sockopt_setint(struct sockopt *, int);
+int sockopt_get(const struct sockopt *, void *, size_t);
+int sockopt_getint(const struct sockopt *, int *);
+int sockopt_setmbuf(struct sockopt *, struct mbuf *);
+struct mbuf *sockopt_getmbuf(const struct sockopt *);
+
+int copyout_sockname(struct sockaddr *, unsigned int *, int, struct mbuf *);
+int copyout_msg_control(struct lwp *, struct msghdr *, struct mbuf *);
+void free_control_mbuf(struct lwp *, struct mbuf *, struct mbuf *);
+
+int do_sys_getsockname(struct lwp *, int, int, struct mbuf **);
+int do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *);
+int do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
+ struct mbuf **, register_t *);
+
+int do_sys_bind(struct lwp *, int, struct mbuf *);
+int do_sys_connect(struct lwp *, int, struct mbuf *);
+int do_sys_accept(struct lwp *, int, struct mbuf **, register_t *,
+ const sigset_t *, int, int);
+
+/*
+ * Inline functions for sockets and socket buffering.
+ */
+
+#include <sys/protosw.h>
+#include <sys/mbuf.h>
+
+/*
+ * Do we need to notify the other side when I/O is possible?
+ */
+static inline int
+sb_notify(struct sockbuf *sb)
+{
+
+ KASSERT(solocked(sb->sb_so));
+
+ return sb->sb_flags & (SB_NOTIFY | SB_ASYNC | SB_UPCALL | SB_KNOTE);
+}
+
+/*
+ * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
+ * This is problematical if the fields are unsigned, as the space might
+ * still be negative (cc > hiwat or mbcnt > mbmax). Should detect
+ * overflow and return 0.
+ */
+static inline long
+sbspace(struct sockbuf *sb)
+{
+
+ KASSERT(solocked(sb->sb_so));
+
+ return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt);
+}
+
+/* do we have to send all at once on a socket? */
+static inline int
+sosendallatonce(struct socket *so)
+{
+
+ return so->so_proto->pr_flags & PR_ATOMIC;
+}
+
+/* can we read something from so? */
+static inline int
+soreadable(struct socket *so)
+{
+
+ KASSERT(solocked(so));
+
+ return so->so_rcv.sb_cc >= so->so_rcv.sb_lowat ||
+ (so->so_state & SS_CANTRCVMORE) != 0 ||
+ so->so_qlen != 0 || so->so_error != 0;
+}
+
+/* can we write something to so? */
+static inline int
+sowritable(struct socket *so)
+{
+
+ KASSERT(solocked(so));
+
+ return (sbspace(&so->so_snd) >= so->so_snd.sb_lowat &&
+ ((so->so_state & SS_ISCONNECTED) != 0 ||
+ (so->so_proto->pr_flags & PR_CONNREQUIRED) == 0)) ||
+ (so->so_state & SS_CANTSENDMORE) != 0 ||
+ so->so_error != 0;
+}
+
+/* adjust counters in sb reflecting allocation of m */
+static inline void
+sballoc(struct sockbuf *sb, struct mbuf *m)
+{
+
+ KASSERT(solocked(sb->sb_so));
+
+ sb->sb_cc += m->m_len;
+ sb->sb_mbcnt += MSIZE;
+ if (m->m_flags & M_EXT)
+ sb->sb_mbcnt += m->m_ext.ext_size;
+}
+
+/* adjust counters in sb reflecting freeing of m */
+static inline void
+sbfree(struct sockbuf *sb, struct mbuf *m)
+{
+
+ KASSERT(solocked(sb->sb_so));
+
+ sb->sb_cc -= m->m_len;
+ sb->sb_mbcnt -= MSIZE;
+ if (m->m_flags & M_EXT)
+ sb->sb_mbcnt -= m->m_ext.ext_size;
+}
+
+static inline void
+sorwakeup(struct socket *so)
+{
+
+ KASSERT(solocked(so));
+
+ if (sb_notify(&so->so_rcv))
+ sowakeup(so, &so->so_rcv, POLL_IN);
+}
+
+static inline void
+sowwakeup(struct socket *so)
+{
+
+ KASSERT(solocked(so));
+
+ if (sb_notify(&so->so_snd))
+ sowakeup(so, &so->so_snd, POLL_OUT);
+}
+
+static inline void
+solock(struct socket *so)
+{
+ kmutex_t *lock;
+
+ lock = so->so_lock;
+ mutex_enter(lock);
+ if (__predict_false(lock != so->so_lock))
+ solockretry(so, lock);
+}
+
+static inline void
+sounlock(struct socket *so)
+{
+
+ mutex_exit(so->so_lock);
+}
+
+#ifdef SOCKBUF_DEBUG
+/*
+ * SBLASTRECORDCHK: check sb->sb_lastrecord is maintained correctly.
+ * SBLASTMBUFCHK: check sb->sb_mbtail is maintained correctly.
+ *
+ * => panic if the socket buffer is inconsistent.
+ * => 'where' is used for a panic message.
+ */
+void sblastrecordchk(struct sockbuf *, const char *);
+#define SBLASTRECORDCHK(sb, where) sblastrecordchk((sb), (where))
+
+void sblastmbufchk(struct sockbuf *, const char *);
+#define SBLASTMBUFCHK(sb, where) sblastmbufchk((sb), (where))
+#define SBCHECK(sb) sbcheck(sb)
+#else
+#define SBLASTRECORDCHK(sb, where) /* nothing */
+#define SBLASTMBUFCHK(sb, where) /* nothing */
+#define SBCHECK(sb) /* nothing */
+#endif /* SOCKBUF_DEBUG */
+
+/* sosend loan */
+vaddr_t sokvaalloc(vaddr_t, vsize_t, struct socket *);
+void sokvafree(vaddr_t, vsize_t);
+void soloanfree(struct mbuf *, void *, size_t, void *);
+
+/*
+ * Values for socket-buffer-append priority argument to sbappendaddrchain().
+ * The following flags are reserved for future implementation:
+ *
+ * SB_PRIO_NONE: honour normal socket-buffer limits.
+ *
+ * SB_PRIO_ONESHOT_OVERFLOW: if the socket has any space,
+ * deliver the entire chain. Intended for large requests
+ * that should be delivered in their entirety, or not at all.
+ *
+ * SB_PRIO_OVERDRAFT: allow a small (2*MLEN) overflow, over and
+ * aboce normal socket limits. Intended messages indicating
+ * buffer overflow in earlier normal/lower-priority messages .
+ *
+ * SB_PRIO_BESTEFFORT: Ignore limits entirely. Intended only for
+ * kernel-generated messages to specially-marked scokets which
+ * require "reliable" delivery, nd where the source socket/protocol
+ * message generator enforce some hard limit (but possibly well
+ * above kern.sbmax). It is entirely up to the in-kernel source to
+ * avoid complete mbuf exhaustion or DoS scenarios.
+ */
+#define SB_PRIO_NONE 0
+#define SB_PRIO_ONESHOT_OVERFLOW 1
+#define SB_PRIO_OVERDRAFT 2
+#define SB_PRIO_BESTEFFORT 3
+
+/*
+ * Accept filter functions (duh).
+ */
+int accept_filt_getopt(struct socket *, struct sockopt *);
+int accept_filt_setopt(struct socket *, const struct sockopt *);
+int accept_filt_clear(struct socket *);
+int accept_filt_add(struct accept_filter *);
+int accept_filt_del(struct accept_filter *);
+struct accept_filter *accept_filt_get(char *);
+#ifdef ACCEPT_FILTER_MOD
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_net_inet_accf);
+#endif
+void accept_filter_init(void);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_SOCKETVAR_H_ */
--- /dev/null
+/* $NetBSD: sockio.h,v 1.30 2010/11/15 22:42:36 pooka Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)sockio.h 8.1 (Berkeley) 3/28/94
+ */
+
+#ifndef _SYS_SOCKIO_H_
+#define _SYS_SOCKIO_H_
+
+#include <sys/ioccom.h>
+
+/* Socket ioctl's. */
+#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
+#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
+#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
+#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
+#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
+#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
+#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
+
+#define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
+#define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
+
+#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
+#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */
+
+#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
+#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */
+
+#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */
+
+#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */
+
+#define SIOCGIFCONF _IOWR('i', 38, struct ifconf) /* get ifnet list */
+
+#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */
+
+#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */
+
+#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */
+
+#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */
+#define SIOCGIFALIAS _IOWR('i', 27, struct ifaliasreq)/* get IF alias */
+
+#define SIOCALIFADDR _IOW('i', 28, struct if_laddrreq) /* add IF addr */
+#define SIOCGLIFADDR _IOWR('i', 29, struct if_laddrreq) /* get IF addr */
+#define SIOCDLIFADDR _IOW('i', 30, struct if_laddrreq) /* delete IF addr */
+/* get/set IF addr preference */
+#define SIOCSIFADDRPREF _IOW('i', 31, struct if_addrprefreq)
+#define SIOCGIFADDRPREF _IOWR('i', 32, struct if_addrprefreq)
+
+#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
+#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
+
+#define SIOCGETVIFCNT _IOWR('u', 51, struct sioc_vif_req)/* vif pkt cnt */
+#define SIOCGETSGCNT _IOWR('u', 52, struct sioc_sg_req) /* sg pkt cnt */
+
+#define SIOCSIFMEDIA _IOWR('i', 53, struct ifreq) /* set net media */
+#define SIOCGIFMEDIA _IOWR('i', 54, struct ifmediareq) /* get net media */
+
+#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
+#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
+
+#define SIOCSIFPHYADDR _IOW('i', 70, struct ifaliasreq) /* set gif addres */
+#define SIOCGIFPSRCADDR _IOWR('i', 71, struct ifreq) /* get gif psrc addr */
+#define SIOCGIFPDSTADDR _IOWR('i', 72, struct ifreq) /* get gif pdst addr */
+#define SIOCDIFPHYADDR _IOW('i', 73, struct ifreq) /* delete gif addrs */
+#define SIOCSLIFPHYADDR _IOW('i', 74, struct if_laddrreq) /* set gif addrs */
+#define SIOCGLIFPHYADDR _IOWR('i', 75, struct if_laddrreq) /* get gif addrs */
+
+#define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet mtu */
+#define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet mtu */
+
+/* 128 was SIOCGIFDATA */
+/* 129 was SIOCZIFDATA */
+
+/* 125 was SIOCSIFASYNCMAP */
+/* 124 was SIOCGIFASYNCMAP */
+
+#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific
+ parameters */
+#define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific
+ parameters */
+
+#define SIOCIFCREATE _IOW('i', 122, struct ifreq) /* create clone if */
+#define SIOCIFDESTROY _IOW('i', 121, struct ifreq) /* destroy clone if */
+#define SIOCIFGCLONERS _IOWR('i', 120, struct if_clonereq) /* get cloners */
+
+#define SIOCGIFDLT _IOWR('i', 119, struct ifreq) /* get DLT */
+#define SIOCGIFCAP _IOWR('i', 118, struct ifcapreq)/* get capabilities */
+#define SIOCSIFCAP _IOW('i', 117, struct ifcapreq)/* set capabilities */
+
+#define SIOCSVH _IOWR('i', 130, struct ifreq) /* set carp param */
+#define SIOCGVH _IOWR('i', 131, struct ifreq) /* get carp param */
+#define SIOCINITIFADDR _IOWR('i', 132, struct ifaddr)
+
+#define SIOCGIFDATA _IOWR('i', 133, struct ifdatareq) /* get if_data */
+#define SIOCZIFDATA _IOWR('i', 134, struct ifdatareq) /* get if_data then
+ zero ctrs*/
+
+#define SIOCGLINKSTR _IOWR('i', 135, struct ifdrv)
+#define SIOCSLINKSTR _IOW('i', 136, struct ifdrv)
+
+#define SIOCSETPFSYNC _IOW('i', 247, struct ifreq)
+#define SIOCGETPFSYNC _IOWR('i', 248, struct ifreq)
+
+#endif /* !_SYS_SOCKIO_H_ */
--- /dev/null
+/* $NetBSD: spawn.h,v 1.3 2012/04/30 21:19:58 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/spawn.h,v 1.3.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $
+ */
+
+#ifndef _SYS_SPAWN_H_
+#define _SYS_SPAWN_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/sigtypes.h>
+#include <sys/signal.h>
+#include <sys/sched.h>
+
+struct posix_spawnattr {
+ short sa_flags;
+ pid_t sa_pgroup;
+ struct sched_param sa_schedparam;
+ int sa_schedpolicy;
+ sigset_t sa_sigdefault;
+ sigset_t sa_sigmask;
+};
+
+typedef struct posix_spawn_file_actions_entry {
+ enum { FAE_OPEN, FAE_DUP2, FAE_CLOSE } fae_action;
+
+ int fae_fildes;
+ union {
+ struct {
+ char *path;
+#define fae_path fae_data.open.path
+ int oflag;
+#define fae_oflag fae_data.open.oflag
+ mode_t mode;
+#define fae_mode fae_data.open.mode
+ } open;
+ struct {
+ int newfildes;
+#define fae_newfildes fae_data.dup2.newfildes
+ } dup2;
+ } fae_data;
+} posix_spawn_file_actions_entry_t;
+
+struct posix_spawn_file_actions {
+ unsigned int size; /* size of fae array */
+ unsigned int len; /* how many slots are used */
+ posix_spawn_file_actions_entry_t *fae;
+};
+
+typedef struct posix_spawnattr posix_spawnattr_t;
+typedef struct posix_spawn_file_actions posix_spawn_file_actions_t;
+
+#define POSIX_SPAWN_RESETIDS 0x01
+#define POSIX_SPAWN_SETPGROUP 0x02
+#define POSIX_SPAWN_SETSCHEDPARAM 0x04
+#define POSIX_SPAWN_SETSCHEDULER 0x08
+#define POSIX_SPAWN_SETSIGDEF 0x10
+#define POSIX_SPAWN_SETSIGMASK 0x20
+
+#ifdef _NETBSD_SOURCE
+/*
+ * With this flag set, the kernel part of posix_spawn will not try to
+ * maximize parallelism, but instead the parent will wait for the child
+ * process to complete all file/scheduler actions and report back errors
+ * from that via the return value of the posix_spawn syscall. This is
+ * usefull for testing, as it can verify the generated error codes and
+ * match to the supposedly triggered failures.
+ * In general, the kernel will return from the posix_spawn syscall as
+ * early as possible, as soon as creating the new process is known to
+ * work. Errors might either be reported back via the return value in
+ * the parent, or (less explicit) by an error exit of the child
+ * process. Our test cases deal with both behaviours in the general
+ * case, but request the POSIX_SPAWN_RETURNERROR for some tests.
+ */
+#define POSIX_SPAWN_RETURNERROR 0x40
+#endif
+
+#endif /* !_SYS_SPAWN_H_ */
--- /dev/null
+/* $NetBSD: spl.h,v 1.9 2009/03/07 21:59:25 ad Exp $ */
+
+/*-
+ * Copyright (c)2005 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * this header is intended to be included by MD header.
+ *
+ * an assumption: makeiplcookie() is reasonably fast.
+ * if it isn't the case for your port, it's better to have MD optimized
+ * splxxx() functions, rather than using this header.
+ */
+
+#if !defined(_KERNEL) && !defined(_KMEMUSER)
+#error not supposed to be exposed to userland.
+#endif /* !defined(_KERNEL) && !defined(_KMEMUSER) */
+
+#define _SPL_DECL(x, X) \
+ static __inline int \
+ spl##x(void) \
+ { return splraiseipl(makeiplcookie(IPL_##X)); }
+
+#if defined(IPL_SOFTCLOCK)
+_SPL_DECL(softclock, SOFTCLOCK)
+#endif /* defined(IPL_SOFTCLOCK) */
+#if defined(IPL_SOFTNET)
+_SPL_DECL(softnet, SOFTNET)
+#endif /* defined(IPL_SOFTNET) */
+#if defined(IPL_SOFTSERIAL)
+_SPL_DECL(softserial, SOFTSERIAL)
+#endif /* defined(IPL_SOFTSERIAL) */
+
+_SPL_DECL(vm, VM)
+_SPL_DECL(sched, SCHED)
+_SPL_DECL(high, HIGH)
+
+#undef _SPL_DECL
--- /dev/null
+/* $NetBSD: spldebug.h,v 1.1 2009/11/03 05:23:28 dyoung Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Young.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SYS_SPLDEBUG_H__
+#define __SYS_SPLDEBUG_H__
+
+void spldebug_start(void);
+void spldebug_stop(void);
+
+void spldebug_lower(int);
+void spldebug_raise(int);
+
+#endif /* __SYS_SPLDEBUG_H__ */
--- /dev/null
+/* $NetBSD: swap.h,v 1.8 2009/01/14 02:20:45 mrg Exp $ */
+
+/*
+ * Copyright (c) 1995, 1996, 1998, 2009 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SWAP_H_
+#define _SYS_SWAP_H_
+
+#include <sys/syslimits.h>
+
+/* Thise structure is used to return swap information for userland */
+
+struct swapent {
+ dev_t se_dev; /* device id */
+ int se_flags; /* flags */
+ int se_nblks; /* total blocks */
+ int se_inuse; /* blocks in use */
+ int se_priority; /* priority of this device */
+ char se_path[PATH_MAX+1]; /* path name */
+};
+
+#define SWAP_ON 1 /* begin swapping on device */
+#define SWAP_OFF 2 /* stop swapping on device */
+#define SWAP_NSWAP 3 /* how many swap devices ? */
+#define SWAP_STATS13 4 /* old SWAP_STATS, no se_path */
+#define SWAP_CTL 5 /* change priority on device */
+#define SWAP_STATS50 6 /* old SWAP_STATS, 32 bit dev_t */
+#define SWAP_DUMPDEV 7 /* use this device as dump device */
+#define SWAP_GETDUMPDEV 8 /* use this device as dump device */
+#define SWAP_DUMPOFF 9 /* stop using the dump device */
+#define SWAP_STATS 10 /* get device info */
+
+#define SWF_INUSE 0x00000001 /* in use: we have swapped here */
+#define SWF_ENABLE 0x00000002 /* enabled: we can swap here */
+#define SWF_BUSY 0x00000004 /* busy: I/O happening here */
+#define SWF_FAKE 0x00000008 /* fake: still being built */
+
+#endif /* _SYS_SWAP_H_ */
--- /dev/null
+/* $NetBSD: syncobj.h,v 1.8 2009/10/21 21:12:07 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(_SYS_SYNCOBJ_H_)
+#define _SYS_SYNCOBJ_H_
+
+struct lwp;
+
+typedef volatile const void *wchan_t;
+
+#if defined(_KERNEL)
+
+/*
+ * Synchronisation object operations set.
+ */
+typedef struct syncobj {
+ u_int sobj_flag;
+ void (*sobj_unsleep)(struct lwp *, bool);
+ void (*sobj_changepri)(struct lwp *, pri_t);
+ void (*sobj_lendpri)(struct lwp *, pri_t);
+ struct lwp *(*sobj_owner)(wchan_t);
+} syncobj_t;
+
+struct lwp *syncobj_noowner(wchan_t);
+
+#define SOBJ_SLEEPQ_SORTED 0x01
+#define SOBJ_SLEEPQ_FIFO 0x02
+#define SOBJ_SLEEPQ_LIFO 0x04
+
+extern syncobj_t sched_syncobj;
+extern syncobj_t mutex_syncobj;
+extern syncobj_t rw_syncobj;
+extern syncobj_t sleep_syncobj;
+
+#endif /* defined(_KERNEL) */
+
+#endif /* !_SYS_SYNCOBJ_H_ */
--- /dev/null
+/* $NetBSD: syscall.h,v 1.257 2012/10/02 01:46:20 christos Exp $ */
+
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.261 2012/10/02 01:44:28 christos Exp
+ */
+
+#ifndef _SYS_SYSCALL_H_
+#define _SYS_SYSCALL_H_
+
+#define SYS_MAXSYSARGS 8
+
+/* syscall: "syscall" ret: "int" args: "int" "..." */
+#define SYS_syscall 0
+
+/* syscall: "exit" ret: "void" args: "int" */
+#define SYS_exit 1
+
+/* syscall: "fork" ret: "int" args: */
+#define SYS_fork 2
+
+/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */
+#define SYS_read 3
+
+/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */
+#define SYS_write 4
+
+/* syscall: "open" ret: "int" args: "const char *" "int" "..." */
+#define SYS_open 5
+
+/* syscall: "close" ret: "int" args: "int" */
+#define SYS_close 6
+
+/* syscall: "compat_50_wait4" ret: "int" args: "pid_t" "int *" "int" "struct rusage50 *" */
+#define SYS_compat_50_wait4 7
+
+/* syscall: "compat_43_ocreat" ret: "int" args: "const char *" "mode_t" */
+#define SYS_compat_43_ocreat 8
+
+/* syscall: "link" ret: "int" args: "const char *" "const char *" */
+#define SYS_link 9
+
+/* syscall: "unlink" ret: "int" args: "const char *" */
+#define SYS_unlink 10
+
+ /* 11 is obsolete execv */
+/* syscall: "chdir" ret: "int" args: "const char *" */
+#define SYS_chdir 12
+
+/* syscall: "fchdir" ret: "int" args: "int" */
+#define SYS_fchdir 13
+
+/* syscall: "compat_50_mknod" ret: "int" args: "const char *" "mode_t" "uint32_t" */
+#define SYS_compat_50_mknod 14
+
+/* syscall: "chmod" ret: "int" args: "const char *" "mode_t" */
+#define SYS_chmod 15
+
+/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */
+#define SYS_chown 16
+
+/* syscall: "break" ret: "int" args: "char *" */
+#define SYS_break 17
+
+/* syscall: "compat_20_getfsstat" ret: "int" args: "struct statfs12 *" "long" "int" */
+#define SYS_compat_20_getfsstat 18
+
+/* syscall: "compat_43_olseek" ret: "long" args: "int" "long" "int" */
+#define SYS_compat_43_olseek 19
+
+/* syscall: "getpid" ret: "pid_t" args: */
+#define SYS_getpid 20
+
+/* syscall: "compat_40_mount" ret: "int" args: "const char *" "const char *" "int" "void *" */
+#define SYS_compat_40_mount 21
+
+/* syscall: "unmount" ret: "int" args: "const char *" "int" */
+#define SYS_unmount 22
+
+/* syscall: "setuid" ret: "int" args: "uid_t" */
+#define SYS_setuid 23
+
+/* syscall: "getuid" ret: "uid_t" args: */
+#define SYS_getuid 24
+
+/* syscall: "geteuid" ret: "uid_t" args: */
+#define SYS_geteuid 25
+
+/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "void *" "int" */
+#define SYS_ptrace 26
+
+/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */
+#define SYS_recvmsg 27
+
+/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */
+#define SYS_sendmsg 28
+
+/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */
+#define SYS_recvfrom 29
+
+/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */
+#define SYS_accept 30
+
+/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */
+#define SYS_getpeername 31
+
+/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */
+#define SYS_getsockname 32
+
+/* syscall: "access" ret: "int" args: "const char *" "int" */
+#define SYS_access 33
+
+/* syscall: "chflags" ret: "int" args: "const char *" "u_long" */
+#define SYS_chflags 34
+
+/* syscall: "fchflags" ret: "int" args: "int" "u_long" */
+#define SYS_fchflags 35
+
+/* syscall: "sync" ret: "void" args: */
+#define SYS_sync 36
+
+/* syscall: "kill" ret: "int" args: "pid_t" "int" */
+#define SYS_kill 37
+
+/* syscall: "compat_43_stat43" ret: "int" args: "const char *" "struct stat43 *" */
+#define SYS_compat_43_stat43 38
+
+/* syscall: "getppid" ret: "pid_t" args: */
+#define SYS_getppid 39
+
+/* syscall: "compat_43_lstat43" ret: "int" args: "const char *" "struct stat43 *" */
+#define SYS_compat_43_lstat43 40
+
+/* syscall: "dup" ret: "int" args: "int" */
+#define SYS_dup 41
+
+/* syscall: "pipe" ret: "int" args: */
+#define SYS_pipe 42
+
+/* syscall: "getegid" ret: "gid_t" args: */
+#define SYS_getegid 43
+
+/* syscall: "profil" ret: "int" args: "char *" "size_t" "u_long" "u_int" */
+#define SYS_profil 44
+
+/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */
+#define SYS_ktrace 45
+
+/* syscall: "compat_13_sigaction13" ret: "int" args: "int" "const struct sigaction13 *" "struct sigaction13 *" */
+#define SYS_compat_13_sigaction13 46
+
+/* syscall: "getgid" ret: "gid_t" args: */
+#define SYS_getgid 47
+
+/* syscall: "compat_13_sigprocmask13" ret: "int" args: "int" "int" */
+#define SYS_compat_13_sigprocmask13 48
+
+/* syscall: "__getlogin" ret: "int" args: "char *" "size_t" */
+#define SYS___getlogin 49
+
+/* syscall: "__setlogin" ret: "int" args: "const char *" */
+#define SYS___setlogin 50
+
+/* syscall: "acct" ret: "int" args: "const char *" */
+#define SYS_acct 51
+
+/* syscall: "compat_13_sigpending13" ret: "int" args: */
+#define SYS_compat_13_sigpending13 52
+
+/* syscall: "compat_13_sigaltstack13" ret: "int" args: "const struct sigaltstack13 *" "struct sigaltstack13 *" */
+#define SYS_compat_13_sigaltstack13 53
+
+/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */
+#define SYS_ioctl 54
+
+/* syscall: "compat_12_oreboot" ret: "int" args: "int" */
+#define SYS_compat_12_oreboot 55
+
+/* syscall: "revoke" ret: "int" args: "const char *" */
+#define SYS_revoke 56
+
+/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */
+#define SYS_symlink 57
+
+/* syscall: "readlink" ret: "ssize_t" args: "const char *" "char *" "size_t" */
+#define SYS_readlink 58
+
+/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */
+#define SYS_execve 59
+
+/* syscall: "umask" ret: "mode_t" args: "mode_t" */
+#define SYS_umask 60
+
+/* syscall: "chroot" ret: "int" args: "const char *" */
+#define SYS_chroot 61
+
+/* syscall: "compat_43_fstat43" ret: "int" args: "int" "struct stat43 *" */
+#define SYS_compat_43_fstat43 62
+
+/* syscall: "compat_43_ogetkerninfo" ret: "int" args: "int" "char *" "int *" "int" */
+#define SYS_compat_43_ogetkerninfo 63
+
+/* syscall: "compat_43_ogetpagesize" ret: "int" args: */
+#define SYS_compat_43_ogetpagesize 64
+
+/* syscall: "compat_12_msync" ret: "int" args: "void *" "size_t" */
+#define SYS_compat_12_msync 65
+
+/* syscall: "vfork" ret: "int" args: */
+#define SYS_vfork 66
+
+ /* 67 is obsolete vread */
+ /* 68 is obsolete vwrite */
+/* syscall: "sbrk" ret: "int" args: "intptr_t" */
+#define SYS_sbrk 69
+
+/* syscall: "sstk" ret: "int" args: "int" */
+#define SYS_sstk 70
+
+/* syscall: "compat_43_ommap" ret: "int" args: "void *" "size_t" "int" "int" "int" "long" */
+#define SYS_compat_43_ommap 71
+
+/* syscall: "vadvise" ret: "int" args: "int" */
+#define SYS_vadvise 72
+
+/* syscall: "munmap" ret: "int" args: "void *" "size_t" */
+#define SYS_munmap 73
+
+/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */
+#define SYS_mprotect 74
+
+/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */
+#define SYS_madvise 75
+
+ /* 76 is obsolete vhangup */
+ /* 77 is obsolete vlimit */
+/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */
+#define SYS_mincore 78
+
+/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */
+#define SYS_getgroups 79
+
+/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */
+#define SYS_setgroups 80
+
+/* syscall: "getpgrp" ret: "int" args: */
+#define SYS_getpgrp 81
+
+/* syscall: "setpgid" ret: "int" args: "pid_t" "pid_t" */
+#define SYS_setpgid 82
+
+/* syscall: "compat_50_setitimer" ret: "int" args: "int" "const struct itimerval50 *" "struct itimerval50 *" */
+#define SYS_compat_50_setitimer 83
+
+/* syscall: "compat_43_owait" ret: "int" args: */
+#define SYS_compat_43_owait 84
+
+/* syscall: "compat_12_oswapon" ret: "int" args: "const char *" */
+#define SYS_compat_12_oswapon 85
+
+/* syscall: "compat_50_getitimer" ret: "int" args: "int" "struct itimerval50 *" */
+#define SYS_compat_50_getitimer 86
+
+/* syscall: "compat_43_ogethostname" ret: "int" args: "char *" "u_int" */
+#define SYS_compat_43_ogethostname 87
+
+/* syscall: "compat_43_osethostname" ret: "int" args: "char *" "u_int" */
+#define SYS_compat_43_osethostname 88
+
+/* syscall: "compat_43_ogetdtablesize" ret: "int" args: */
+#define SYS_compat_43_ogetdtablesize 89
+
+/* syscall: "dup2" ret: "int" args: "int" "int" */
+#define SYS_dup2 90
+
+/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */
+#define SYS_fcntl 92
+
+/* syscall: "compat_50_select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval50 *" */
+#define SYS_compat_50_select 93
+
+/* syscall: "fsync" ret: "int" args: "int" */
+#define SYS_fsync 95
+
+/* syscall: "setpriority" ret: "int" args: "int" "id_t" "int" */
+#define SYS_setpriority 96
+
+/* syscall: "compat_30_socket" ret: "int" args: "int" "int" "int" */
+#define SYS_compat_30_socket 97
+
+/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */
+#define SYS_connect 98
+
+/* syscall: "compat_43_oaccept" ret: "int" args: "int" "void *" "socklen_t *" */
+#define SYS_compat_43_oaccept 99
+
+/* syscall: "getpriority" ret: "int" args: "int" "id_t" */
+#define SYS_getpriority 100
+
+/* syscall: "compat_43_osend" ret: "int" args: "int" "void *" "int" "int" */
+#define SYS_compat_43_osend 101
+
+/* syscall: "compat_43_orecv" ret: "int" args: "int" "void *" "int" "int" */
+#define SYS_compat_43_orecv 102
+
+/* syscall: "compat_13_sigreturn13" ret: "int" args: "struct sigcontext13 *" */
+#define SYS_compat_13_sigreturn13 103
+
+/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */
+#define SYS_bind 104
+
+/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */
+#define SYS_setsockopt 105
+
+/* syscall: "listen" ret: "int" args: "int" "int" */
+#define SYS_listen 106
+
+ /* 107 is obsolete vtimes */
+/* syscall: "compat_43_osigvec" ret: "int" args: "int" "struct sigvec *" "struct sigvec *" */
+#define SYS_compat_43_osigvec 108
+
+/* syscall: "compat_43_osigblock" ret: "int" args: "int" */
+#define SYS_compat_43_osigblock 109
+
+/* syscall: "compat_43_osigsetmask" ret: "int" args: "int" */
+#define SYS_compat_43_osigsetmask 110
+
+/* syscall: "compat_13_sigsuspend13" ret: "int" args: "int" */
+#define SYS_compat_13_sigsuspend13 111
+
+/* syscall: "compat_43_osigstack" ret: "int" args: "struct sigstack *" "struct sigstack *" */
+#define SYS_compat_43_osigstack 112
+
+/* syscall: "compat_43_orecvmsg" ret: "int" args: "int" "struct omsghdr *" "int" */
+#define SYS_compat_43_orecvmsg 113
+
+/* syscall: "compat_43_osendmsg" ret: "int" args: "int" "void *" "int" */
+#define SYS_compat_43_osendmsg 114
+
+ /* 115 is obsolete vtrace */
+/* syscall: "compat_50_gettimeofday" ret: "int" args: "struct timeval50 *" "void *" */
+#define SYS_compat_50_gettimeofday 116
+
+/* syscall: "compat_50_getrusage" ret: "int" args: "int" "struct rusage50 *" */
+#define SYS_compat_50_getrusage 117
+
+/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */
+#define SYS_getsockopt 118
+
+ /* 119 is obsolete resuba */
+/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */
+#define SYS_readv 120
+
+/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */
+#define SYS_writev 121
+
+/* syscall: "compat_50_settimeofday" ret: "int" args: "const struct timeval50 *" "const void *" */
+#define SYS_compat_50_settimeofday 122
+
+/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */
+#define SYS_fchown 123
+
+/* syscall: "fchmod" ret: "int" args: "int" "mode_t" */
+#define SYS_fchmod 124
+
+/* syscall: "compat_43_orecvfrom" ret: "int" args: "int" "void *" "size_t" "int" "void *" "socklen_t *" */
+#define SYS_compat_43_orecvfrom 125
+
+/* syscall: "setreuid" ret: "int" args: "uid_t" "uid_t" */
+#define SYS_setreuid 126
+
+/* syscall: "setregid" ret: "int" args: "gid_t" "gid_t" */
+#define SYS_setregid 127
+
+/* syscall: "rename" ret: "int" args: "const char *" "const char *" */
+#define SYS_rename 128
+
+/* syscall: "compat_43_otruncate" ret: "int" args: "const char *" "long" */
+#define SYS_compat_43_otruncate 129
+
+/* syscall: "compat_43_oftruncate" ret: "int" args: "int" "long" */
+#define SYS_compat_43_oftruncate 130
+
+/* syscall: "flock" ret: "int" args: "int" "int" */
+#define SYS_flock 131
+
+/* syscall: "mkfifo" ret: "int" args: "const char *" "mode_t" */
+#define SYS_mkfifo 132
+
+/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */
+#define SYS_sendto 133
+
+/* syscall: "shutdown" ret: "int" args: "int" "int" */
+#define SYS_shutdown 134
+
+/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */
+#define SYS_socketpair 135
+
+/* syscall: "mkdir" ret: "int" args: "const char *" "mode_t" */
+#define SYS_mkdir 136
+
+/* syscall: "rmdir" ret: "int" args: "const char *" */
+#define SYS_rmdir 137
+
+/* syscall: "compat_50_utimes" ret: "int" args: "const char *" "const struct timeval50 *" */
+#define SYS_compat_50_utimes 138
+
+ /* 139 is obsolete 4.2 sigreturn */
+/* syscall: "compat_50_adjtime" ret: "int" args: "const struct timeval50 *" "struct timeval50 *" */
+#define SYS_compat_50_adjtime 140
+
+/* syscall: "compat_43_ogetpeername" ret: "int" args: "int" "void *" "socklen_t *" */
+#define SYS_compat_43_ogetpeername 141
+
+/* syscall: "compat_43_ogethostid" ret: "int32_t" args: */
+#define SYS_compat_43_ogethostid 142
+
+/* syscall: "compat_43_osethostid" ret: "int" args: "int32_t" */
+#define SYS_compat_43_osethostid 143
+
+/* syscall: "compat_43_ogetrlimit" ret: "int" args: "int" "struct orlimit *" */
+#define SYS_compat_43_ogetrlimit 144
+
+/* syscall: "compat_43_osetrlimit" ret: "int" args: "int" "const struct orlimit *" */
+#define SYS_compat_43_osetrlimit 145
+
+/* syscall: "compat_43_okillpg" ret: "int" args: "int" "int" */
+#define SYS_compat_43_okillpg 146
+
+/* syscall: "setsid" ret: "int" args: */
+#define SYS_setsid 147
+
+/* syscall: "compat_50_quotactl" ret: "int" args: "const char *" "int" "int" "void *" */
+#define SYS_compat_50_quotactl 148
+
+/* syscall: "compat_43_oquota" ret: "int" args: */
+#define SYS_compat_43_oquota 149
+
+/* syscall: "compat_43_ogetsockname" ret: "int" args: "int" "void *" "socklen_t *" */
+#define SYS_compat_43_ogetsockname 150
+
+/* syscall: "nfssvc" ret: "int" args: "int" "void *" */
+#define SYS_nfssvc 155
+
+/* syscall: "compat_43_ogetdirentries" ret: "int" args: "int" "char *" "u_int" "long *" */
+#define SYS_compat_43_ogetdirentries 156
+
+/* syscall: "compat_20_statfs" ret: "int" args: "const char *" "struct statfs12 *" */
+#define SYS_compat_20_statfs 157
+
+/* syscall: "compat_20_fstatfs" ret: "int" args: "int" "struct statfs12 *" */
+#define SYS_compat_20_fstatfs 158
+
+/* syscall: "compat_30_getfh" ret: "int" args: "const char *" "struct compat_30_fhandle *" */
+#define SYS_compat_30_getfh 161
+
+/* syscall: "compat_09_ogetdomainname" ret: "int" args: "char *" "int" */
+#define SYS_compat_09_ogetdomainname 162
+
+/* syscall: "compat_09_osetdomainname" ret: "int" args: "char *" "int" */
+#define SYS_compat_09_osetdomainname 163
+
+/* syscall: "compat_09_ouname" ret: "int" args: "struct outsname *" */
+#define SYS_compat_09_ouname 164
+
+/* syscall: "sysarch" ret: "int" args: "int" "void *" */
+#define SYS_sysarch 165
+
+#if (defined(SYSVSEM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+/* syscall: "compat_10_osemsys" ret: "int" args: "int" "int" "int" "int" "int" */
+#define SYS_compat_10_osemsys 169
+
+#else
+ /* 169 is excluded 1.0 semsys */
+#endif
+#if (defined(SYSVMSG) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+/* syscall: "compat_10_omsgsys" ret: "int" args: "int" "int" "int" "int" "int" "int" */
+#define SYS_compat_10_omsgsys 170
+
+#else
+ /* 170 is excluded 1.0 msgsys */
+#endif
+#if (defined(SYSVSHM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+/* syscall: "compat_10_oshmsys" ret: "int" args: "int" "int" "int" "int" */
+#define SYS_compat_10_oshmsys 171
+
+#else
+ /* 171 is excluded 1.0 shmsys */
+#endif
+/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */
+#define SYS_pread 173
+
+/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */
+#define SYS_pwrite 174
+
+/* syscall: "compat_30_ntp_gettime" ret: "int" args: "struct ntptimeval30 *" */
+#define SYS_compat_30_ntp_gettime 175
+
+#if defined(NTP) || !defined(_KERNEL_OPT)
+/* syscall: "ntp_adjtime" ret: "int" args: "struct timex *" */
+#define SYS_ntp_adjtime 176
+
+#else
+ /* 176 is excluded ntp_adjtime */
+#endif
+/* syscall: "setgid" ret: "int" args: "gid_t" */
+#define SYS_setgid 181
+
+/* syscall: "setegid" ret: "int" args: "gid_t" */
+#define SYS_setegid 182
+
+/* syscall: "seteuid" ret: "int" args: "uid_t" */
+#define SYS_seteuid 183
+
+/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */
+#define SYS_lfs_bmapv 184
+
+/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */
+#define SYS_lfs_markv 185
+
+/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */
+#define SYS_lfs_segclean 186
+
+/* syscall: "compat_50_lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval50 *" */
+#define SYS_compat_50_lfs_segwait 187
+
+/* syscall: "compat_12_stat12" ret: "int" args: "const char *" "struct stat12 *" */
+#define SYS_compat_12_stat12 188
+
+/* syscall: "compat_12_fstat12" ret: "int" args: "int" "struct stat12 *" */
+#define SYS_compat_12_fstat12 189
+
+/* syscall: "compat_12_lstat12" ret: "int" args: "const char *" "struct stat12 *" */
+#define SYS_compat_12_lstat12 190
+
+/* syscall: "pathconf" ret: "long" args: "const char *" "int" */
+#define SYS_pathconf 191
+
+/* syscall: "fpathconf" ret: "long" args: "int" "int" */
+#define SYS_fpathconf 192
+
+/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */
+#define SYS_getrlimit 194
+
+/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */
+#define SYS_setrlimit 195
+
+/* syscall: "compat_12_getdirentries" ret: "int" args: "int" "char *" "u_int" "long *" */
+#define SYS_compat_12_getdirentries 196
+
+/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */
+#define SYS_mmap 197
+
+/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */
+#define SYS___syscall 198
+
+/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */
+#define SYS_lseek 199
+
+/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */
+#define SYS_truncate 200
+
+/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */
+#define SYS_ftruncate 201
+
+/* syscall: "__sysctl" ret: "int" args: "const int *" "u_int" "void *" "size_t *" "const void *" "size_t" */
+#define SYS___sysctl 202
+
+/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */
+#define SYS_mlock 203
+
+/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */
+#define SYS_munlock 204
+
+/* syscall: "undelete" ret: "int" args: "const char *" */
+#define SYS_undelete 205
+
+/* syscall: "compat_50_futimes" ret: "int" args: "int" "const struct timeval50 *" */
+#define SYS_compat_50_futimes 206
+
+/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */
+#define SYS_getpgid 207
+
+/* syscall: "reboot" ret: "int" args: "int" "char *" */
+#define SYS_reboot 208
+
+/* syscall: "poll" ret: "int" args: "struct pollfd *" "u_int" "int" */
+#define SYS_poll 209
+
+/* syscall: "afssys" ret: "int" args: "long" "long" "long" "long" "long" "long" "long" */
+#define SYS_afssys 210
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+/* syscall: "compat_14___semctl" ret: "int" args: "int" "int" "int" "union __semun *" */
+#define SYS_compat_14___semctl 220
+
+/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */
+#define SYS_semget 221
+
+/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "size_t" */
+#define SYS_semop 222
+
+/* syscall: "semconfig" ret: "int" args: "int" */
+#define SYS_semconfig 223
+
+#else
+ /* 220 is excluded compat_14_semctl */
+ /* 221 is excluded semget */
+ /* 222 is excluded semop */
+ /* 223 is excluded semconfig */
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+/* syscall: "compat_14_msgctl" ret: "int" args: "int" "int" "struct msqid_ds14 *" */
+#define SYS_compat_14_msgctl 224
+
+/* syscall: "msgget" ret: "int" args: "key_t" "int" */
+#define SYS_msgget 225
+
+/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */
+#define SYS_msgsnd 226
+
+/* syscall: "msgrcv" ret: "ssize_t" args: "int" "void *" "size_t" "long" "int" */
+#define SYS_msgrcv 227
+
+#else
+ /* 224 is excluded compat_14_msgctl */
+ /* 225 is excluded msgget */
+ /* 226 is excluded msgsnd */
+ /* 227 is excluded msgrcv */
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */
+#define SYS_shmat 228
+
+/* syscall: "compat_14_shmctl" ret: "int" args: "int" "int" "struct shmid_ds14 *" */
+#define SYS_compat_14_shmctl 229
+
+/* syscall: "shmdt" ret: "int" args: "const void *" */
+#define SYS_shmdt 230
+
+/* syscall: "shmget" ret: "int" args: "key_t" "size_t" "int" */
+#define SYS_shmget 231
+
+#else
+ /* 228 is excluded shmat */
+ /* 229 is excluded compat_14_shmctl */
+ /* 230 is excluded shmdt */
+ /* 231 is excluded shmget */
+#endif
+/* syscall: "compat_50_clock_gettime" ret: "int" args: "clockid_t" "struct timespec50 *" */
+#define SYS_compat_50_clock_gettime 232
+
+/* syscall: "compat_50_clock_settime" ret: "int" args: "clockid_t" "const struct timespec50 *" */
+#define SYS_compat_50_clock_settime 233
+
+/* syscall: "compat_50_clock_getres" ret: "int" args: "clockid_t" "struct timespec50 *" */
+#define SYS_compat_50_clock_getres 234
+
+/* syscall: "timer_create" ret: "int" args: "clockid_t" "struct sigevent *" "timer_t *" */
+#define SYS_timer_create 235
+
+/* syscall: "timer_delete" ret: "int" args: "timer_t" */
+#define SYS_timer_delete 236
+
+/* syscall: "compat_50_timer_settime" ret: "int" args: "timer_t" "int" "const struct itimerspec50 *" "struct itimerspec50 *" */
+#define SYS_compat_50_timer_settime 237
+
+/* syscall: "compat_50_timer_gettime" ret: "int" args: "timer_t" "struct itimerspec50 *" */
+#define SYS_compat_50_timer_gettime 238
+
+/* syscall: "timer_getoverrun" ret: "int" args: "timer_t" */
+#define SYS_timer_getoverrun 239
+
+/* syscall: "compat_50_nanosleep" ret: "int" args: "const struct timespec50 *" "struct timespec50 *" */
+#define SYS_compat_50_nanosleep 240
+
+/* syscall: "fdatasync" ret: "int" args: "int" */
+#define SYS_fdatasync 241
+
+/* syscall: "mlockall" ret: "int" args: "int" */
+#define SYS_mlockall 242
+
+/* syscall: "munlockall" ret: "int" args: */
+#define SYS_munlockall 243
+
+/* syscall: "compat_50___sigtimedwait" ret: "int" args: "const sigset_t *" "siginfo_t *" "struct timespec50 *" */
+#define SYS_compat_50___sigtimedwait 244
+
+/* syscall: "sigqueueinfo" ret: "int" args: "pid_t" "const siginfo_t *" */
+#define SYS_sigqueueinfo 245
+
+/* syscall: "modctl" ret: "int" args: "int" "void *" */
+#define SYS_modctl 246
+
+/* syscall: "_ksem_init" ret: "int" args: "unsigned int" "intptr_t *" */
+#define SYS__ksem_init 247
+
+/* syscall: "_ksem_open" ret: "int" args: "const char *" "int" "mode_t" "unsigned int" "intptr_t *" */
+#define SYS__ksem_open 248
+
+/* syscall: "_ksem_unlink" ret: "int" args: "const char *" */
+#define SYS__ksem_unlink 249
+
+/* syscall: "_ksem_close" ret: "int" args: "intptr_t" */
+#define SYS__ksem_close 250
+
+/* syscall: "_ksem_post" ret: "int" args: "intptr_t" */
+#define SYS__ksem_post 251
+
+/* syscall: "_ksem_wait" ret: "int" args: "intptr_t" */
+#define SYS__ksem_wait 252
+
+/* syscall: "_ksem_trywait" ret: "int" args: "intptr_t" */
+#define SYS__ksem_trywait 253
+
+/* syscall: "_ksem_getvalue" ret: "int" args: "intptr_t" "unsigned int *" */
+#define SYS__ksem_getvalue 254
+
+/* syscall: "_ksem_destroy" ret: "int" args: "intptr_t" */
+#define SYS__ksem_destroy 255
+
+/* syscall: "_ksem_timedwait" ret: "int" args: "intptr_t" "const struct timespec *" */
+#define SYS__ksem_timedwait 256
+
+/* syscall: "mq_open" ret: "mqd_t" args: "const char *" "int" "mode_t" "struct mq_attr *" */
+#define SYS_mq_open 257
+
+/* syscall: "mq_close" ret: "int" args: "mqd_t" */
+#define SYS_mq_close 258
+
+/* syscall: "mq_unlink" ret: "int" args: "const char *" */
+#define SYS_mq_unlink 259
+
+/* syscall: "mq_getattr" ret: "int" args: "mqd_t" "struct mq_attr *" */
+#define SYS_mq_getattr 260
+
+/* syscall: "mq_setattr" ret: "int" args: "mqd_t" "const struct mq_attr *" "struct mq_attr *" */
+#define SYS_mq_setattr 261
+
+/* syscall: "mq_notify" ret: "int" args: "mqd_t" "const struct sigevent *" */
+#define SYS_mq_notify 262
+
+/* syscall: "mq_send" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" */
+#define SYS_mq_send 263
+
+/* syscall: "mq_receive" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" */
+#define SYS_mq_receive 264
+
+/* syscall: "compat_50_mq_timedsend" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" "const struct timespec50 *" */
+#define SYS_compat_50_mq_timedsend 265
+
+/* syscall: "compat_50_mq_timedreceive" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" "const struct timespec50 *" */
+#define SYS_compat_50_mq_timedreceive 266
+
+/* syscall: "__posix_rename" ret: "int" args: "const char *" "const char *" */
+#define SYS___posix_rename 270
+
+/* syscall: "swapctl" ret: "int" args: "int" "void *" "int" */
+#define SYS_swapctl 271
+
+/* syscall: "compat_30_getdents" ret: "int" args: "int" "char *" "size_t" */
+#define SYS_compat_30_getdents 272
+
+/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */
+#define SYS_minherit 273
+
+/* syscall: "lchmod" ret: "int" args: "const char *" "mode_t" */
+#define SYS_lchmod 274
+
+/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */
+#define SYS_lchown 275
+
+/* syscall: "compat_50_lutimes" ret: "int" args: "const char *" "const struct timeval50 *" */
+#define SYS_compat_50_lutimes 276
+
+/* syscall: "__msync13" ret: "int" args: "void *" "size_t" "int" */
+#define SYS___msync13 277
+
+/* syscall: "compat_30___stat13" ret: "int" args: "const char *" "struct stat13 *" */
+#define SYS_compat_30___stat13 278
+
+/* syscall: "compat_30___fstat13" ret: "int" args: "int" "struct stat13 *" */
+#define SYS_compat_30___fstat13 279
+
+/* syscall: "compat_30___lstat13" ret: "int" args: "const char *" "struct stat13 *" */
+#define SYS_compat_30___lstat13 280
+
+/* syscall: "__sigaltstack14" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */
+#define SYS___sigaltstack14 281
+
+/* syscall: "__vfork14" ret: "int" args: */
+#define SYS___vfork14 282
+
+/* syscall: "__posix_chown" ret: "int" args: "const char *" "uid_t" "gid_t" */
+#define SYS___posix_chown 283
+
+/* syscall: "__posix_fchown" ret: "int" args: "int" "uid_t" "gid_t" */
+#define SYS___posix_fchown 284
+
+/* syscall: "__posix_lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */
+#define SYS___posix_lchown 285
+
+/* syscall: "getsid" ret: "pid_t" args: "pid_t" */
+#define SYS_getsid 286
+
+/* syscall: "__clone" ret: "pid_t" args: "int" "void *" */
+#define SYS___clone 287
+
+/* syscall: "fktrace" ret: "int" args: "int" "int" "int" "pid_t" */
+#define SYS_fktrace 288
+
+/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */
+#define SYS_preadv 289
+
+/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */
+#define SYS_pwritev 290
+
+/* syscall: "compat_16___sigaction14" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */
+#define SYS_compat_16___sigaction14 291
+
+/* syscall: "__sigpending14" ret: "int" args: "sigset_t *" */
+#define SYS___sigpending14 292
+
+/* syscall: "__sigprocmask14" ret: "int" args: "int" "const sigset_t *" "sigset_t *" */
+#define SYS___sigprocmask14 293
+
+/* syscall: "__sigsuspend14" ret: "int" args: "const sigset_t *" */
+#define SYS___sigsuspend14 294
+
+/* syscall: "compat_16___sigreturn14" ret: "int" args: "struct sigcontext *" */
+#define SYS_compat_16___sigreturn14 295
+
+/* syscall: "__getcwd" ret: "int" args: "char *" "size_t" */
+#define SYS___getcwd 296
+
+/* syscall: "fchroot" ret: "int" args: "int" */
+#define SYS_fchroot 297
+
+/* syscall: "compat_30_fhopen" ret: "int" args: "const struct compat_30_fhandle *" "int" */
+#define SYS_compat_30_fhopen 298
+
+/* syscall: "compat_30_fhstat" ret: "int" args: "const struct compat_30_fhandle *" "struct stat13 *" */
+#define SYS_compat_30_fhstat 299
+
+/* syscall: "compat_20_fhstatfs" ret: "int" args: "const struct compat_30_fhandle *" "struct statfs12 *" */
+#define SYS_compat_20_fhstatfs 300
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+/* syscall: "compat_50_____semctl13" ret: "int" args: "int" "int" "int" "..." */
+#define SYS_compat_50_____semctl13 301
+
+#else
+ /* 301 is excluded ____semctl13 */
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+/* syscall: "compat_50___msgctl13" ret: "int" args: "int" "int" "struct msqid_ds *" */
+#define SYS_compat_50___msgctl13 302
+
+#else
+ /* 302 is excluded __msgctl13 */
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+/* syscall: "compat_50___shmctl13" ret: "int" args: "int" "int" "struct shmid_ds13 *" */
+#define SYS_compat_50___shmctl13 303
+
+#else
+ /* 303 is excluded __shmctl13 */
+#endif
+/* syscall: "lchflags" ret: "int" args: "const char *" "u_long" */
+#define SYS_lchflags 304
+
+/* syscall: "issetugid" ret: "int" args: */
+#define SYS_issetugid 305
+
+/* syscall: "utrace" ret: "int" args: "const char *" "void *" "size_t" */
+#define SYS_utrace 306
+
+/* syscall: "getcontext" ret: "int" args: "struct __ucontext *" */
+#define SYS_getcontext 307
+
+/* syscall: "setcontext" ret: "int" args: "const struct __ucontext *" */
+#define SYS_setcontext 308
+
+/* syscall: "_lwp_create" ret: "int" args: "const struct __ucontext *" "u_long" "lwpid_t *" */
+#define SYS__lwp_create 309
+
+/* syscall: "_lwp_exit" ret: "int" args: */
+#define SYS__lwp_exit 310
+
+/* syscall: "_lwp_self" ret: "lwpid_t" args: */
+#define SYS__lwp_self 311
+
+/* syscall: "_lwp_wait" ret: "int" args: "lwpid_t" "lwpid_t *" */
+#define SYS__lwp_wait 312
+
+/* syscall: "_lwp_suspend" ret: "int" args: "lwpid_t" */
+#define SYS__lwp_suspend 313
+
+/* syscall: "_lwp_continue" ret: "int" args: "lwpid_t" */
+#define SYS__lwp_continue 314
+
+/* syscall: "_lwp_wakeup" ret: "int" args: "lwpid_t" */
+#define SYS__lwp_wakeup 315
+
+/* syscall: "_lwp_getprivate" ret: "void *" args: */
+#define SYS__lwp_getprivate 316
+
+/* syscall: "_lwp_setprivate" ret: "void" args: "void *" */
+#define SYS__lwp_setprivate 317
+
+/* syscall: "_lwp_kill" ret: "int" args: "lwpid_t" "int" */
+#define SYS__lwp_kill 318
+
+/* syscall: "_lwp_detach" ret: "int" args: "lwpid_t" */
+#define SYS__lwp_detach 319
+
+/* syscall: "compat_50__lwp_park" ret: "int" args: "const struct timespec50 *" "lwpid_t" "const void *" "const void *" */
+#define SYS_compat_50__lwp_park 320
+
+/* syscall: "_lwp_unpark" ret: "int" args: "lwpid_t" "const void *" */
+#define SYS__lwp_unpark 321
+
+/* syscall: "_lwp_unpark_all" ret: "ssize_t" args: "const lwpid_t *" "size_t" "const void *" */
+#define SYS__lwp_unpark_all 322
+
+/* syscall: "_lwp_setname" ret: "int" args: "lwpid_t" "const char *" */
+#define SYS__lwp_setname 323
+
+/* syscall: "_lwp_getname" ret: "int" args: "lwpid_t" "char *" "size_t" */
+#define SYS__lwp_getname 324
+
+/* syscall: "_lwp_ctl" ret: "int" args: "int" "struct lwpctl **" */
+#define SYS__lwp_ctl 325
+
+/* syscall: "compat_60_sa_register" ret: "int" args: "void *" "void **" "int" "ssize_t" */
+#define SYS_compat_60_sa_register 330
+
+/* syscall: "compat_60_sa_stacks" ret: "int" args: "int" "stack_t *" */
+#define SYS_compat_60_sa_stacks 331
+
+/* syscall: "compat_60_sa_enable" ret: "int" args: */
+#define SYS_compat_60_sa_enable 332
+
+/* syscall: "compat_60_sa_setconcurrency" ret: "int" args: "int" */
+#define SYS_compat_60_sa_setconcurrency 333
+
+/* syscall: "compat_60_sa_yield" ret: "int" args: */
+#define SYS_compat_60_sa_yield 334
+
+/* syscall: "compat_60_sa_preempt" ret: "int" args: "int" */
+#define SYS_compat_60_sa_preempt 335
+
+ /* 336 is obsolete sys_sa_unblockyield */
+/* syscall: "__sigaction_sigtramp" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" "const void *" "int" */
+#define SYS___sigaction_sigtramp 340
+
+/* syscall: "pmc_get_info" ret: "int" args: "int" "int" "void *" */
+#define SYS_pmc_get_info 341
+
+/* syscall: "pmc_control" ret: "int" args: "int" "int" "void *" */
+#define SYS_pmc_control 342
+
+/* syscall: "rasctl" ret: "int" args: "void *" "size_t" "int" */
+#define SYS_rasctl 343
+
+/* syscall: "kqueue" ret: "int" args: */
+#define SYS_kqueue 344
+
+/* syscall: "compat_50_kevent" ret: "int" args: "int" "const struct kevent *" "size_t" "struct kevent *" "size_t" "const struct timespec50 *" */
+#define SYS_compat_50_kevent 345
+
+/* syscall: "_sched_setparam" ret: "int" args: "pid_t" "lwpid_t" "int" "const struct sched_param *" */
+#define SYS__sched_setparam 346
+
+/* syscall: "_sched_getparam" ret: "int" args: "pid_t" "lwpid_t" "int *" "struct sched_param *" */
+#define SYS__sched_getparam 347
+
+/* syscall: "_sched_setaffinity" ret: "int" args: "pid_t" "lwpid_t" "size_t" "const cpuset_t *" */
+#define SYS__sched_setaffinity 348
+
+/* syscall: "_sched_getaffinity" ret: "int" args: "pid_t" "lwpid_t" "size_t" "cpuset_t *" */
+#define SYS__sched_getaffinity 349
+
+/* syscall: "sched_yield" ret: "int" args: */
+#define SYS_sched_yield 350
+
+/* syscall: "fsync_range" ret: "int" args: "int" "int" "off_t" "off_t" */
+#define SYS_fsync_range 354
+
+/* syscall: "uuidgen" ret: "int" args: "struct uuid *" "int" */
+#define SYS_uuidgen 355
+
+/* syscall: "getvfsstat" ret: "int" args: "struct statvfs *" "size_t" "int" */
+#define SYS_getvfsstat 356
+
+/* syscall: "statvfs1" ret: "int" args: "const char *" "struct statvfs *" "int" */
+#define SYS_statvfs1 357
+
+/* syscall: "fstatvfs1" ret: "int" args: "int" "struct statvfs *" "int" */
+#define SYS_fstatvfs1 358
+
+/* syscall: "compat_30_fhstatvfs1" ret: "int" args: "const struct compat_30_fhandle *" "struct statvfs *" "int" */
+#define SYS_compat_30_fhstatvfs1 359
+
+/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */
+#define SYS_extattrctl 360
+
+/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "const void *" "size_t" */
+#define SYS_extattr_set_file 361
+
+/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */
+#define SYS_extattr_get_file 362
+
+/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */
+#define SYS_extattr_delete_file 363
+
+/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "const void *" "size_t" */
+#define SYS_extattr_set_fd 364
+
+/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */
+#define SYS_extattr_get_fd 365
+
+/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */
+#define SYS_extattr_delete_fd 366
+
+/* syscall: "extattr_set_link" ret: "int" args: "const char *" "int" "const char *" "const void *" "size_t" */
+#define SYS_extattr_set_link 367
+
+/* syscall: "extattr_get_link" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */
+#define SYS_extattr_get_link 368
+
+/* syscall: "extattr_delete_link" ret: "int" args: "const char *" "int" "const char *" */
+#define SYS_extattr_delete_link 369
+
+/* syscall: "extattr_list_fd" ret: "ssize_t" args: "int" "int" "void *" "size_t" */
+#define SYS_extattr_list_fd 370
+
+/* syscall: "extattr_list_file" ret: "ssize_t" args: "const char *" "int" "void *" "size_t" */
+#define SYS_extattr_list_file 371
+
+/* syscall: "extattr_list_link" ret: "ssize_t" args: "const char *" "int" "void *" "size_t" */
+#define SYS_extattr_list_link 372
+
+/* syscall: "compat_50_pselect" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "const struct timespec50 *" "const sigset_t *" */
+#define SYS_compat_50_pselect 373
+
+/* syscall: "compat_50_pollts" ret: "int" args: "struct pollfd *" "u_int" "const struct timespec50 *" "const sigset_t *" */
+#define SYS_compat_50_pollts 374
+
+/* syscall: "setxattr" ret: "int" args: "const char *" "const char *" "const void *" "size_t" "int" */
+#define SYS_setxattr 375
+
+/* syscall: "lsetxattr" ret: "int" args: "const char *" "const char *" "const void *" "size_t" "int" */
+#define SYS_lsetxattr 376
+
+/* syscall: "fsetxattr" ret: "int" args: "int" "const char *" "const void *" "size_t" "int" */
+#define SYS_fsetxattr 377
+
+/* syscall: "getxattr" ret: "int" args: "const char *" "const char *" "void *" "size_t" */
+#define SYS_getxattr 378
+
+/* syscall: "lgetxattr" ret: "int" args: "const char *" "const char *" "void *" "size_t" */
+#define SYS_lgetxattr 379
+
+/* syscall: "fgetxattr" ret: "int" args: "int" "const char *" "void *" "size_t" */
+#define SYS_fgetxattr 380
+
+/* syscall: "listxattr" ret: "int" args: "const char *" "char *" "size_t" */
+#define SYS_listxattr 381
+
+/* syscall: "llistxattr" ret: "int" args: "const char *" "char *" "size_t" */
+#define SYS_llistxattr 382
+
+/* syscall: "flistxattr" ret: "int" args: "int" "char *" "size_t" */
+#define SYS_flistxattr 383
+
+/* syscall: "removexattr" ret: "int" args: "const char *" "const char *" */
+#define SYS_removexattr 384
+
+/* syscall: "lremovexattr" ret: "int" args: "const char *" "const char *" */
+#define SYS_lremovexattr 385
+
+/* syscall: "fremovexattr" ret: "int" args: "int" "const char *" */
+#define SYS_fremovexattr 386
+
+/* syscall: "compat_50___stat30" ret: "int" args: "const char *" "struct stat30 *" */
+#define SYS_compat_50___stat30 387
+
+/* syscall: "compat_50___fstat30" ret: "int" args: "int" "struct stat30 *" */
+#define SYS_compat_50___fstat30 388
+
+/* syscall: "compat_50___lstat30" ret: "int" args: "const char *" "struct stat30 *" */
+#define SYS_compat_50___lstat30 389
+
+/* syscall: "__getdents30" ret: "int" args: "int" "char *" "size_t" */
+#define SYS___getdents30 390
+
+ /* 391 is ignored old posix_fadvise */
+/* syscall: "compat_30___fhstat30" ret: "int" args: "const struct compat_30_fhandle *" "struct stat30 *" */
+#define SYS_compat_30___fhstat30 392
+
+/* syscall: "compat_50___ntp_gettime30" ret: "int" args: "struct ntptimeval50 *" */
+#define SYS_compat_50___ntp_gettime30 393
+
+/* syscall: "__socket30" ret: "int" args: "int" "int" "int" */
+#define SYS___socket30 394
+
+/* syscall: "__getfh30" ret: "int" args: "const char *" "void *" "size_t *" */
+#define SYS___getfh30 395
+
+/* syscall: "__fhopen40" ret: "int" args: "const void *" "size_t" "int" */
+#define SYS___fhopen40 396
+
+/* syscall: "__fhstatvfs140" ret: "int" args: "const void *" "size_t" "struct statvfs *" "int" */
+#define SYS___fhstatvfs140 397
+
+/* syscall: "compat_50___fhstat40" ret: "int" args: "const void *" "size_t" "struct stat30 *" */
+#define SYS_compat_50___fhstat40 398
+
+/* syscall: "aio_cancel" ret: "int" args: "int" "struct aiocb *" */
+#define SYS_aio_cancel 399
+
+/* syscall: "aio_error" ret: "int" args: "const struct aiocb *" */
+#define SYS_aio_error 400
+
+/* syscall: "aio_fsync" ret: "int" args: "int" "struct aiocb *" */
+#define SYS_aio_fsync 401
+
+/* syscall: "aio_read" ret: "int" args: "struct aiocb *" */
+#define SYS_aio_read 402
+
+/* syscall: "aio_return" ret: "int" args: "struct aiocb *" */
+#define SYS_aio_return 403
+
+/* syscall: "compat_50_aio_suspend" ret: "int" args: "const struct aiocb *const *" "int" "const struct timespec50 *" */
+#define SYS_compat_50_aio_suspend 404
+
+/* syscall: "aio_write" ret: "int" args: "struct aiocb *" */
+#define SYS_aio_write 405
+
+/* syscall: "lio_listio" ret: "int" args: "int" "struct aiocb *const *" "int" "struct sigevent *" */
+#define SYS_lio_listio 406
+
+/* syscall: "__mount50" ret: "int" args: "const char *" "const char *" "int" "void *" "size_t" */
+#define SYS___mount50 410
+
+/* syscall: "mremap" ret: "void *" args: "void *" "size_t" "void *" "size_t" "int" */
+#define SYS_mremap 411
+
+/* syscall: "pset_create" ret: "int" args: "psetid_t *" */
+#define SYS_pset_create 412
+
+/* syscall: "pset_destroy" ret: "int" args: "psetid_t" */
+#define SYS_pset_destroy 413
+
+/* syscall: "pset_assign" ret: "int" args: "psetid_t" "cpuid_t" "psetid_t *" */
+#define SYS_pset_assign 414
+
+/* syscall: "_pset_bind" ret: "int" args: "idtype_t" "id_t" "id_t" "psetid_t" "psetid_t *" */
+#define SYS__pset_bind 415
+
+/* syscall: "__posix_fadvise50" ret: "int" args: "int" "int" "off_t" "off_t" "int" */
+#define SYS___posix_fadvise50 416
+
+/* syscall: "__select50" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */
+#define SYS___select50 417
+
+/* syscall: "__gettimeofday50" ret: "int" args: "struct timeval *" "void *" */
+#define SYS___gettimeofday50 418
+
+/* syscall: "__settimeofday50" ret: "int" args: "const struct timeval *" "const void *" */
+#define SYS___settimeofday50 419
+
+/* syscall: "__utimes50" ret: "int" args: "const char *" "const struct timeval *" */
+#define SYS___utimes50 420
+
+/* syscall: "__adjtime50" ret: "int" args: "const struct timeval *" "struct timeval *" */
+#define SYS___adjtime50 421
+
+/* syscall: "__lfs_segwait50" ret: "int" args: "fsid_t *" "struct timeval *" */
+#define SYS___lfs_segwait50 422
+
+/* syscall: "__futimes50" ret: "int" args: "int" "const struct timeval *" */
+#define SYS___futimes50 423
+
+/* syscall: "__lutimes50" ret: "int" args: "const char *" "const struct timeval *" */
+#define SYS___lutimes50 424
+
+/* syscall: "__setitimer50" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */
+#define SYS___setitimer50 425
+
+/* syscall: "__getitimer50" ret: "int" args: "int" "struct itimerval *" */
+#define SYS___getitimer50 426
+
+/* syscall: "__clock_gettime50" ret: "int" args: "clockid_t" "struct timespec *" */
+#define SYS___clock_gettime50 427
+
+/* syscall: "__clock_settime50" ret: "int" args: "clockid_t" "const struct timespec *" */
+#define SYS___clock_settime50 428
+
+/* syscall: "__clock_getres50" ret: "int" args: "clockid_t" "struct timespec *" */
+#define SYS___clock_getres50 429
+
+/* syscall: "__nanosleep50" ret: "int" args: "const struct timespec *" "struct timespec *" */
+#define SYS___nanosleep50 430
+
+/* syscall: "____sigtimedwait50" ret: "int" args: "const sigset_t *" "siginfo_t *" "struct timespec *" */
+#define SYS_____sigtimedwait50 431
+
+/* syscall: "__mq_timedsend50" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" "const struct timespec *" */
+#define SYS___mq_timedsend50 432
+
+/* syscall: "__mq_timedreceive50" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" "const struct timespec *" */
+#define SYS___mq_timedreceive50 433
+
+/* syscall: "___lwp_park50" ret: "int" args: "const struct timespec *" "lwpid_t" "const void *" "const void *" */
+#define SYS____lwp_park50 434
+
+/* syscall: "__kevent50" ret: "int" args: "int" "const struct kevent *" "size_t" "struct kevent *" "size_t" "const struct timespec *" */
+#define SYS___kevent50 435
+
+/* syscall: "__pselect50" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "const struct timespec *" "const sigset_t *" */
+#define SYS___pselect50 436
+
+/* syscall: "__pollts50" ret: "int" args: "struct pollfd *" "u_int" "const struct timespec *" "const sigset_t *" */
+#define SYS___pollts50 437
+
+/* syscall: "__aio_suspend50" ret: "int" args: "const struct aiocb *const *" "int" "const struct timespec *" */
+#define SYS___aio_suspend50 438
+
+/* syscall: "__stat50" ret: "int" args: "const char *" "struct stat *" */
+#define SYS___stat50 439
+
+/* syscall: "__fstat50" ret: "int" args: "int" "struct stat *" */
+#define SYS___fstat50 440
+
+/* syscall: "__lstat50" ret: "int" args: "const char *" "struct stat *" */
+#define SYS___lstat50 441
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+/* syscall: "____semctl50" ret: "int" args: "int" "int" "int" "..." */
+#define SYS_____semctl50 442
+
+#else
+ /* 442 is excluded ____semctl50 */
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+/* syscall: "__shmctl50" ret: "int" args: "int" "int" "struct shmid_ds *" */
+#define SYS___shmctl50 443
+
+#else
+ /* 443 is excluded ____shmctl50 */
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+/* syscall: "__msgctl50" ret: "int" args: "int" "int" "struct msqid_ds *" */
+#define SYS___msgctl50 444
+
+#else
+ /* 444 is excluded ____msgctl50 */
+#endif
+/* syscall: "__getrusage50" ret: "int" args: "int" "struct rusage *" */
+#define SYS___getrusage50 445
+
+/* syscall: "__timer_settime50" ret: "int" args: "timer_t" "int" "const struct itimerspec *" "struct itimerspec *" */
+#define SYS___timer_settime50 446
+
+/* syscall: "__timer_gettime50" ret: "int" args: "timer_t" "struct itimerspec *" */
+#define SYS___timer_gettime50 447
+
+#if defined(NTP) || !defined(_KERNEL_OPT)
+/* syscall: "__ntp_gettime50" ret: "int" args: "struct ntptimeval *" */
+#define SYS___ntp_gettime50 448
+
+#else
+ /* 448 is excluded ___ntp_gettime50 */
+#endif
+/* syscall: "__wait450" ret: "int" args: "pid_t" "int *" "int" "struct rusage *" */
+#define SYS___wait450 449
+
+/* syscall: "__mknod50" ret: "int" args: "const char *" "mode_t" "dev_t" */
+#define SYS___mknod50 450
+
+/* syscall: "__fhstat50" ret: "int" args: "const void *" "size_t" "struct stat *" */
+#define SYS___fhstat50 451
+
+ /* 452 is obsolete 5.99 quotactl */
+/* syscall: "pipe2" ret: "int" args: "int *" "int" */
+#define SYS_pipe2 453
+
+/* syscall: "dup3" ret: "int" args: "int" "int" "int" */
+#define SYS_dup3 454
+
+/* syscall: "kqueue1" ret: "int" args: "int" */
+#define SYS_kqueue1 455
+
+/* syscall: "paccept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" "const sigset_t *" "int" */
+#define SYS_paccept 456
+
+/* syscall: "linkat" ret: "int" args: "int" "const char *" "int" "const char *" "int" */
+#define SYS_linkat 457
+
+/* syscall: "renameat" ret: "int" args: "int" "const char *" "int" "const char *" */
+#define SYS_renameat 458
+
+/* syscall: "mkfifoat" ret: "int" args: "int" "const char *" "mode_t" */
+#define SYS_mkfifoat 459
+
+/* syscall: "mknodat" ret: "int" args: "int" "const char *" "mode_t" "uint32_t" */
+#define SYS_mknodat 460
+
+/* syscall: "mkdirat" ret: "int" args: "int" "const char *" "mode_t" */
+#define SYS_mkdirat 461
+
+/* syscall: "faccessat" ret: "int" args: "int" "const char *" "int" "int" */
+#define SYS_faccessat 462
+
+/* syscall: "fchmodat" ret: "int" args: "int" "const char *" "mode_t" "int" */
+#define SYS_fchmodat 463
+
+/* syscall: "fchownat" ret: "int" args: "int" "const char *" "uid_t" "gid_t" "int" */
+#define SYS_fchownat 464
+
+/* syscall: "fexecve" ret: "int" args: "int" "char *const *" "char *const *" */
+#define SYS_fexecve 465
+
+/* syscall: "fstatat" ret: "int" args: "int" "const char *" "struct stat *" "int" */
+#define SYS_fstatat 466
+
+/* syscall: "utimensat" ret: "int" args: "int" "const char *" "const struct timespec *" "int" */
+#define SYS_utimensat 467
+
+/* syscall: "openat" ret: "int" args: "int" "const char *" "int" "..." */
+#define SYS_openat 468
+
+/* syscall: "readlinkat" ret: "int" args: "int" "const char *" "char *" "size_t" */
+#define SYS_readlinkat 469
+
+/* syscall: "symlinkat" ret: "int" args: "const char *" "int" "const char *" */
+#define SYS_symlinkat 470
+
+/* syscall: "unlinkat" ret: "int" args: "int" "const char *" "int" */
+#define SYS_unlinkat 471
+
+/* syscall: "futimens" ret: "int" args: "int" "const struct timespec *" */
+#define SYS_futimens 472
+
+/* syscall: "__quotactl" ret: "int" args: "const char *" "struct quotactl_args *" */
+#define SYS___quotactl 473
+
+/* syscall: "posix_spawn" ret: "int" args: "pid_t *" "const char *" "const struct posix_spawn_file_actions *" "const struct posix_spawnattr *" "char *const *" "char *const *" */
+#define SYS_posix_spawn 474
+
+/* syscall: "recvmmsg" ret: "int" args: "int" "struct mmsghdr *" "unsigned int" "unsigned int" "struct timespec *" */
+#define SYS_recvmmsg 475
+
+/* syscall: "sendmmsg" ret: "int" args: "int" "struct mmsghdr *" "unsigned int" "unsigned int" */
+#define SYS_sendmmsg 476
+
+/* syscall: "clock_nanosleep" ret: "int" args: "clockid_t" "int" "const struct timespec *" "struct timespec *" */
+#define SYS_clock_nanosleep 477
+
+#define SYS_MAXSYSCALL 478
+#define SYS_NSYSENT 512
+#endif /* _SYS_SYSCALL_H_ */
--- /dev/null
+/* $NetBSD: syscall_stats.h,v 1.4 2008/11/12 12:36:28 ad Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SYCALL_STAT_H_
+#define _SYS_SYCALL_STAT_H_
+
+#ifdef _KERNEL_OPT
+#include "opt_syscall_stats.h"
+#endif
+
+#ifdef SYSCALL_STATS
+#include <sys/syscall.h>
+
+extern uint64_t syscall_counts[SYS_NSYSENT];
+extern uint64_t syscall_count_user, syscall_count_system, syscall_count_interrupt;
+#define SYSCALL_COUNT(table, code) ((table)[code]++)
+
+#if defined(SYSCALL_TIMES) && defined(__HAVE_CPU_COUNTER)
+
+#include <machine/cpu_counter.h>
+extern uint64_t syscall_times[SYS_NSYSENT];
+
+#ifdef SYSCALL_TIMES_HASCOUNTER
+/* Force use of cycle counter - needed for Soekris systems */
+#define SYSCALL_TIME() (cpu_counter32())
+#else
+#define SYSCALL_TIME() (cpu_hascounter() ? cpu_counter32() : 0u)
+#endif
+
+#ifdef SYSCALL_TIMES_PROCTIMES
+#define SYSCALL_TIME_UPDATE_PROC(l, fld, delta) \
+ (l)->l_proc->p_##fld##ticks += (delta)
+#else
+#define SYSCALL_TIME_UPDATE_PROC(l, fld, delta)
+#endif
+
+/* lwp creation */
+#define SYSCALL_TIME_LWP_INIT(l) do { \
+ (l)->l_syscall_counter = &syscall_count_system; \
+ SYSCALL_TIME_WAKEUP(l); \
+} while (0)
+
+/* System call entry hook */
+#define SYSCALL_TIME_SYS_ENTRY(l, table, code) do { \
+ uint32_t now = SYSCALL_TIME(); \
+ SYSCALL_TIME_UPDATE_PROC(l, u, elapsed = now - (l)->l_syscall_time); \
+ (l)->l_syscall_counter = (table) + (code); \
+ (l)->l_syscall_time = now; \
+} while (0)
+
+/* System call - process sleep */
+#define SYSCALL_TIME_SLEEP(l) do { \
+ uint32_t now = SYSCALL_TIME(); \
+ uint32_t elapsed = now - (l)->l_syscall_time; \
+ (l)->l_syscall_time = now; \
+ *(l)->l_syscall_counter += elapsed; \
+ SYSCALL_TIME_UPDATE_PROC(l, s, elapsed); \
+} while (0)
+
+/* Process wakeup */
+#define SYSCALL_TIME_WAKEUP(l) \
+ (l)->l_syscall_time = SYSCALL_TIME()
+
+/* System call exit */
+#define SYSCALL_TIME_SYS_EXIT(l) do { \
+ uint32_t now = SYSCALL_TIME(); \
+ uint32_t elapsed = now - (l)->l_syscall_time; \
+ (l)->l_syscall_time = now; \
+ *(l)->l_syscall_counter += elapsed; \
+ (l)->l_syscall_counter = &syscall_count_user; \
+ SYSCALL_TIME_UPDATE_PROC(l, s, elapsed); \
+} while (0)
+
+#ifdef _notyet
+/* Interrupt entry hook */
+#define SYSCALL_TIME_ISR_ENTRY(l, old) do { \
+ uint32_t now = SYSCALL_TIME(); \
+ uint32_t elapsed = now - (l)->l_syscall_time; \
+ (l)->l_syscall_time = now; \
+ old = (l)->l_syscall_counter; \
+ if ((l)->l_syscall_counter != &syscall_count_interrupt) \
+ if ((l)->l_syscall_counter == &syscall_count_user) \
+ SYSCALL_TIME_UPDATE_PROC(l, u, elapsed); \
+ else { \
+ *(l)->l_syscall_counter += elapsed; \
+ SYSCALL_TIME_UPDATE_PROC(l, s, elapsed); \
+ } \
+ (l)->l_syscall_counter = &syscall_count_interrupt; \
+ } \
+} while (0)
+
+/* Interrupt exit hook */
+#define SYSCALL_TIME_ISR_EXIT(l, saved) do { \
+ uint32_t now = SYSCALL_TIME(); \
+ SYSCALL_TIME_UPDATE_PROC(l, i, now - (l)->l_syscall_time); \
+ (l)->l_syscall_time = now; \
+ (l)->l_syscall_counter = saved; \
+} while (0)
+#endif
+
+#endif
+#endif
+
+#ifndef SYSCALL_TIME_SYS_ENTRY
+#define SYSCALL_TIME_LWP_INIT(l)
+#define SYSCALL_TIME_SYS_ENTRY(l,table,code)
+#define SYSCALL_TIME_SLEEP(l)
+#define SYSCALL_TIME_WAKEUP(l)
+#define SYSCALL_TIME_SYS_EXIT(l)
+#define SYSCALL_TIME_ISR_ENTRY(l,old)
+#define SYSCALL_TIME_ISR_EXIT(l,saved)
+#undef SYSCALL_TIMES
+#endif
+
+#ifndef SYSCALL_COUNT
+#define SYSCALL_COUNT(table, code)
+#endif
+
+#endif /* !_SYS_SYCALL_STAT_H_ */
--- /dev/null
+/* $NetBSD: syscallargs.h,v 1.240 2012/10/02 01:46:20 christos Exp $ */
+
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.261 2012/10/02 01:44:28 christos Exp
+ */
+
+#ifndef _SYS_SYSCALLARGS_H_
+#define _SYS_SYSCALLARGS_H_
+
+#include <sys/mount.h>
+#ifndef RUMP_CLIENT
+#include <sys/sched.h>
+#endif
+#include <sys/socket.h>
+
+#define SYS_MAXSYSARGS 8
+
+#undef syscallarg
+#define syscallarg(x) \
+ union { \
+ register_t pad; \
+ struct { x datum; } le; \
+ struct { /* LINTED zero array dimension */ \
+ int8_t pad[ /* CONSTCOND */ \
+ (sizeof (register_t) < sizeof (x)) \
+ ? 0 \
+ : sizeof (register_t) - sizeof (x)]; \
+ x datum; \
+ } be; \
+ }
+
+#undef check_syscall_args
+#define check_syscall_args(call) /*LINTED*/ \
+ typedef char call##_check_args[sizeof (struct call##_args) \
+ <= SYS_MAXSYSARGS * sizeof (register_t) ? 1 : -1];
+
+#ifndef RUMP_CLIENT
+struct sys_syscall_args {
+ syscallarg(int) code;
+ syscallarg(register_t) args[SYS_MAXSYSARGS];
+};
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_exit_args {
+ syscallarg(int) rval;
+};
+check_syscall_args(sys_exit)
+#endif /* !RUMP_CLIENT */
+
+struct sys_read_args {
+ syscallarg(int) fd;
+ syscallarg(void *) buf;
+ syscallarg(size_t) nbyte;
+};
+check_syscall_args(sys_read)
+
+struct sys_write_args {
+ syscallarg(int) fd;
+ syscallarg(const void *) buf;
+ syscallarg(size_t) nbyte;
+};
+check_syscall_args(sys_write)
+
+struct sys_open_args {
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_open)
+
+struct sys_close_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_close)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_wait4_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage50 *) rusage;
+};
+check_syscall_args(compat_50_sys_wait4)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_creat_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(compat_43_sys_creat)
+#endif /* !RUMP_CLIENT */
+
+struct sys_link_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) link;
+};
+check_syscall_args(sys_link)
+
+struct sys_unlink_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_unlink)
+
+struct sys_chdir_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_chdir)
+
+struct sys_fchdir_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_fchdir)
+
+struct compat_50_sys_mknod_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+ syscallarg(uint32_t) dev;
+};
+check_syscall_args(compat_50_sys_mknod)
+
+struct sys_chmod_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_chmod)
+
+struct sys_chown_args {
+ syscallarg(const char *) path;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys_chown)
+
+#ifndef RUMP_CLIENT
+struct sys_obreak_args {
+ syscallarg(char *) nsize;
+};
+check_syscall_args(sys_obreak)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_20_sys_getfsstat_args {
+ syscallarg(struct statfs12 *) buf;
+ syscallarg(long) bufsize;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_20_sys_getfsstat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_lseek_args {
+ syscallarg(int) fd;
+ syscallarg(long) offset;
+ syscallarg(int) whence;
+};
+check_syscall_args(compat_43_sys_lseek)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_40_sys_mount_args {
+ syscallarg(const char *) type;
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+ syscallarg(void *) data;
+};
+check_syscall_args(compat_40_sys_mount)
+#endif /* !RUMP_CLIENT */
+
+struct sys_unmount_args {
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_unmount)
+
+struct sys_setuid_args {
+ syscallarg(uid_t) uid;
+};
+check_syscall_args(sys_setuid)
+
+#ifndef RUMP_CLIENT
+struct sys_ptrace_args {
+ syscallarg(int) req;
+ syscallarg(pid_t) pid;
+ syscallarg(void *) addr;
+ syscallarg(int) data;
+};
+check_syscall_args(sys_ptrace)
+#endif /* !RUMP_CLIENT */
+
+struct sys_recvmsg_args {
+ syscallarg(int) s;
+ syscallarg(struct msghdr *) msg;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_recvmsg)
+
+struct sys_sendmsg_args {
+ syscallarg(int) s;
+ syscallarg(const struct msghdr *) msg;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_sendmsg)
+
+struct sys_recvfrom_args {
+ syscallarg(int) s;
+ syscallarg(void *) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(struct sockaddr *) from;
+ syscallarg(socklen_t *) fromlenaddr;
+};
+check_syscall_args(sys_recvfrom)
+
+struct sys_accept_args {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) name;
+ syscallarg(socklen_t *) anamelen;
+};
+check_syscall_args(sys_accept)
+
+struct sys_getpeername_args {
+ syscallarg(int) fdes;
+ syscallarg(struct sockaddr *) asa;
+ syscallarg(socklen_t *) alen;
+};
+check_syscall_args(sys_getpeername)
+
+struct sys_getsockname_args {
+ syscallarg(int) fdes;
+ syscallarg(struct sockaddr *) asa;
+ syscallarg(socklen_t *) alen;
+};
+check_syscall_args(sys_getsockname)
+
+struct sys_access_args {
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_access)
+
+struct sys_chflags_args {
+ syscallarg(const char *) path;
+ syscallarg(u_long) flags;
+};
+check_syscall_args(sys_chflags)
+
+struct sys_fchflags_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) flags;
+};
+check_syscall_args(sys_fchflags)
+
+#ifndef RUMP_CLIENT
+struct sys_kill_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int) signum;
+};
+check_syscall_args(sys_kill)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_stat_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat43 *) ub;
+};
+check_syscall_args(compat_43_sys_stat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_lstat_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat43 *) ub;
+};
+check_syscall_args(compat_43_sys_lstat)
+#endif /* !RUMP_CLIENT */
+
+struct sys_dup_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_dup)
+
+#ifndef RUMP_CLIENT
+struct sys_profil_args {
+ syscallarg(char *) samples;
+ syscallarg(size_t) size;
+ syscallarg(u_long) offset;
+ syscallarg(u_int) scale;
+};
+check_syscall_args(sys_profil)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_ktrace_args {
+ syscallarg(const char *) fname;
+ syscallarg(int) ops;
+ syscallarg(int) facs;
+ syscallarg(pid_t) pid;
+};
+check_syscall_args(sys_ktrace)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_13_sys_sigaction_args {
+ syscallarg(int) signum;
+ syscallarg(const struct sigaction13 *) nsa;
+ syscallarg(struct sigaction13 *) osa;
+};
+check_syscall_args(compat_13_sys_sigaction)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_13_sys_sigprocmask_args {
+ syscallarg(int) how;
+ syscallarg(int) mask;
+};
+check_syscall_args(compat_13_sys_sigprocmask)
+#endif /* !RUMP_CLIENT */
+
+struct sys___getlogin_args {
+ syscallarg(char *) namebuf;
+ syscallarg(size_t) namelen;
+};
+check_syscall_args(sys___getlogin)
+
+struct sys___setlogin_args {
+ syscallarg(const char *) namebuf;
+};
+check_syscall_args(sys___setlogin)
+
+#ifndef RUMP_CLIENT
+struct sys_acct_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_acct)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_13_sys_sigaltstack_args {
+ syscallarg(const struct sigaltstack13 *) nss;
+ syscallarg(struct sigaltstack13 *) oss;
+};
+check_syscall_args(compat_13_sys_sigaltstack)
+#endif /* !RUMP_CLIENT */
+
+struct sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(void *) data;
+};
+check_syscall_args(sys_ioctl)
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_reboot_args {
+ syscallarg(int) opt;
+};
+check_syscall_args(compat_12_sys_reboot)
+#endif /* !RUMP_CLIENT */
+
+struct sys_revoke_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_revoke)
+
+struct sys_symlink_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) link;
+};
+check_syscall_args(sys_symlink)
+
+struct sys_readlink_args {
+ syscallarg(const char *) path;
+ syscallarg(char *) buf;
+ syscallarg(size_t) count;
+};
+check_syscall_args(sys_readlink)
+
+#ifndef RUMP_CLIENT
+struct sys_execve_args {
+ syscallarg(const char *) path;
+ syscallarg(char *const *) argp;
+ syscallarg(char *const *) envp;
+};
+check_syscall_args(sys_execve)
+#endif /* !RUMP_CLIENT */
+
+struct sys_umask_args {
+ syscallarg(mode_t) newmask;
+};
+check_syscall_args(sys_umask)
+
+struct sys_chroot_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_chroot)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct stat43 *) sb;
+};
+check_syscall_args(compat_43_sys_fstat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_getkerninfo_args {
+ syscallarg(int) op;
+ syscallarg(char *) where;
+ syscallarg(int *) size;
+ syscallarg(int) arg;
+};
+check_syscall_args(compat_43_sys_getkerninfo)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_msync_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+};
+check_syscall_args(compat_12_sys_msync)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_sbrk_args {
+ syscallarg(intptr_t) incr;
+};
+check_syscall_args(sys_sbrk)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_sstk_args {
+ syscallarg(int) incr;
+};
+check_syscall_args(sys_sstk)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_mmap_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pos;
+};
+check_syscall_args(compat_43_sys_mmap)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_ovadvise_args {
+ syscallarg(int) anom;
+};
+check_syscall_args(sys_ovadvise)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_munmap_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+};
+check_syscall_args(sys_munmap)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mprotect_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+};
+check_syscall_args(sys_mprotect)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_madvise_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) behav;
+};
+check_syscall_args(sys_madvise)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mincore_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(char *) vec;
+};
+check_syscall_args(sys_mincore)
+#endif /* !RUMP_CLIENT */
+
+struct sys_getgroups_args {
+ syscallarg(int) gidsetsize;
+ syscallarg(gid_t *) gidset;
+};
+check_syscall_args(sys_getgroups)
+
+struct sys_setgroups_args {
+ syscallarg(int) gidsetsize;
+ syscallarg(const gid_t *) gidset;
+};
+check_syscall_args(sys_setgroups)
+
+struct sys_setpgid_args {
+ syscallarg(pid_t) pid;
+ syscallarg(pid_t) pgid;
+};
+check_syscall_args(sys_setpgid)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_setitimer_args {
+ syscallarg(int) which;
+ syscallarg(const struct itimerval50 *) itv;
+ syscallarg(struct itimerval50 *) oitv;
+};
+check_syscall_args(compat_50_sys_setitimer)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_swapon_args {
+ syscallarg(const char *) name;
+};
+check_syscall_args(compat_12_sys_swapon)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_getitimer_args {
+ syscallarg(int) which;
+ syscallarg(struct itimerval50 *) itv;
+};
+check_syscall_args(compat_50_sys_getitimer)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_gethostname_args {
+ syscallarg(char *) hostname;
+ syscallarg(u_int) len;
+};
+check_syscall_args(compat_43_sys_gethostname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sethostname_args {
+ syscallarg(char *) hostname;
+ syscallarg(u_int) len;
+};
+check_syscall_args(compat_43_sys_sethostname)
+#endif /* !RUMP_CLIENT */
+
+struct sys_dup2_args {
+ syscallarg(int) from;
+ syscallarg(int) to;
+};
+check_syscall_args(sys_dup2)
+
+struct sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+};
+check_syscall_args(sys_fcntl)
+
+struct compat_50_sys_select_args {
+ syscallarg(int) nd;
+ syscallarg(fd_set *) in;
+ syscallarg(fd_set *) ou;
+ syscallarg(fd_set *) ex;
+ syscallarg(struct timeval50 *) tv;
+};
+check_syscall_args(compat_50_sys_select)
+
+struct sys_fsync_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_fsync)
+
+#ifndef RUMP_CLIENT
+struct sys_setpriority_args {
+ syscallarg(int) which;
+ syscallarg(id_t) who;
+ syscallarg(int) prio;
+};
+check_syscall_args(sys_setpriority)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_socket_args {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+};
+check_syscall_args(compat_30_sys_socket)
+#endif /* !RUMP_CLIENT */
+
+struct sys_connect_args {
+ syscallarg(int) s;
+ syscallarg(const struct sockaddr *) name;
+ syscallarg(socklen_t) namelen;
+};
+check_syscall_args(sys_connect)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_accept_args {
+ syscallarg(int) s;
+ syscallarg(void *) name;
+ syscallarg(socklen_t *) anamelen;
+};
+check_syscall_args(compat_43_sys_accept)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_getpriority_args {
+ syscallarg(int) which;
+ syscallarg(id_t) who;
+};
+check_syscall_args(sys_getpriority)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_send_args {
+ syscallarg(int) s;
+ syscallarg(void *) buf;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_43_sys_send)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_recv_args {
+ syscallarg(int) s;
+ syscallarg(void *) buf;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_43_sys_recv)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_13_sys_sigreturn_args {
+ syscallarg(struct sigcontext13 *) sigcntxp;
+};
+check_syscall_args(compat_13_sys_sigreturn)
+#endif /* !RUMP_CLIENT */
+
+struct sys_bind_args {
+ syscallarg(int) s;
+ syscallarg(const struct sockaddr *) name;
+ syscallarg(socklen_t) namelen;
+};
+check_syscall_args(sys_bind)
+
+struct sys_setsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(const void *) val;
+ syscallarg(socklen_t) valsize;
+};
+check_syscall_args(sys_setsockopt)
+
+struct sys_listen_args {
+ syscallarg(int) s;
+ syscallarg(int) backlog;
+};
+check_syscall_args(sys_listen)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sigvec_args {
+ syscallarg(int) signum;
+ syscallarg(struct sigvec *) nsv;
+ syscallarg(struct sigvec *) osv;
+};
+check_syscall_args(compat_43_sys_sigvec)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sigblock_args {
+ syscallarg(int) mask;
+};
+check_syscall_args(compat_43_sys_sigblock)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sigsetmask_args {
+ syscallarg(int) mask;
+};
+check_syscall_args(compat_43_sys_sigsetmask)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_13_sys_sigsuspend_args {
+ syscallarg(int) mask;
+};
+check_syscall_args(compat_13_sys_sigsuspend)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sigstack_args {
+ syscallarg(struct sigstack *) nss;
+ syscallarg(struct sigstack *) oss;
+};
+check_syscall_args(compat_43_sys_sigstack)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_recvmsg_args {
+ syscallarg(int) s;
+ syscallarg(struct omsghdr *) msg;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_43_sys_recvmsg)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sendmsg_args {
+ syscallarg(int) s;
+ syscallarg(void *) msg;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_43_sys_sendmsg)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_gettimeofday_args {
+ syscallarg(struct timeval50 *) tp;
+ syscallarg(void *) tzp;
+};
+check_syscall_args(compat_50_sys_gettimeofday)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_getrusage_args {
+ syscallarg(int) who;
+ syscallarg(struct rusage50 *) rusage;
+};
+check_syscall_args(compat_50_sys_getrusage)
+#endif /* !RUMP_CLIENT */
+
+struct sys_getsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(void *) val;
+ syscallarg(socklen_t *) avalsize;
+};
+check_syscall_args(sys_getsockopt)
+
+struct sys_readv_args {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+};
+check_syscall_args(sys_readv)
+
+struct sys_writev_args {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+};
+check_syscall_args(sys_writev)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_settimeofday_args {
+ syscallarg(const struct timeval50 *) tv;
+ syscallarg(const void *) tzp;
+};
+check_syscall_args(compat_50_sys_settimeofday)
+#endif /* !RUMP_CLIENT */
+
+struct sys_fchown_args {
+ syscallarg(int) fd;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys_fchown)
+
+struct sys_fchmod_args {
+ syscallarg(int) fd;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_fchmod)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_recvfrom_args {
+ syscallarg(int) s;
+ syscallarg(void *) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(void *) from;
+ syscallarg(socklen_t *) fromlenaddr;
+};
+check_syscall_args(compat_43_sys_recvfrom)
+#endif /* !RUMP_CLIENT */
+
+struct sys_setreuid_args {
+ syscallarg(uid_t) ruid;
+ syscallarg(uid_t) euid;
+};
+check_syscall_args(sys_setreuid)
+
+struct sys_setregid_args {
+ syscallarg(gid_t) rgid;
+ syscallarg(gid_t) egid;
+};
+check_syscall_args(sys_setregid)
+
+struct sys_rename_args {
+ syscallarg(const char *) from;
+ syscallarg(const char *) to;
+};
+check_syscall_args(sys_rename)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_truncate_args {
+ syscallarg(const char *) path;
+ syscallarg(long) length;
+};
+check_syscall_args(compat_43_sys_truncate)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_ftruncate_args {
+ syscallarg(int) fd;
+ syscallarg(long) length;
+};
+check_syscall_args(compat_43_sys_ftruncate)
+#endif /* !RUMP_CLIENT */
+
+struct sys_flock_args {
+ syscallarg(int) fd;
+ syscallarg(int) how;
+};
+check_syscall_args(sys_flock)
+
+struct sys_mkfifo_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_mkfifo)
+
+struct sys_sendto_args {
+ syscallarg(int) s;
+ syscallarg(const void *) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(const struct sockaddr *) to;
+ syscallarg(socklen_t) tolen;
+};
+check_syscall_args(sys_sendto)
+
+struct sys_shutdown_args {
+ syscallarg(int) s;
+ syscallarg(int) how;
+};
+check_syscall_args(sys_shutdown)
+
+struct sys_socketpair_args {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+ syscallarg(int *) rsv;
+};
+check_syscall_args(sys_socketpair)
+
+struct sys_mkdir_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_mkdir)
+
+struct sys_rmdir_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_rmdir)
+
+struct compat_50_sys_utimes_args {
+ syscallarg(const char *) path;
+ syscallarg(const struct timeval50 *) tptr;
+};
+check_syscall_args(compat_50_sys_utimes)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_adjtime_args {
+ syscallarg(const struct timeval50 *) delta;
+ syscallarg(struct timeval50 *) olddelta;
+};
+check_syscall_args(compat_50_sys_adjtime)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_getpeername_args {
+ syscallarg(int) fdes;
+ syscallarg(void *) asa;
+ syscallarg(socklen_t *) alen;
+};
+check_syscall_args(compat_43_sys_getpeername)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_sethostid_args {
+ syscallarg(int32_t) hostid;
+};
+check_syscall_args(compat_43_sys_sethostid)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_getrlimit_args {
+ syscallarg(int) which;
+ syscallarg(struct orlimit *) rlp;
+};
+check_syscall_args(compat_43_sys_getrlimit)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_setrlimit_args {
+ syscallarg(int) which;
+ syscallarg(const struct orlimit *) rlp;
+};
+check_syscall_args(compat_43_sys_setrlimit)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_killpg_args {
+ syscallarg(int) pgid;
+ syscallarg(int) signum;
+};
+check_syscall_args(compat_43_sys_killpg)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_quotactl_args {
+ syscallarg(const char *) path;
+ syscallarg(int) cmd;
+ syscallarg(int) uid;
+ syscallarg(void *) arg;
+};
+check_syscall_args(compat_50_sys_quotactl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_getsockname_args {
+ syscallarg(int) fdec;
+ syscallarg(void *) asa;
+ syscallarg(socklen_t *) alen;
+};
+check_syscall_args(compat_43_sys_getsockname)
+#endif /* !RUMP_CLIENT */
+
+struct sys_nfssvc_args {
+ syscallarg(int) flag;
+ syscallarg(void *) argp;
+};
+check_syscall_args(sys_nfssvc)
+
+#ifndef RUMP_CLIENT
+struct compat_43_sys_getdirentries_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) count;
+ syscallarg(long *) basep;
+};
+check_syscall_args(compat_43_sys_getdirentries)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_20_sys_statfs_args {
+ syscallarg(const char *) path;
+ syscallarg(struct statfs12 *) buf;
+};
+check_syscall_args(compat_20_sys_statfs)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_20_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct statfs12 *) buf;
+};
+check_syscall_args(compat_20_sys_fstatfs)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_getfh_args {
+ syscallarg(const char *) fname;
+ syscallarg(struct compat_30_fhandle *) fhp;
+};
+check_syscall_args(compat_30_sys_getfh)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_09_sys_getdomainname_args {
+ syscallarg(char *) domainname;
+ syscallarg(int) len;
+};
+check_syscall_args(compat_09_sys_getdomainname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_09_sys_setdomainname_args {
+ syscallarg(char *) domainname;
+ syscallarg(int) len;
+};
+check_syscall_args(compat_09_sys_setdomainname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_09_sys_uname_args {
+ syscallarg(struct outsname *) name;
+};
+check_syscall_args(compat_09_sys_uname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_sysarch_args {
+ syscallarg(int) op;
+ syscallarg(void *) parms;
+};
+check_syscall_args(sys_sysarch)
+#endif /* !RUMP_CLIENT */
+#if (defined(SYSVSEM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+
+#ifndef RUMP_CLIENT
+struct compat_10_sys_semsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+};
+check_syscall_args(compat_10_sys_semsys)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if (defined(SYSVMSG) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+
+#ifndef RUMP_CLIENT
+struct compat_10_sys_msgsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ syscallarg(int) a6;
+};
+check_syscall_args(compat_10_sys_msgsys)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if (defined(SYSVSHM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+
+#ifndef RUMP_CLIENT
+struct compat_10_sys_shmsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+};
+check_syscall_args(compat_10_sys_shmsys)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+struct sys_pread_args {
+ syscallarg(int) fd;
+ syscallarg(void *) buf;
+ syscallarg(size_t) nbyte;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+};
+check_syscall_args(sys_pread)
+
+struct sys_pwrite_args {
+ syscallarg(int) fd;
+ syscallarg(const void *) buf;
+ syscallarg(size_t) nbyte;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+};
+check_syscall_args(sys_pwrite)
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_ntp_gettime_args {
+ syscallarg(struct ntptimeval30 *) ntvp;
+};
+check_syscall_args(compat_30_sys_ntp_gettime)
+#endif /* !RUMP_CLIENT */
+#if defined(NTP) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys_ntp_adjtime_args {
+ syscallarg(struct timex *) tp;
+};
+check_syscall_args(sys_ntp_adjtime)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+struct sys_setgid_args {
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys_setgid)
+
+struct sys_setegid_args {
+ syscallarg(gid_t) egid;
+};
+check_syscall_args(sys_setegid)
+
+struct sys_seteuid_args {
+ syscallarg(uid_t) euid;
+};
+check_syscall_args(sys_seteuid)
+
+#ifndef RUMP_CLIENT
+struct sys_lfs_bmapv_args {
+ syscallarg(fsid_t *) fsidp;
+ syscallarg(struct block_info *) blkiov;
+ syscallarg(int) blkcnt;
+};
+check_syscall_args(sys_lfs_bmapv)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_lfs_markv_args {
+ syscallarg(fsid_t *) fsidp;
+ syscallarg(struct block_info *) blkiov;
+ syscallarg(int) blkcnt;
+};
+check_syscall_args(sys_lfs_markv)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_lfs_segclean_args {
+ syscallarg(fsid_t *) fsidp;
+ syscallarg(u_long) segment;
+};
+check_syscall_args(sys_lfs_segclean)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_lfs_segwait_args {
+ syscallarg(fsid_t *) fsidp;
+ syscallarg(struct timeval50 *) tv;
+};
+check_syscall_args(compat_50_sys_lfs_segwait)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_stat_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat12 *) ub;
+};
+check_syscall_args(compat_12_sys_stat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct stat12 *) sb;
+};
+check_syscall_args(compat_12_sys_fstat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_lstat_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat12 *) ub;
+};
+check_syscall_args(compat_12_sys_lstat)
+#endif /* !RUMP_CLIENT */
+
+struct sys_pathconf_args {
+ syscallarg(const char *) path;
+ syscallarg(int) name;
+};
+check_syscall_args(sys_pathconf)
+
+struct sys_fpathconf_args {
+ syscallarg(int) fd;
+ syscallarg(int) name;
+};
+check_syscall_args(sys_fpathconf)
+
+struct sys_getrlimit_args {
+ syscallarg(int) which;
+ syscallarg(struct rlimit *) rlp;
+};
+check_syscall_args(sys_getrlimit)
+
+struct sys_setrlimit_args {
+ syscallarg(int) which;
+ syscallarg(const struct rlimit *) rlp;
+};
+check_syscall_args(sys_setrlimit)
+
+#ifndef RUMP_CLIENT
+struct compat_12_sys_getdirentries_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) count;
+ syscallarg(long *) basep;
+};
+check_syscall_args(compat_12_sys_getdirentries)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mmap_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) PAD;
+ syscallarg(off_t) pos;
+};
+check_syscall_args(sys_mmap)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___syscall_args {
+ syscallarg(quad_t) code;
+ syscallarg(register_t) args[SYS_MAXSYSARGS];
+};
+#endif /* !RUMP_CLIENT */
+
+struct sys_lseek_args {
+ syscallarg(int) fd;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+ syscallarg(int) whence;
+};
+check_syscall_args(sys_lseek)
+
+struct sys_truncate_args {
+ syscallarg(const char *) path;
+ syscallarg(int) PAD;
+ syscallarg(off_t) length;
+};
+check_syscall_args(sys_truncate)
+
+struct sys_ftruncate_args {
+ syscallarg(int) fd;
+ syscallarg(int) PAD;
+ syscallarg(off_t) length;
+};
+check_syscall_args(sys_ftruncate)
+
+struct sys___sysctl_args {
+ syscallarg(const int *) name;
+ syscallarg(u_int) namelen;
+ syscallarg(void *) old;
+ syscallarg(size_t *) oldlenp;
+ syscallarg(const void *) new;
+ syscallarg(size_t) newlen;
+};
+check_syscall_args(sys___sysctl)
+
+#ifndef RUMP_CLIENT
+struct sys_mlock_args {
+ syscallarg(const void *) addr;
+ syscallarg(size_t) len;
+};
+check_syscall_args(sys_mlock)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_munlock_args {
+ syscallarg(const void *) addr;
+ syscallarg(size_t) len;
+};
+check_syscall_args(sys_munlock)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_undelete_args {
+ syscallarg(const char *) path;
+};
+check_syscall_args(sys_undelete)
+#endif /* !RUMP_CLIENT */
+
+struct compat_50_sys_futimes_args {
+ syscallarg(int) fd;
+ syscallarg(const struct timeval50 *) tptr;
+};
+check_syscall_args(compat_50_sys_futimes)
+
+struct sys_getpgid_args {
+ syscallarg(pid_t) pid;
+};
+check_syscall_args(sys_getpgid)
+
+struct sys_reboot_args {
+ syscallarg(int) opt;
+ syscallarg(char *) bootstr;
+};
+check_syscall_args(sys_reboot)
+
+struct sys_poll_args {
+ syscallarg(struct pollfd *) fds;
+ syscallarg(u_int) nfds;
+ syscallarg(int) timeout;
+};
+check_syscall_args(sys_poll)
+
+#ifndef RUMP_CLIENT
+struct sys_afssys_args {
+ syscallarg(long) id;
+ syscallarg(long) a1;
+ syscallarg(long) a2;
+ syscallarg(long) a3;
+ syscallarg(long) a4;
+ syscallarg(long) a5;
+ syscallarg(long) a6;
+};
+check_syscall_args(sys_afssys)
+#endif /* !RUMP_CLIENT */
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct compat_14_sys___semctl_args {
+ syscallarg(int) semid;
+ syscallarg(int) semnum;
+ syscallarg(int) cmd;
+ syscallarg(union __semun *) arg;
+};
+check_syscall_args(compat_14_sys___semctl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_semget_args {
+ syscallarg(key_t) key;
+ syscallarg(int) nsems;
+ syscallarg(int) semflg;
+};
+check_syscall_args(sys_semget)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_semop_args {
+ syscallarg(int) semid;
+ syscallarg(struct sembuf *) sops;
+ syscallarg(size_t) nsops;
+};
+check_syscall_args(sys_semop)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_semconfig_args {
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_semconfig)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct compat_14_sys_msgctl_args {
+ syscallarg(int) msqid;
+ syscallarg(int) cmd;
+ syscallarg(struct msqid_ds14 *) buf;
+};
+check_syscall_args(compat_14_sys_msgctl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_msgget_args {
+ syscallarg(key_t) key;
+ syscallarg(int) msgflg;
+};
+check_syscall_args(sys_msgget)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_msgsnd_args {
+ syscallarg(int) msqid;
+ syscallarg(const void *) msgp;
+ syscallarg(size_t) msgsz;
+ syscallarg(int) msgflg;
+};
+check_syscall_args(sys_msgsnd)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_msgrcv_args {
+ syscallarg(int) msqid;
+ syscallarg(void *) msgp;
+ syscallarg(size_t) msgsz;
+ syscallarg(long) msgtyp;
+ syscallarg(int) msgflg;
+};
+check_syscall_args(sys_msgrcv)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys_shmat_args {
+ syscallarg(int) shmid;
+ syscallarg(const void *) shmaddr;
+ syscallarg(int) shmflg;
+};
+check_syscall_args(sys_shmat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_14_sys_shmctl_args {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(struct shmid_ds14 *) buf;
+};
+check_syscall_args(compat_14_sys_shmctl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_shmdt_args {
+ syscallarg(const void *) shmaddr;
+};
+check_syscall_args(sys_shmdt)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_shmget_args {
+ syscallarg(key_t) key;
+ syscallarg(size_t) size;
+ syscallarg(int) shmflg;
+};
+check_syscall_args(sys_shmget)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_clock_gettime_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(struct timespec50 *) tp;
+};
+check_syscall_args(compat_50_sys_clock_gettime)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_clock_settime_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(const struct timespec50 *) tp;
+};
+check_syscall_args(compat_50_sys_clock_settime)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_clock_getres_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(struct timespec50 *) tp;
+};
+check_syscall_args(compat_50_sys_clock_getres)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_timer_create_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(struct sigevent *) evp;
+ syscallarg(timer_t *) timerid;
+};
+check_syscall_args(sys_timer_create)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_timer_delete_args {
+ syscallarg(timer_t) timerid;
+};
+check_syscall_args(sys_timer_delete)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_timer_settime_args {
+ syscallarg(timer_t) timerid;
+ syscallarg(int) flags;
+ syscallarg(const struct itimerspec50 *) value;
+ syscallarg(struct itimerspec50 *) ovalue;
+};
+check_syscall_args(compat_50_sys_timer_settime)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_timer_gettime_args {
+ syscallarg(timer_t) timerid;
+ syscallarg(struct itimerspec50 *) value;
+};
+check_syscall_args(compat_50_sys_timer_gettime)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_timer_getoverrun_args {
+ syscallarg(timer_t) timerid;
+};
+check_syscall_args(sys_timer_getoverrun)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_nanosleep_args {
+ syscallarg(const struct timespec50 *) rqtp;
+ syscallarg(struct timespec50 *) rmtp;
+};
+check_syscall_args(compat_50_sys_nanosleep)
+#endif /* !RUMP_CLIENT */
+
+struct sys_fdatasync_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_fdatasync)
+
+#ifndef RUMP_CLIENT
+struct sys_mlockall_args {
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_mlockall)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys___sigtimedwait_args {
+ syscallarg(const sigset_t *) set;
+ syscallarg(siginfo_t *) info;
+ syscallarg(struct timespec50 *) timeout;
+};
+check_syscall_args(compat_50_sys___sigtimedwait)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_sigqueueinfo_args {
+ syscallarg(pid_t) pid;
+ syscallarg(const siginfo_t *) info;
+};
+check_syscall_args(sys_sigqueueinfo)
+#endif /* !RUMP_CLIENT */
+
+struct sys_modctl_args {
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+};
+check_syscall_args(sys_modctl)
+
+struct sys__ksem_init_args {
+ syscallarg(unsigned int) value;
+ syscallarg(intptr_t *) idp;
+};
+check_syscall_args(sys__ksem_init)
+
+struct sys__ksem_open_args {
+ syscallarg(const char *) name;
+ syscallarg(int) oflag;
+ syscallarg(mode_t) mode;
+ syscallarg(unsigned int) value;
+ syscallarg(intptr_t *) idp;
+};
+check_syscall_args(sys__ksem_open)
+
+struct sys__ksem_unlink_args {
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys__ksem_unlink)
+
+struct sys__ksem_close_args {
+ syscallarg(intptr_t) id;
+};
+check_syscall_args(sys__ksem_close)
+
+struct sys__ksem_post_args {
+ syscallarg(intptr_t) id;
+};
+check_syscall_args(sys__ksem_post)
+
+struct sys__ksem_wait_args {
+ syscallarg(intptr_t) id;
+};
+check_syscall_args(sys__ksem_wait)
+
+struct sys__ksem_trywait_args {
+ syscallarg(intptr_t) id;
+};
+check_syscall_args(sys__ksem_trywait)
+
+struct sys__ksem_getvalue_args {
+ syscallarg(intptr_t) id;
+ syscallarg(unsigned int *) value;
+};
+check_syscall_args(sys__ksem_getvalue)
+
+struct sys__ksem_destroy_args {
+ syscallarg(intptr_t) id;
+};
+check_syscall_args(sys__ksem_destroy)
+
+struct sys__ksem_timedwait_args {
+ syscallarg(intptr_t) id;
+ syscallarg(const struct timespec *) abstime;
+};
+check_syscall_args(sys__ksem_timedwait)
+
+#ifndef RUMP_CLIENT
+struct sys_mq_open_args {
+ syscallarg(const char *) name;
+ syscallarg(int) oflag;
+ syscallarg(mode_t) mode;
+ syscallarg(struct mq_attr *) attr;
+};
+check_syscall_args(sys_mq_open)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_close_args {
+ syscallarg(mqd_t) mqdes;
+};
+check_syscall_args(sys_mq_close)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_unlink_args {
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys_mq_unlink)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_getattr_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(struct mq_attr *) mqstat;
+};
+check_syscall_args(sys_mq_getattr)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_setattr_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(const struct mq_attr *) mqstat;
+ syscallarg(struct mq_attr *) omqstat;
+};
+check_syscall_args(sys_mq_setattr)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_notify_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(const struct sigevent *) notification;
+};
+check_syscall_args(sys_mq_notify)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_send_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(const char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned) msg_prio;
+};
+check_syscall_args(sys_mq_send)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_mq_receive_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned *) msg_prio;
+};
+check_syscall_args(sys_mq_receive)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_mq_timedsend_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(const char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned) msg_prio;
+ syscallarg(const struct timespec50 *) abs_timeout;
+};
+check_syscall_args(compat_50_sys_mq_timedsend)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_mq_timedreceive_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned *) msg_prio;
+ syscallarg(const struct timespec50 *) abs_timeout;
+};
+check_syscall_args(compat_50_sys_mq_timedreceive)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___posix_rename_args {
+ syscallarg(const char *) from;
+ syscallarg(const char *) to;
+};
+check_syscall_args(sys___posix_rename)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_swapctl_args {
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+ syscallarg(int) misc;
+};
+check_syscall_args(sys_swapctl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_getdents_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(size_t) count;
+};
+check_syscall_args(compat_30_sys_getdents)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_minherit_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) inherit;
+};
+check_syscall_args(sys_minherit)
+#endif /* !RUMP_CLIENT */
+
+struct sys_lchmod_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_lchmod)
+
+struct sys_lchown_args {
+ syscallarg(const char *) path;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys_lchown)
+
+struct compat_50_sys_lutimes_args {
+ syscallarg(const char *) path;
+ syscallarg(const struct timeval50 *) tptr;
+};
+check_syscall_args(compat_50_sys_lutimes)
+
+#ifndef RUMP_CLIENT
+struct sys___msync13_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys___msync13)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys___stat13_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat13 *) ub;
+};
+check_syscall_args(compat_30_sys___stat13)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys___fstat13_args {
+ syscallarg(int) fd;
+ syscallarg(struct stat13 *) sb;
+};
+check_syscall_args(compat_30_sys___fstat13)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys___lstat13_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat13 *) ub;
+};
+check_syscall_args(compat_30_sys___lstat13)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___sigaltstack14_args {
+ syscallarg(const struct sigaltstack *) nss;
+ syscallarg(struct sigaltstack *) oss;
+};
+check_syscall_args(sys___sigaltstack14)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___posix_chown_args {
+ syscallarg(const char *) path;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys___posix_chown)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___posix_fchown_args {
+ syscallarg(int) fd;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys___posix_fchown)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___posix_lchown_args {
+ syscallarg(const char *) path;
+ syscallarg(uid_t) uid;
+ syscallarg(gid_t) gid;
+};
+check_syscall_args(sys___posix_lchown)
+#endif /* !RUMP_CLIENT */
+
+struct sys_getsid_args {
+ syscallarg(pid_t) pid;
+};
+check_syscall_args(sys_getsid)
+
+#ifndef RUMP_CLIENT
+struct sys___clone_args {
+ syscallarg(int) flags;
+ syscallarg(void *) stack;
+};
+check_syscall_args(sys___clone)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_fktrace_args {
+ syscallarg(int) fd;
+ syscallarg(int) ops;
+ syscallarg(int) facs;
+ syscallarg(pid_t) pid;
+};
+check_syscall_args(sys_fktrace)
+#endif /* !RUMP_CLIENT */
+
+struct sys_preadv_args {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+};
+check_syscall_args(sys_preadv)
+
+struct sys_pwritev_args {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+};
+check_syscall_args(sys_pwritev)
+
+#ifndef RUMP_CLIENT
+struct compat_16_sys___sigaction14_args {
+ syscallarg(int) signum;
+ syscallarg(const struct sigaction *) nsa;
+ syscallarg(struct sigaction *) osa;
+};
+check_syscall_args(compat_16_sys___sigaction14)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___sigpending14_args {
+ syscallarg(sigset_t *) set;
+};
+check_syscall_args(sys___sigpending14)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___sigprocmask14_args {
+ syscallarg(int) how;
+ syscallarg(const sigset_t *) set;
+ syscallarg(sigset_t *) oset;
+};
+check_syscall_args(sys___sigprocmask14)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___sigsuspend14_args {
+ syscallarg(const sigset_t *) set;
+};
+check_syscall_args(sys___sigsuspend14)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_16_sys___sigreturn14_args {
+ syscallarg(struct sigcontext *) sigcntxp;
+};
+check_syscall_args(compat_16_sys___sigreturn14)
+#endif /* !RUMP_CLIENT */
+
+struct sys___getcwd_args {
+ syscallarg(char *) bufp;
+ syscallarg(size_t) length;
+};
+check_syscall_args(sys___getcwd)
+
+struct sys_fchroot_args {
+ syscallarg(int) fd;
+};
+check_syscall_args(sys_fchroot)
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_fhopen_args {
+ syscallarg(const struct compat_30_fhandle *) fhp;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_30_sys_fhopen)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_fhstat_args {
+ syscallarg(const struct compat_30_fhandle *) fhp;
+ syscallarg(struct stat13 *) sb;
+};
+check_syscall_args(compat_30_sys_fhstat)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_20_sys_fhstatfs_args {
+ syscallarg(const struct compat_30_fhandle *) fhp;
+ syscallarg(struct statfs12 *) buf;
+};
+check_syscall_args(compat_20_sys_fhstatfs)
+#endif /* !RUMP_CLIENT */
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_____semctl13_args {
+ syscallarg(int) semid;
+ syscallarg(int) semnum;
+ syscallarg(int) cmd;
+ syscallarg(union __semun *) arg;
+};
+check_syscall_args(compat_50_sys_____semctl13)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys___msgctl13_args {
+ syscallarg(int) msqid;
+ syscallarg(int) cmd;
+ syscallarg(struct msqid_ds *) buf;
+};
+check_syscall_args(compat_50_sys___msgctl13)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys___shmctl13_args {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(struct shmid_ds13 *) buf;
+};
+check_syscall_args(compat_50_sys___shmctl13)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+struct sys_lchflags_args {
+ syscallarg(const char *) path;
+ syscallarg(u_long) flags;
+};
+check_syscall_args(sys_lchflags)
+
+#ifndef RUMP_CLIENT
+struct sys_utrace_args {
+ syscallarg(const char *) label;
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+};
+check_syscall_args(sys_utrace)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_getcontext_args {
+ syscallarg(struct __ucontext *) ucp;
+};
+check_syscall_args(sys_getcontext)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_setcontext_args {
+ syscallarg(const struct __ucontext *) ucp;
+};
+check_syscall_args(sys_setcontext)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_create_args {
+ syscallarg(const struct __ucontext *) ucp;
+ syscallarg(u_long) flags;
+ syscallarg(lwpid_t *) new_lwp;
+};
+check_syscall_args(sys__lwp_create)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_wait_args {
+ syscallarg(lwpid_t) wait_for;
+ syscallarg(lwpid_t *) departed;
+};
+check_syscall_args(sys__lwp_wait)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_suspend_args {
+ syscallarg(lwpid_t) target;
+};
+check_syscall_args(sys__lwp_suspend)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_continue_args {
+ syscallarg(lwpid_t) target;
+};
+check_syscall_args(sys__lwp_continue)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_wakeup_args {
+ syscallarg(lwpid_t) target;
+};
+check_syscall_args(sys__lwp_wakeup)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_setprivate_args {
+ syscallarg(void *) ptr;
+};
+check_syscall_args(sys__lwp_setprivate)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_kill_args {
+ syscallarg(lwpid_t) target;
+ syscallarg(int) signo;
+};
+check_syscall_args(sys__lwp_kill)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_detach_args {
+ syscallarg(lwpid_t) target;
+};
+check_syscall_args(sys__lwp_detach)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys__lwp_park_args {
+ syscallarg(const struct timespec50 *) ts;
+ syscallarg(lwpid_t) unpark;
+ syscallarg(const void *) hint;
+ syscallarg(const void *) unparkhint;
+};
+check_syscall_args(compat_50_sys__lwp_park)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_unpark_args {
+ syscallarg(lwpid_t) target;
+ syscallarg(const void *) hint;
+};
+check_syscall_args(sys__lwp_unpark)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_unpark_all_args {
+ syscallarg(const lwpid_t *) targets;
+ syscallarg(size_t) ntargets;
+ syscallarg(const void *) hint;
+};
+check_syscall_args(sys__lwp_unpark_all)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_setname_args {
+ syscallarg(lwpid_t) target;
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys__lwp_setname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_getname_args {
+ syscallarg(lwpid_t) target;
+ syscallarg(char *) name;
+ syscallarg(size_t) len;
+};
+check_syscall_args(sys__lwp_getname)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__lwp_ctl_args {
+ syscallarg(int) features;
+ syscallarg(struct lwpctl **) address;
+};
+check_syscall_args(sys__lwp_ctl)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_60_sys_sa_register_args {
+ syscallarg(void *) new;
+ syscallarg(void **) old;
+ syscallarg(int) flags;
+ syscallarg(ssize_t) stackinfo_offset;
+};
+check_syscall_args(compat_60_sys_sa_register)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_60_sys_sa_stacks_args {
+ syscallarg(int) num;
+ syscallarg(stack_t *) stacks;
+};
+check_syscall_args(compat_60_sys_sa_stacks)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_60_sys_sa_setconcurrency_args {
+ syscallarg(int) concurrency;
+};
+check_syscall_args(compat_60_sys_sa_setconcurrency)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_60_sys_sa_preempt_args {
+ syscallarg(int) sa_id;
+};
+check_syscall_args(compat_60_sys_sa_preempt)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___sigaction_sigtramp_args {
+ syscallarg(int) signum;
+ syscallarg(const struct sigaction *) nsa;
+ syscallarg(struct sigaction *) osa;
+ syscallarg(const void *) tramp;
+ syscallarg(int) vers;
+};
+check_syscall_args(sys___sigaction_sigtramp)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_pmc_get_info_args {
+ syscallarg(int) ctr;
+ syscallarg(int) op;
+ syscallarg(void *) args;
+};
+check_syscall_args(sys_pmc_get_info)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_pmc_control_args {
+ syscallarg(int) ctr;
+ syscallarg(int) op;
+ syscallarg(void *) args;
+};
+check_syscall_args(sys_pmc_control)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_rasctl_args {
+ syscallarg(void *) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) op;
+};
+check_syscall_args(sys_rasctl)
+#endif /* !RUMP_CLIENT */
+
+struct compat_50_sys_kevent_args {
+ syscallarg(int) fd;
+ syscallarg(const struct kevent *) changelist;
+ syscallarg(size_t) nchanges;
+ syscallarg(struct kevent *) eventlist;
+ syscallarg(size_t) nevents;
+ syscallarg(const struct timespec50 *) timeout;
+};
+check_syscall_args(compat_50_sys_kevent)
+
+#ifndef RUMP_CLIENT
+struct sys__sched_setparam_args {
+ syscallarg(pid_t) pid;
+ syscallarg(lwpid_t) lid;
+ syscallarg(int) policy;
+ syscallarg(const struct sched_param *) params;
+};
+check_syscall_args(sys__sched_setparam)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__sched_getparam_args {
+ syscallarg(pid_t) pid;
+ syscallarg(lwpid_t) lid;
+ syscallarg(int *) policy;
+ syscallarg(struct sched_param *) params;
+};
+check_syscall_args(sys__sched_getparam)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__sched_setaffinity_args {
+ syscallarg(pid_t) pid;
+ syscallarg(lwpid_t) lid;
+ syscallarg(size_t) size;
+ syscallarg(const cpuset_t *) cpuset;
+};
+check_syscall_args(sys__sched_setaffinity)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__sched_getaffinity_args {
+ syscallarg(pid_t) pid;
+ syscallarg(lwpid_t) lid;
+ syscallarg(size_t) size;
+ syscallarg(cpuset_t *) cpuset;
+};
+check_syscall_args(sys__sched_getaffinity)
+#endif /* !RUMP_CLIENT */
+
+struct sys_fsync_range_args {
+ syscallarg(int) fd;
+ syscallarg(int) flags;
+ syscallarg(off_t) start;
+ syscallarg(off_t) length;
+};
+check_syscall_args(sys_fsync_range)
+
+#ifndef RUMP_CLIENT
+struct sys_uuidgen_args {
+ syscallarg(struct uuid *) store;
+ syscallarg(int) count;
+};
+check_syscall_args(sys_uuidgen)
+#endif /* !RUMP_CLIENT */
+
+struct sys_getvfsstat_args {
+ syscallarg(struct statvfs *) buf;
+ syscallarg(size_t) bufsize;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_getvfsstat)
+
+struct sys_statvfs1_args {
+ syscallarg(const char *) path;
+ syscallarg(struct statvfs *) buf;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_statvfs1)
+
+struct sys_fstatvfs1_args {
+ syscallarg(int) fd;
+ syscallarg(struct statvfs *) buf;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_fstatvfs1)
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys_fhstatvfs1_args {
+ syscallarg(const struct compat_30_fhandle *) fhp;
+ syscallarg(struct statvfs *) buf;
+ syscallarg(int) flags;
+};
+check_syscall_args(compat_30_sys_fhstatvfs1)
+#endif /* !RUMP_CLIENT */
+
+struct sys_extattrctl_args {
+ syscallarg(const char *) path;
+ syscallarg(int) cmd;
+ syscallarg(const char *) filename;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+};
+check_syscall_args(sys_extattrctl)
+
+struct sys_extattr_set_file_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(const void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_set_file)
+
+struct sys_extattr_get_file_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_get_file)
+
+struct sys_extattr_delete_file_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+};
+check_syscall_args(sys_extattr_delete_file)
+
+struct sys_extattr_set_fd_args {
+ syscallarg(int) fd;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(const void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_set_fd)
+
+struct sys_extattr_get_fd_args {
+ syscallarg(int) fd;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_get_fd)
+
+struct sys_extattr_delete_fd_args {
+ syscallarg(int) fd;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+};
+check_syscall_args(sys_extattr_delete_fd)
+
+struct sys_extattr_set_link_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(const void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_set_link)
+
+struct sys_extattr_get_link_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_get_link)
+
+struct sys_extattr_delete_link_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(const char *) attrname;
+};
+check_syscall_args(sys_extattr_delete_link)
+
+struct sys_extattr_list_fd_args {
+ syscallarg(int) fd;
+ syscallarg(int) attrnamespace;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_list_fd)
+
+struct sys_extattr_list_file_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_list_file)
+
+struct sys_extattr_list_link_args {
+ syscallarg(const char *) path;
+ syscallarg(int) attrnamespace;
+ syscallarg(void *) data;
+ syscallarg(size_t) nbytes;
+};
+check_syscall_args(sys_extattr_list_link)
+
+struct compat_50_sys_pselect_args {
+ syscallarg(int) nd;
+ syscallarg(fd_set *) in;
+ syscallarg(fd_set *) ou;
+ syscallarg(fd_set *) ex;
+ syscallarg(const struct timespec50 *) ts;
+ syscallarg(const sigset_t *) mask;
+};
+check_syscall_args(compat_50_sys_pselect)
+
+struct compat_50_sys_pollts_args {
+ syscallarg(struct pollfd *) fds;
+ syscallarg(u_int) nfds;
+ syscallarg(const struct timespec50 *) ts;
+ syscallarg(const sigset_t *) mask;
+};
+check_syscall_args(compat_50_sys_pollts)
+
+struct sys_setxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+ syscallarg(const void *) value;
+ syscallarg(size_t) size;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_setxattr)
+
+struct sys_lsetxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+ syscallarg(const void *) value;
+ syscallarg(size_t) size;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_lsetxattr)
+
+struct sys_fsetxattr_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) name;
+ syscallarg(const void *) value;
+ syscallarg(size_t) size;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_fsetxattr)
+
+struct sys_getxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+ syscallarg(void *) value;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_getxattr)
+
+struct sys_lgetxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+ syscallarg(void *) value;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_lgetxattr)
+
+struct sys_fgetxattr_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) name;
+ syscallarg(void *) value;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_fgetxattr)
+
+struct sys_listxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(char *) list;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_listxattr)
+
+struct sys_llistxattr_args {
+ syscallarg(const char *) path;
+ syscallarg(char *) list;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_llistxattr)
+
+struct sys_flistxattr_args {
+ syscallarg(int) fd;
+ syscallarg(char *) list;
+ syscallarg(size_t) size;
+};
+check_syscall_args(sys_flistxattr)
+
+struct sys_removexattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys_removexattr)
+
+struct sys_lremovexattr_args {
+ syscallarg(const char *) path;
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys_lremovexattr)
+
+struct sys_fremovexattr_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) name;
+};
+check_syscall_args(sys_fremovexattr)
+
+struct compat_50_sys___stat30_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat30 *) ub;
+};
+check_syscall_args(compat_50_sys___stat30)
+
+struct compat_50_sys___fstat30_args {
+ syscallarg(int) fd;
+ syscallarg(struct stat30 *) sb;
+};
+check_syscall_args(compat_50_sys___fstat30)
+
+struct compat_50_sys___lstat30_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat30 *) ub;
+};
+check_syscall_args(compat_50_sys___lstat30)
+
+struct sys___getdents30_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(size_t) count;
+};
+check_syscall_args(sys___getdents30)
+
+#ifndef RUMP_CLIENT
+struct compat_30_sys___fhstat30_args {
+ syscallarg(const struct compat_30_fhandle *) fhp;
+ syscallarg(struct stat30 *) sb;
+};
+check_syscall_args(compat_30_sys___fhstat30)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys___ntp_gettime30_args {
+ syscallarg(struct ntptimeval50 *) ntvp;
+};
+check_syscall_args(compat_50_sys___ntp_gettime30)
+#endif /* !RUMP_CLIENT */
+
+struct sys___socket30_args {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+};
+check_syscall_args(sys___socket30)
+
+struct sys___getfh30_args {
+ syscallarg(const char *) fname;
+ syscallarg(void *) fhp;
+ syscallarg(size_t *) fh_size;
+};
+check_syscall_args(sys___getfh30)
+
+struct sys___fhopen40_args {
+ syscallarg(const void *) fhp;
+ syscallarg(size_t) fh_size;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys___fhopen40)
+
+struct sys___fhstatvfs140_args {
+ syscallarg(const void *) fhp;
+ syscallarg(size_t) fh_size;
+ syscallarg(struct statvfs *) buf;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys___fhstatvfs140)
+
+struct compat_50_sys___fhstat40_args {
+ syscallarg(const void *) fhp;
+ syscallarg(size_t) fh_size;
+ syscallarg(struct stat30 *) sb;
+};
+check_syscall_args(compat_50_sys___fhstat40)
+
+#ifndef RUMP_CLIENT
+struct sys_aio_cancel_args {
+ syscallarg(int) fildes;
+ syscallarg(struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_cancel)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_aio_error_args {
+ syscallarg(const struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_error)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_aio_fsync_args {
+ syscallarg(int) op;
+ syscallarg(struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_fsync)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_aio_read_args {
+ syscallarg(struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_read)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_aio_return_args {
+ syscallarg(struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_return)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct compat_50_sys_aio_suspend_args {
+ syscallarg(const struct aiocb *const *) list;
+ syscallarg(int) nent;
+ syscallarg(const struct timespec50 *) timeout;
+};
+check_syscall_args(compat_50_sys_aio_suspend)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_aio_write_args {
+ syscallarg(struct aiocb *) aiocbp;
+};
+check_syscall_args(sys_aio_write)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_lio_listio_args {
+ syscallarg(int) mode;
+ syscallarg(struct aiocb *const *) list;
+ syscallarg(int) nent;
+ syscallarg(struct sigevent *) sig;
+};
+check_syscall_args(sys_lio_listio)
+#endif /* !RUMP_CLIENT */
+
+struct sys___mount50_args {
+ syscallarg(const char *) type;
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+ syscallarg(void *) data;
+ syscallarg(size_t) data_len;
+};
+check_syscall_args(sys___mount50)
+
+#ifndef RUMP_CLIENT
+struct sys_mremap_args {
+ syscallarg(void *) old_address;
+ syscallarg(size_t) old_size;
+ syscallarg(void *) new_address;
+ syscallarg(size_t) new_size;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_mremap)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_pset_create_args {
+ syscallarg(psetid_t *) psid;
+};
+check_syscall_args(sys_pset_create)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_pset_destroy_args {
+ syscallarg(psetid_t) psid;
+};
+check_syscall_args(sys_pset_destroy)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_pset_assign_args {
+ syscallarg(psetid_t) psid;
+ syscallarg(cpuid_t) cpuid;
+ syscallarg(psetid_t *) opsid;
+};
+check_syscall_args(sys_pset_assign)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys__pset_bind_args {
+ syscallarg(idtype_t) idtype;
+ syscallarg(id_t) first_id;
+ syscallarg(id_t) second_id;
+ syscallarg(psetid_t) psid;
+ syscallarg(psetid_t *) opsid;
+};
+check_syscall_args(sys__pset_bind)
+#endif /* !RUMP_CLIENT */
+
+struct sys___posix_fadvise50_args {
+ syscallarg(int) fd;
+ syscallarg(int) PAD;
+ syscallarg(off_t) offset;
+ syscallarg(off_t) len;
+ syscallarg(int) advice;
+};
+check_syscall_args(sys___posix_fadvise50)
+
+struct sys___select50_args {
+ syscallarg(int) nd;
+ syscallarg(fd_set *) in;
+ syscallarg(fd_set *) ou;
+ syscallarg(fd_set *) ex;
+ syscallarg(struct timeval *) tv;
+};
+check_syscall_args(sys___select50)
+
+#ifndef RUMP_CLIENT
+struct sys___gettimeofday50_args {
+ syscallarg(struct timeval *) tp;
+ syscallarg(void *) tzp;
+};
+check_syscall_args(sys___gettimeofday50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___settimeofday50_args {
+ syscallarg(const struct timeval *) tv;
+ syscallarg(const void *) tzp;
+};
+check_syscall_args(sys___settimeofday50)
+#endif /* !RUMP_CLIENT */
+
+struct sys___utimes50_args {
+ syscallarg(const char *) path;
+ syscallarg(const struct timeval *) tptr;
+};
+check_syscall_args(sys___utimes50)
+
+#ifndef RUMP_CLIENT
+struct sys___adjtime50_args {
+ syscallarg(const struct timeval *) delta;
+ syscallarg(struct timeval *) olddelta;
+};
+check_syscall_args(sys___adjtime50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___lfs_segwait50_args {
+ syscallarg(fsid_t *) fsidp;
+ syscallarg(struct timeval *) tv;
+};
+check_syscall_args(sys___lfs_segwait50)
+#endif /* !RUMP_CLIENT */
+
+struct sys___futimes50_args {
+ syscallarg(int) fd;
+ syscallarg(const struct timeval *) tptr;
+};
+check_syscall_args(sys___futimes50)
+
+struct sys___lutimes50_args {
+ syscallarg(const char *) path;
+ syscallarg(const struct timeval *) tptr;
+};
+check_syscall_args(sys___lutimes50)
+
+#ifndef RUMP_CLIENT
+struct sys___setitimer50_args {
+ syscallarg(int) which;
+ syscallarg(const struct itimerval *) itv;
+ syscallarg(struct itimerval *) oitv;
+};
+check_syscall_args(sys___setitimer50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___getitimer50_args {
+ syscallarg(int) which;
+ syscallarg(struct itimerval *) itv;
+};
+check_syscall_args(sys___getitimer50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___clock_gettime50_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(struct timespec *) tp;
+};
+check_syscall_args(sys___clock_gettime50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___clock_settime50_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(const struct timespec *) tp;
+};
+check_syscall_args(sys___clock_settime50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___clock_getres50_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(struct timespec *) tp;
+};
+check_syscall_args(sys___clock_getres50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___nanosleep50_args {
+ syscallarg(const struct timespec *) rqtp;
+ syscallarg(struct timespec *) rmtp;
+};
+check_syscall_args(sys___nanosleep50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_____sigtimedwait50_args {
+ syscallarg(const sigset_t *) set;
+ syscallarg(siginfo_t *) info;
+ syscallarg(struct timespec *) timeout;
+};
+check_syscall_args(sys_____sigtimedwait50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___mq_timedsend50_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(const char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned) msg_prio;
+ syscallarg(const struct timespec *) abs_timeout;
+};
+check_syscall_args(sys___mq_timedsend50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___mq_timedreceive50_args {
+ syscallarg(mqd_t) mqdes;
+ syscallarg(char *) msg_ptr;
+ syscallarg(size_t) msg_len;
+ syscallarg(unsigned *) msg_prio;
+ syscallarg(const struct timespec *) abs_timeout;
+};
+check_syscall_args(sys___mq_timedreceive50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys____lwp_park50_args {
+ syscallarg(const struct timespec *) ts;
+ syscallarg(lwpid_t) unpark;
+ syscallarg(const void *) hint;
+ syscallarg(const void *) unparkhint;
+};
+check_syscall_args(sys____lwp_park50)
+#endif /* !RUMP_CLIENT */
+
+struct sys___kevent50_args {
+ syscallarg(int) fd;
+ syscallarg(const struct kevent *) changelist;
+ syscallarg(size_t) nchanges;
+ syscallarg(struct kevent *) eventlist;
+ syscallarg(size_t) nevents;
+ syscallarg(const struct timespec *) timeout;
+};
+check_syscall_args(sys___kevent50)
+
+struct sys___pselect50_args {
+ syscallarg(int) nd;
+ syscallarg(fd_set *) in;
+ syscallarg(fd_set *) ou;
+ syscallarg(fd_set *) ex;
+ syscallarg(const struct timespec *) ts;
+ syscallarg(const sigset_t *) mask;
+};
+check_syscall_args(sys___pselect50)
+
+struct sys___pollts50_args {
+ syscallarg(struct pollfd *) fds;
+ syscallarg(u_int) nfds;
+ syscallarg(const struct timespec *) ts;
+ syscallarg(const sigset_t *) mask;
+};
+check_syscall_args(sys___pollts50)
+
+#ifndef RUMP_CLIENT
+struct sys___aio_suspend50_args {
+ syscallarg(const struct aiocb *const *) list;
+ syscallarg(int) nent;
+ syscallarg(const struct timespec *) timeout;
+};
+check_syscall_args(sys___aio_suspend50)
+#endif /* !RUMP_CLIENT */
+
+struct sys___stat50_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat *) ub;
+};
+check_syscall_args(sys___stat50)
+
+struct sys___fstat50_args {
+ syscallarg(int) fd;
+ syscallarg(struct stat *) sb;
+};
+check_syscall_args(sys___fstat50)
+
+struct sys___lstat50_args {
+ syscallarg(const char *) path;
+ syscallarg(struct stat *) ub;
+};
+check_syscall_args(sys___lstat50)
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys_____semctl50_args {
+ syscallarg(int) semid;
+ syscallarg(int) semnum;
+ syscallarg(int) cmd;
+ syscallarg(union __semun *) arg;
+};
+check_syscall_args(sys_____semctl50)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys___shmctl50_args {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(struct shmid_ds *) buf;
+};
+check_syscall_args(sys___shmctl50)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys___msgctl50_args {
+ syscallarg(int) msqid;
+ syscallarg(int) cmd;
+ syscallarg(struct msqid_ds *) buf;
+};
+check_syscall_args(sys___msgctl50)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+#ifndef RUMP_CLIENT
+struct sys___getrusage50_args {
+ syscallarg(int) who;
+ syscallarg(struct rusage *) rusage;
+};
+check_syscall_args(sys___getrusage50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___timer_settime50_args {
+ syscallarg(timer_t) timerid;
+ syscallarg(int) flags;
+ syscallarg(const struct itimerspec *) value;
+ syscallarg(struct itimerspec *) ovalue;
+};
+check_syscall_args(sys___timer_settime50)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys___timer_gettime50_args {
+ syscallarg(timer_t) timerid;
+ syscallarg(struct itimerspec *) value;
+};
+check_syscall_args(sys___timer_gettime50)
+#endif /* !RUMP_CLIENT */
+#if defined(NTP) || !defined(_KERNEL_OPT)
+
+#ifndef RUMP_CLIENT
+struct sys___ntp_gettime50_args {
+ syscallarg(struct ntptimeval *) ntvp;
+};
+check_syscall_args(sys___ntp_gettime50)
+#endif /* !RUMP_CLIENT */
+#else
+#endif
+
+#ifndef RUMP_CLIENT
+struct sys___wait450_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+};
+check_syscall_args(sys___wait450)
+#endif /* !RUMP_CLIENT */
+
+struct sys___mknod50_args {
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+ syscallarg(dev_t) dev;
+};
+check_syscall_args(sys___mknod50)
+
+struct sys___fhstat50_args {
+ syscallarg(const void *) fhp;
+ syscallarg(size_t) fh_size;
+ syscallarg(struct stat *) sb;
+};
+check_syscall_args(sys___fhstat50)
+
+struct sys_pipe2_args {
+ syscallarg(int *) fildes;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_pipe2)
+
+struct sys_dup3_args {
+ syscallarg(int) from;
+ syscallarg(int) to;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_dup3)
+
+struct sys_kqueue1_args {
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_kqueue1)
+
+struct sys_paccept_args {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) name;
+ syscallarg(socklen_t *) anamelen;
+ syscallarg(const sigset_t *) mask;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_paccept)
+
+struct sys_linkat_args {
+ syscallarg(int) fd1;
+ syscallarg(const char *) name1;
+ syscallarg(int) fd2;
+ syscallarg(const char *) name2;
+ syscallarg(int) flags;
+};
+check_syscall_args(sys_linkat)
+
+struct sys_renameat_args {
+ syscallarg(int) fromfd;
+ syscallarg(const char *) from;
+ syscallarg(int) tofd;
+ syscallarg(const char *) to;
+};
+check_syscall_args(sys_renameat)
+
+struct sys_mkfifoat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_mkfifoat)
+
+struct sys_mknodat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+ syscallarg(uint32_t) dev;
+};
+check_syscall_args(sys_mknodat)
+
+struct sys_mkdirat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_mkdirat)
+
+struct sys_faccessat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(int) amode;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_faccessat)
+
+struct sys_fchmodat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(mode_t) mode;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_fchmodat)
+
+struct sys_fchownat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(uid_t) owner;
+ syscallarg(gid_t) group;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_fchownat)
+
+struct sys_fexecve_args {
+ syscallarg(int) fd;
+ syscallarg(char *const *) argp;
+ syscallarg(char *const *) envp;
+};
+check_syscall_args(sys_fexecve)
+
+struct sys_fstatat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(struct stat *) buf;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_fstatat)
+
+struct sys_utimensat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(const struct timespec *) tptr;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_utimensat)
+
+struct sys_openat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(int) oflags;
+ syscallarg(mode_t) mode;
+};
+check_syscall_args(sys_openat)
+
+struct sys_readlinkat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(char *) buf;
+ syscallarg(size_t) bufsize;
+};
+check_syscall_args(sys_readlinkat)
+
+struct sys_symlinkat_args {
+ syscallarg(const char *) path1;
+ syscallarg(int) fd;
+ syscallarg(const char *) path2;
+};
+check_syscall_args(sys_symlinkat)
+
+struct sys_unlinkat_args {
+ syscallarg(int) fd;
+ syscallarg(const char *) path;
+ syscallarg(int) flag;
+};
+check_syscall_args(sys_unlinkat)
+
+struct sys_futimens_args {
+ syscallarg(int) fd;
+ syscallarg(const struct timespec *) tptr;
+};
+check_syscall_args(sys_futimens)
+
+struct sys___quotactl_args {
+ syscallarg(const char *) path;
+ syscallarg(struct quotactl_args *) args;
+};
+check_syscall_args(sys___quotactl)
+
+#ifndef RUMP_CLIENT
+struct sys_posix_spawn_args {
+ syscallarg(pid_t *) pid;
+ syscallarg(const char *) path;
+ syscallarg(const struct posix_spawn_file_actions *) file_actions;
+ syscallarg(const struct posix_spawnattr *) attrp;
+ syscallarg(char *const *) argv;
+ syscallarg(char *const *) envp;
+};
+check_syscall_args(sys_posix_spawn)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_recvmmsg_args {
+ syscallarg(int) s;
+ syscallarg(struct mmsghdr *) mmsg;
+ syscallarg(unsigned int) vlen;
+ syscallarg(unsigned int) flags;
+ syscallarg(struct timespec *) timeout;
+};
+check_syscall_args(sys_recvmmsg)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_sendmmsg_args {
+ syscallarg(int) s;
+ syscallarg(struct mmsghdr *) mmsg;
+ syscallarg(unsigned int) vlen;
+ syscallarg(unsigned int) flags;
+};
+check_syscall_args(sys_sendmmsg)
+#endif /* !RUMP_CLIENT */
+
+#ifndef RUMP_CLIENT
+struct sys_clock_nanosleep_args {
+ syscallarg(clockid_t) clock_id;
+ syscallarg(int) flags;
+ syscallarg(const struct timespec *) rqtp;
+ syscallarg(struct timespec *) rmtp;
+};
+check_syscall_args(sys_clock_nanosleep)
+#endif /* !RUMP_CLIENT */
+
+/*
+ * System call prototypes.
+ */
+
+#ifndef RUMP_CLIENT
+int sys_syscall(struct lwp *, const struct sys_syscall_args *, register_t *);
+
+int sys_exit(struct lwp *, const struct sys_exit_args *, register_t *);
+
+int sys_fork(struct lwp *, const void *, register_t *);
+
+int sys_read(struct lwp *, const struct sys_read_args *, register_t *);
+
+int sys_write(struct lwp *, const struct sys_write_args *, register_t *);
+
+int sys_open(struct lwp *, const struct sys_open_args *, register_t *);
+
+int sys_close(struct lwp *, const struct sys_close_args *, register_t *);
+
+int compat_50_sys_wait4(struct lwp *, const struct compat_50_sys_wait4_args *, register_t *);
+
+int compat_43_sys_creat(struct lwp *, const struct compat_43_sys_creat_args *, register_t *);
+
+int sys_link(struct lwp *, const struct sys_link_args *, register_t *);
+
+int sys_unlink(struct lwp *, const struct sys_unlink_args *, register_t *);
+
+int sys_chdir(struct lwp *, const struct sys_chdir_args *, register_t *);
+
+int sys_fchdir(struct lwp *, const struct sys_fchdir_args *, register_t *);
+
+int compat_50_sys_mknod(struct lwp *, const struct compat_50_sys_mknod_args *, register_t *);
+
+int sys_chmod(struct lwp *, const struct sys_chmod_args *, register_t *);
+
+int sys_chown(struct lwp *, const struct sys_chown_args *, register_t *);
+
+int sys_obreak(struct lwp *, const struct sys_obreak_args *, register_t *);
+
+int compat_20_sys_getfsstat(struct lwp *, const struct compat_20_sys_getfsstat_args *, register_t *);
+
+int compat_43_sys_lseek(struct lwp *, const struct compat_43_sys_lseek_args *, register_t *);
+
+int sys_getpid_with_ppid(struct lwp *, const void *, register_t *);
+
+int compat_40_sys_mount(struct lwp *, const struct compat_40_sys_mount_args *, register_t *);
+
+int sys_unmount(struct lwp *, const struct sys_unmount_args *, register_t *);
+
+int sys_setuid(struct lwp *, const struct sys_setuid_args *, register_t *);
+
+int sys_getuid_with_euid(struct lwp *, const void *, register_t *);
+
+int sys_geteuid(struct lwp *, const void *, register_t *);
+
+int sys_ptrace(struct lwp *, const struct sys_ptrace_args *, register_t *);
+
+int sys_recvmsg(struct lwp *, const struct sys_recvmsg_args *, register_t *);
+
+int sys_sendmsg(struct lwp *, const struct sys_sendmsg_args *, register_t *);
+
+int sys_recvfrom(struct lwp *, const struct sys_recvfrom_args *, register_t *);
+
+int sys_accept(struct lwp *, const struct sys_accept_args *, register_t *);
+
+int sys_getpeername(struct lwp *, const struct sys_getpeername_args *, register_t *);
+
+int sys_getsockname(struct lwp *, const struct sys_getsockname_args *, register_t *);
+
+int sys_access(struct lwp *, const struct sys_access_args *, register_t *);
+
+int sys_chflags(struct lwp *, const struct sys_chflags_args *, register_t *);
+
+int sys_fchflags(struct lwp *, const struct sys_fchflags_args *, register_t *);
+
+int sys_sync(struct lwp *, const void *, register_t *);
+
+int sys_kill(struct lwp *, const struct sys_kill_args *, register_t *);
+
+int compat_43_sys_stat(struct lwp *, const struct compat_43_sys_stat_args *, register_t *);
+
+int sys_getppid(struct lwp *, const void *, register_t *);
+
+int compat_43_sys_lstat(struct lwp *, const struct compat_43_sys_lstat_args *, register_t *);
+
+int sys_dup(struct lwp *, const struct sys_dup_args *, register_t *);
+
+int sys_pipe(struct lwp *, const void *, register_t *);
+
+int sys_getegid(struct lwp *, const void *, register_t *);
+
+int sys_profil(struct lwp *, const struct sys_profil_args *, register_t *);
+
+int sys_ktrace(struct lwp *, const struct sys_ktrace_args *, register_t *);
+
+int compat_13_sys_sigaction(struct lwp *, const struct compat_13_sys_sigaction_args *, register_t *);
+
+int sys_getgid_with_egid(struct lwp *, const void *, register_t *);
+
+int compat_13_sys_sigprocmask(struct lwp *, const struct compat_13_sys_sigprocmask_args *, register_t *);
+
+int sys___getlogin(struct lwp *, const struct sys___getlogin_args *, register_t *);
+
+int sys___setlogin(struct lwp *, const struct sys___setlogin_args *, register_t *);
+
+int sys_acct(struct lwp *, const struct sys_acct_args *, register_t *);
+
+int compat_13_sys_sigpending(struct lwp *, const void *, register_t *);
+
+int compat_13_sys_sigaltstack(struct lwp *, const struct compat_13_sys_sigaltstack_args *, register_t *);
+
+int sys_ioctl(struct lwp *, const struct sys_ioctl_args *, register_t *);
+
+int compat_12_sys_reboot(struct lwp *, const struct compat_12_sys_reboot_args *, register_t *);
+
+int sys_revoke(struct lwp *, const struct sys_revoke_args *, register_t *);
+
+int sys_symlink(struct lwp *, const struct sys_symlink_args *, register_t *);
+
+int sys_readlink(struct lwp *, const struct sys_readlink_args *, register_t *);
+
+int sys_execve(struct lwp *, const struct sys_execve_args *, register_t *);
+
+int sys_umask(struct lwp *, const struct sys_umask_args *, register_t *);
+
+int sys_chroot(struct lwp *, const struct sys_chroot_args *, register_t *);
+
+int compat_43_sys_fstat(struct lwp *, const struct compat_43_sys_fstat_args *, register_t *);
+
+int compat_43_sys_getkerninfo(struct lwp *, const struct compat_43_sys_getkerninfo_args *, register_t *);
+
+int compat_43_sys_getpagesize(struct lwp *, const void *, register_t *);
+
+int compat_12_sys_msync(struct lwp *, const struct compat_12_sys_msync_args *, register_t *);
+
+int sys_vfork(struct lwp *, const void *, register_t *);
+
+int sys_sbrk(struct lwp *, const struct sys_sbrk_args *, register_t *);
+
+int sys_sstk(struct lwp *, const struct sys_sstk_args *, register_t *);
+
+int compat_43_sys_mmap(struct lwp *, const struct compat_43_sys_mmap_args *, register_t *);
+
+int sys_ovadvise(struct lwp *, const struct sys_ovadvise_args *, register_t *);
+
+int sys_munmap(struct lwp *, const struct sys_munmap_args *, register_t *);
+
+int sys_mprotect(struct lwp *, const struct sys_mprotect_args *, register_t *);
+
+int sys_madvise(struct lwp *, const struct sys_madvise_args *, register_t *);
+
+int sys_mincore(struct lwp *, const struct sys_mincore_args *, register_t *);
+
+int sys_getgroups(struct lwp *, const struct sys_getgroups_args *, register_t *);
+
+int sys_setgroups(struct lwp *, const struct sys_setgroups_args *, register_t *);
+
+int sys_getpgrp(struct lwp *, const void *, register_t *);
+
+int sys_setpgid(struct lwp *, const struct sys_setpgid_args *, register_t *);
+
+int compat_50_sys_setitimer(struct lwp *, const struct compat_50_sys_setitimer_args *, register_t *);
+
+int compat_43_sys_wait(struct lwp *, const void *, register_t *);
+
+int compat_12_sys_swapon(struct lwp *, const struct compat_12_sys_swapon_args *, register_t *);
+
+int compat_50_sys_getitimer(struct lwp *, const struct compat_50_sys_getitimer_args *, register_t *);
+
+int compat_43_sys_gethostname(struct lwp *, const struct compat_43_sys_gethostname_args *, register_t *);
+
+int compat_43_sys_sethostname(struct lwp *, const struct compat_43_sys_sethostname_args *, register_t *);
+
+int compat_43_sys_getdtablesize(struct lwp *, const void *, register_t *);
+
+int sys_dup2(struct lwp *, const struct sys_dup2_args *, register_t *);
+
+int sys_fcntl(struct lwp *, const struct sys_fcntl_args *, register_t *);
+
+int compat_50_sys_select(struct lwp *, const struct compat_50_sys_select_args *, register_t *);
+
+int sys_fsync(struct lwp *, const struct sys_fsync_args *, register_t *);
+
+int sys_setpriority(struct lwp *, const struct sys_setpriority_args *, register_t *);
+
+int compat_30_sys_socket(struct lwp *, const struct compat_30_sys_socket_args *, register_t *);
+
+int sys_connect(struct lwp *, const struct sys_connect_args *, register_t *);
+
+int compat_43_sys_accept(struct lwp *, const struct compat_43_sys_accept_args *, register_t *);
+
+int sys_getpriority(struct lwp *, const struct sys_getpriority_args *, register_t *);
+
+int compat_43_sys_send(struct lwp *, const struct compat_43_sys_send_args *, register_t *);
+
+int compat_43_sys_recv(struct lwp *, const struct compat_43_sys_recv_args *, register_t *);
+
+int compat_13_sys_sigreturn(struct lwp *, const struct compat_13_sys_sigreturn_args *, register_t *);
+
+int sys_bind(struct lwp *, const struct sys_bind_args *, register_t *);
+
+int sys_setsockopt(struct lwp *, const struct sys_setsockopt_args *, register_t *);
+
+int sys_listen(struct lwp *, const struct sys_listen_args *, register_t *);
+
+int compat_43_sys_sigvec(struct lwp *, const struct compat_43_sys_sigvec_args *, register_t *);
+
+int compat_43_sys_sigblock(struct lwp *, const struct compat_43_sys_sigblock_args *, register_t *);
+
+int compat_43_sys_sigsetmask(struct lwp *, const struct compat_43_sys_sigsetmask_args *, register_t *);
+
+int compat_13_sys_sigsuspend(struct lwp *, const struct compat_13_sys_sigsuspend_args *, register_t *);
+
+int compat_43_sys_sigstack(struct lwp *, const struct compat_43_sys_sigstack_args *, register_t *);
+
+int compat_43_sys_recvmsg(struct lwp *, const struct compat_43_sys_recvmsg_args *, register_t *);
+
+int compat_43_sys_sendmsg(struct lwp *, const struct compat_43_sys_sendmsg_args *, register_t *);
+
+int compat_50_sys_gettimeofday(struct lwp *, const struct compat_50_sys_gettimeofday_args *, register_t *);
+
+int compat_50_sys_getrusage(struct lwp *, const struct compat_50_sys_getrusage_args *, register_t *);
+
+int sys_getsockopt(struct lwp *, const struct sys_getsockopt_args *, register_t *);
+
+int sys_readv(struct lwp *, const struct sys_readv_args *, register_t *);
+
+int sys_writev(struct lwp *, const struct sys_writev_args *, register_t *);
+
+int compat_50_sys_settimeofday(struct lwp *, const struct compat_50_sys_settimeofday_args *, register_t *);
+
+int sys_fchown(struct lwp *, const struct sys_fchown_args *, register_t *);
+
+int sys_fchmod(struct lwp *, const struct sys_fchmod_args *, register_t *);
+
+int compat_43_sys_recvfrom(struct lwp *, const struct compat_43_sys_recvfrom_args *, register_t *);
+
+int sys_setreuid(struct lwp *, const struct sys_setreuid_args *, register_t *);
+
+int sys_setregid(struct lwp *, const struct sys_setregid_args *, register_t *);
+
+int sys_rename(struct lwp *, const struct sys_rename_args *, register_t *);
+
+int compat_43_sys_truncate(struct lwp *, const struct compat_43_sys_truncate_args *, register_t *);
+
+int compat_43_sys_ftruncate(struct lwp *, const struct compat_43_sys_ftruncate_args *, register_t *);
+
+int sys_flock(struct lwp *, const struct sys_flock_args *, register_t *);
+
+int sys_mkfifo(struct lwp *, const struct sys_mkfifo_args *, register_t *);
+
+int sys_sendto(struct lwp *, const struct sys_sendto_args *, register_t *);
+
+int sys_shutdown(struct lwp *, const struct sys_shutdown_args *, register_t *);
+
+int sys_socketpair(struct lwp *, const struct sys_socketpair_args *, register_t *);
+
+int sys_mkdir(struct lwp *, const struct sys_mkdir_args *, register_t *);
+
+int sys_rmdir(struct lwp *, const struct sys_rmdir_args *, register_t *);
+
+int compat_50_sys_utimes(struct lwp *, const struct compat_50_sys_utimes_args *, register_t *);
+
+int compat_50_sys_adjtime(struct lwp *, const struct compat_50_sys_adjtime_args *, register_t *);
+
+int compat_43_sys_getpeername(struct lwp *, const struct compat_43_sys_getpeername_args *, register_t *);
+
+int compat_43_sys_gethostid(struct lwp *, const void *, register_t *);
+
+int compat_43_sys_sethostid(struct lwp *, const struct compat_43_sys_sethostid_args *, register_t *);
+
+int compat_43_sys_getrlimit(struct lwp *, const struct compat_43_sys_getrlimit_args *, register_t *);
+
+int compat_43_sys_setrlimit(struct lwp *, const struct compat_43_sys_setrlimit_args *, register_t *);
+
+int compat_43_sys_killpg(struct lwp *, const struct compat_43_sys_killpg_args *, register_t *);
+
+int sys_setsid(struct lwp *, const void *, register_t *);
+
+int compat_50_sys_quotactl(struct lwp *, const struct compat_50_sys_quotactl_args *, register_t *);
+
+int compat_43_sys_quota(struct lwp *, const void *, register_t *);
+
+int compat_43_sys_getsockname(struct lwp *, const struct compat_43_sys_getsockname_args *, register_t *);
+
+int sys_nfssvc(struct lwp *, const struct sys_nfssvc_args *, register_t *);
+
+int compat_43_sys_getdirentries(struct lwp *, const struct compat_43_sys_getdirentries_args *, register_t *);
+
+int compat_20_sys_statfs(struct lwp *, const struct compat_20_sys_statfs_args *, register_t *);
+
+int compat_20_sys_fstatfs(struct lwp *, const struct compat_20_sys_fstatfs_args *, register_t *);
+
+int compat_30_sys_getfh(struct lwp *, const struct compat_30_sys_getfh_args *, register_t *);
+
+int compat_09_sys_getdomainname(struct lwp *, const struct compat_09_sys_getdomainname_args *, register_t *);
+
+int compat_09_sys_setdomainname(struct lwp *, const struct compat_09_sys_setdomainname_args *, register_t *);
+
+int compat_09_sys_uname(struct lwp *, const struct compat_09_sys_uname_args *, register_t *);
+
+int sys_sysarch(struct lwp *, const struct sys_sysarch_args *, register_t *);
+
+#if (defined(SYSVSEM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+int compat_10_sys_semsys(struct lwp *, const struct compat_10_sys_semsys_args *, register_t *);
+
+#else
+#endif
+#if (defined(SYSVMSG) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+int compat_10_sys_msgsys(struct lwp *, const struct compat_10_sys_msgsys_args *, register_t *);
+
+#else
+#endif
+#if (defined(SYSVSHM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
+int compat_10_sys_shmsys(struct lwp *, const struct compat_10_sys_shmsys_args *, register_t *);
+
+#else
+#endif
+int sys_pread(struct lwp *, const struct sys_pread_args *, register_t *);
+
+int sys_pwrite(struct lwp *, const struct sys_pwrite_args *, register_t *);
+
+int compat_30_sys_ntp_gettime(struct lwp *, const struct compat_30_sys_ntp_gettime_args *, register_t *);
+
+#if defined(NTP) || !defined(_KERNEL_OPT)
+int sys_ntp_adjtime(struct lwp *, const struct sys_ntp_adjtime_args *, register_t *);
+
+#else
+#endif
+int sys_setgid(struct lwp *, const struct sys_setgid_args *, register_t *);
+
+int sys_setegid(struct lwp *, const struct sys_setegid_args *, register_t *);
+
+int sys_seteuid(struct lwp *, const struct sys_seteuid_args *, register_t *);
+
+int sys_lfs_bmapv(struct lwp *, const struct sys_lfs_bmapv_args *, register_t *);
+
+int sys_lfs_markv(struct lwp *, const struct sys_lfs_markv_args *, register_t *);
+
+int sys_lfs_segclean(struct lwp *, const struct sys_lfs_segclean_args *, register_t *);
+
+int compat_50_sys_lfs_segwait(struct lwp *, const struct compat_50_sys_lfs_segwait_args *, register_t *);
+
+int compat_12_sys_stat(struct lwp *, const struct compat_12_sys_stat_args *, register_t *);
+
+int compat_12_sys_fstat(struct lwp *, const struct compat_12_sys_fstat_args *, register_t *);
+
+int compat_12_sys_lstat(struct lwp *, const struct compat_12_sys_lstat_args *, register_t *);
+
+int sys_pathconf(struct lwp *, const struct sys_pathconf_args *, register_t *);
+
+int sys_fpathconf(struct lwp *, const struct sys_fpathconf_args *, register_t *);
+
+int sys_getrlimit(struct lwp *, const struct sys_getrlimit_args *, register_t *);
+
+int sys_setrlimit(struct lwp *, const struct sys_setrlimit_args *, register_t *);
+
+int compat_12_sys_getdirentries(struct lwp *, const struct compat_12_sys_getdirentries_args *, register_t *);
+
+int sys_mmap(struct lwp *, const struct sys_mmap_args *, register_t *);
+
+int sys___syscall(struct lwp *, const struct sys___syscall_args *, register_t *);
+
+int sys_lseek(struct lwp *, const struct sys_lseek_args *, register_t *);
+
+int sys_truncate(struct lwp *, const struct sys_truncate_args *, register_t *);
+
+int sys_ftruncate(struct lwp *, const struct sys_ftruncate_args *, register_t *);
+
+int sys___sysctl(struct lwp *, const struct sys___sysctl_args *, register_t *);
+
+int sys_mlock(struct lwp *, const struct sys_mlock_args *, register_t *);
+
+int sys_munlock(struct lwp *, const struct sys_munlock_args *, register_t *);
+
+int sys_undelete(struct lwp *, const struct sys_undelete_args *, register_t *);
+
+int compat_50_sys_futimes(struct lwp *, const struct compat_50_sys_futimes_args *, register_t *);
+
+int sys_getpgid(struct lwp *, const struct sys_getpgid_args *, register_t *);
+
+int sys_reboot(struct lwp *, const struct sys_reboot_args *, register_t *);
+
+int sys_poll(struct lwp *, const struct sys_poll_args *, register_t *);
+
+int sys_afssys(struct lwp *, const struct sys_afssys_args *, register_t *);
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+int compat_14_sys___semctl(struct lwp *, const struct compat_14_sys___semctl_args *, register_t *);
+
+int sys_semget(struct lwp *, const struct sys_semget_args *, register_t *);
+
+int sys_semop(struct lwp *, const struct sys_semop_args *, register_t *);
+
+int sys_semconfig(struct lwp *, const struct sys_semconfig_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+int compat_14_sys_msgctl(struct lwp *, const struct compat_14_sys_msgctl_args *, register_t *);
+
+int sys_msgget(struct lwp *, const struct sys_msgget_args *, register_t *);
+
+int sys_msgsnd(struct lwp *, const struct sys_msgsnd_args *, register_t *);
+
+int sys_msgrcv(struct lwp *, const struct sys_msgrcv_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+int sys_shmat(struct lwp *, const struct sys_shmat_args *, register_t *);
+
+int compat_14_sys_shmctl(struct lwp *, const struct compat_14_sys_shmctl_args *, register_t *);
+
+int sys_shmdt(struct lwp *, const struct sys_shmdt_args *, register_t *);
+
+int sys_shmget(struct lwp *, const struct sys_shmget_args *, register_t *);
+
+#else
+#endif
+int compat_50_sys_clock_gettime(struct lwp *, const struct compat_50_sys_clock_gettime_args *, register_t *);
+
+int compat_50_sys_clock_settime(struct lwp *, const struct compat_50_sys_clock_settime_args *, register_t *);
+
+int compat_50_sys_clock_getres(struct lwp *, const struct compat_50_sys_clock_getres_args *, register_t *);
+
+int sys_timer_create(struct lwp *, const struct sys_timer_create_args *, register_t *);
+
+int sys_timer_delete(struct lwp *, const struct sys_timer_delete_args *, register_t *);
+
+int compat_50_sys_timer_settime(struct lwp *, const struct compat_50_sys_timer_settime_args *, register_t *);
+
+int compat_50_sys_timer_gettime(struct lwp *, const struct compat_50_sys_timer_gettime_args *, register_t *);
+
+int sys_timer_getoverrun(struct lwp *, const struct sys_timer_getoverrun_args *, register_t *);
+
+int compat_50_sys_nanosleep(struct lwp *, const struct compat_50_sys_nanosleep_args *, register_t *);
+
+int sys_fdatasync(struct lwp *, const struct sys_fdatasync_args *, register_t *);
+
+int sys_mlockall(struct lwp *, const struct sys_mlockall_args *, register_t *);
+
+int sys_munlockall(struct lwp *, const void *, register_t *);
+
+int compat_50_sys___sigtimedwait(struct lwp *, const struct compat_50_sys___sigtimedwait_args *, register_t *);
+
+int sys_sigqueueinfo(struct lwp *, const struct sys_sigqueueinfo_args *, register_t *);
+
+int sys_modctl(struct lwp *, const struct sys_modctl_args *, register_t *);
+
+int sys__ksem_init(struct lwp *, const struct sys__ksem_init_args *, register_t *);
+
+int sys__ksem_open(struct lwp *, const struct sys__ksem_open_args *, register_t *);
+
+int sys__ksem_unlink(struct lwp *, const struct sys__ksem_unlink_args *, register_t *);
+
+int sys__ksem_close(struct lwp *, const struct sys__ksem_close_args *, register_t *);
+
+int sys__ksem_post(struct lwp *, const struct sys__ksem_post_args *, register_t *);
+
+int sys__ksem_wait(struct lwp *, const struct sys__ksem_wait_args *, register_t *);
+
+int sys__ksem_trywait(struct lwp *, const struct sys__ksem_trywait_args *, register_t *);
+
+int sys__ksem_getvalue(struct lwp *, const struct sys__ksem_getvalue_args *, register_t *);
+
+int sys__ksem_destroy(struct lwp *, const struct sys__ksem_destroy_args *, register_t *);
+
+int sys__ksem_timedwait(struct lwp *, const struct sys__ksem_timedwait_args *, register_t *);
+
+int sys_mq_open(struct lwp *, const struct sys_mq_open_args *, register_t *);
+
+int sys_mq_close(struct lwp *, const struct sys_mq_close_args *, register_t *);
+
+int sys_mq_unlink(struct lwp *, const struct sys_mq_unlink_args *, register_t *);
+
+int sys_mq_getattr(struct lwp *, const struct sys_mq_getattr_args *, register_t *);
+
+int sys_mq_setattr(struct lwp *, const struct sys_mq_setattr_args *, register_t *);
+
+int sys_mq_notify(struct lwp *, const struct sys_mq_notify_args *, register_t *);
+
+int sys_mq_send(struct lwp *, const struct sys_mq_send_args *, register_t *);
+
+int sys_mq_receive(struct lwp *, const struct sys_mq_receive_args *, register_t *);
+
+int compat_50_sys_mq_timedsend(struct lwp *, const struct compat_50_sys_mq_timedsend_args *, register_t *);
+
+int compat_50_sys_mq_timedreceive(struct lwp *, const struct compat_50_sys_mq_timedreceive_args *, register_t *);
+
+int sys___posix_rename(struct lwp *, const struct sys___posix_rename_args *, register_t *);
+
+int sys_swapctl(struct lwp *, const struct sys_swapctl_args *, register_t *);
+
+int compat_30_sys_getdents(struct lwp *, const struct compat_30_sys_getdents_args *, register_t *);
+
+int sys_minherit(struct lwp *, const struct sys_minherit_args *, register_t *);
+
+int sys_lchmod(struct lwp *, const struct sys_lchmod_args *, register_t *);
+
+int sys_lchown(struct lwp *, const struct sys_lchown_args *, register_t *);
+
+int compat_50_sys_lutimes(struct lwp *, const struct compat_50_sys_lutimes_args *, register_t *);
+
+int sys___msync13(struct lwp *, const struct sys___msync13_args *, register_t *);
+
+int compat_30_sys___stat13(struct lwp *, const struct compat_30_sys___stat13_args *, register_t *);
+
+int compat_30_sys___fstat13(struct lwp *, const struct compat_30_sys___fstat13_args *, register_t *);
+
+int compat_30_sys___lstat13(struct lwp *, const struct compat_30_sys___lstat13_args *, register_t *);
+
+int sys___sigaltstack14(struct lwp *, const struct sys___sigaltstack14_args *, register_t *);
+
+int sys___vfork14(struct lwp *, const void *, register_t *);
+
+int sys___posix_chown(struct lwp *, const struct sys___posix_chown_args *, register_t *);
+
+int sys___posix_fchown(struct lwp *, const struct sys___posix_fchown_args *, register_t *);
+
+int sys___posix_lchown(struct lwp *, const struct sys___posix_lchown_args *, register_t *);
+
+int sys_getsid(struct lwp *, const struct sys_getsid_args *, register_t *);
+
+int sys___clone(struct lwp *, const struct sys___clone_args *, register_t *);
+
+int sys_fktrace(struct lwp *, const struct sys_fktrace_args *, register_t *);
+
+int sys_preadv(struct lwp *, const struct sys_preadv_args *, register_t *);
+
+int sys_pwritev(struct lwp *, const struct sys_pwritev_args *, register_t *);
+
+int compat_16_sys___sigaction14(struct lwp *, const struct compat_16_sys___sigaction14_args *, register_t *);
+
+int sys___sigpending14(struct lwp *, const struct sys___sigpending14_args *, register_t *);
+
+int sys___sigprocmask14(struct lwp *, const struct sys___sigprocmask14_args *, register_t *);
+
+int sys___sigsuspend14(struct lwp *, const struct sys___sigsuspend14_args *, register_t *);
+
+int compat_16_sys___sigreturn14(struct lwp *, const struct compat_16_sys___sigreturn14_args *, register_t *);
+
+int sys___getcwd(struct lwp *, const struct sys___getcwd_args *, register_t *);
+
+int sys_fchroot(struct lwp *, const struct sys_fchroot_args *, register_t *);
+
+int compat_30_sys_fhopen(struct lwp *, const struct compat_30_sys_fhopen_args *, register_t *);
+
+int compat_30_sys_fhstat(struct lwp *, const struct compat_30_sys_fhstat_args *, register_t *);
+
+int compat_20_sys_fhstatfs(struct lwp *, const struct compat_20_sys_fhstatfs_args *, register_t *);
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+int compat_50_sys_____semctl13(struct lwp *, const struct compat_50_sys_____semctl13_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+int compat_50_sys___msgctl13(struct lwp *, const struct compat_50_sys___msgctl13_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+int compat_50_sys___shmctl13(struct lwp *, const struct compat_50_sys___shmctl13_args *, register_t *);
+
+#else
+#endif
+int sys_lchflags(struct lwp *, const struct sys_lchflags_args *, register_t *);
+
+int sys_issetugid(struct lwp *, const void *, register_t *);
+
+int sys_utrace(struct lwp *, const struct sys_utrace_args *, register_t *);
+
+int sys_getcontext(struct lwp *, const struct sys_getcontext_args *, register_t *);
+
+int sys_setcontext(struct lwp *, const struct sys_setcontext_args *, register_t *);
+
+int sys__lwp_create(struct lwp *, const struct sys__lwp_create_args *, register_t *);
+
+int sys__lwp_exit(struct lwp *, const void *, register_t *);
+
+int sys__lwp_self(struct lwp *, const void *, register_t *);
+
+int sys__lwp_wait(struct lwp *, const struct sys__lwp_wait_args *, register_t *);
+
+int sys__lwp_suspend(struct lwp *, const struct sys__lwp_suspend_args *, register_t *);
+
+int sys__lwp_continue(struct lwp *, const struct sys__lwp_continue_args *, register_t *);
+
+int sys__lwp_wakeup(struct lwp *, const struct sys__lwp_wakeup_args *, register_t *);
+
+int sys__lwp_getprivate(struct lwp *, const void *, register_t *);
+
+int sys__lwp_setprivate(struct lwp *, const struct sys__lwp_setprivate_args *, register_t *);
+
+int sys__lwp_kill(struct lwp *, const struct sys__lwp_kill_args *, register_t *);
+
+int sys__lwp_detach(struct lwp *, const struct sys__lwp_detach_args *, register_t *);
+
+int compat_50_sys__lwp_park(struct lwp *, const struct compat_50_sys__lwp_park_args *, register_t *);
+
+int sys__lwp_unpark(struct lwp *, const struct sys__lwp_unpark_args *, register_t *);
+
+int sys__lwp_unpark_all(struct lwp *, const struct sys__lwp_unpark_all_args *, register_t *);
+
+int sys__lwp_setname(struct lwp *, const struct sys__lwp_setname_args *, register_t *);
+
+int sys__lwp_getname(struct lwp *, const struct sys__lwp_getname_args *, register_t *);
+
+int sys__lwp_ctl(struct lwp *, const struct sys__lwp_ctl_args *, register_t *);
+
+int compat_60_sys_sa_register(struct lwp *, const struct compat_60_sys_sa_register_args *, register_t *);
+
+int compat_60_sys_sa_stacks(struct lwp *, const struct compat_60_sys_sa_stacks_args *, register_t *);
+
+int compat_60_sys_sa_enable(struct lwp *, const void *, register_t *);
+
+int compat_60_sys_sa_setconcurrency(struct lwp *, const struct compat_60_sys_sa_setconcurrency_args *, register_t *);
+
+int compat_60_sys_sa_yield(struct lwp *, const void *, register_t *);
+
+int compat_60_sys_sa_preempt(struct lwp *, const struct compat_60_sys_sa_preempt_args *, register_t *);
+
+int sys___sigaction_sigtramp(struct lwp *, const struct sys___sigaction_sigtramp_args *, register_t *);
+
+int sys_pmc_get_info(struct lwp *, const struct sys_pmc_get_info_args *, register_t *);
+
+int sys_pmc_control(struct lwp *, const struct sys_pmc_control_args *, register_t *);
+
+int sys_rasctl(struct lwp *, const struct sys_rasctl_args *, register_t *);
+
+int sys_kqueue(struct lwp *, const void *, register_t *);
+
+int compat_50_sys_kevent(struct lwp *, const struct compat_50_sys_kevent_args *, register_t *);
+
+int sys__sched_setparam(struct lwp *, const struct sys__sched_setparam_args *, register_t *);
+
+int sys__sched_getparam(struct lwp *, const struct sys__sched_getparam_args *, register_t *);
+
+int sys__sched_setaffinity(struct lwp *, const struct sys__sched_setaffinity_args *, register_t *);
+
+int sys__sched_getaffinity(struct lwp *, const struct sys__sched_getaffinity_args *, register_t *);
+
+int sys_sched_yield(struct lwp *, const void *, register_t *);
+
+int sys_fsync_range(struct lwp *, const struct sys_fsync_range_args *, register_t *);
+
+int sys_uuidgen(struct lwp *, const struct sys_uuidgen_args *, register_t *);
+
+int sys_getvfsstat(struct lwp *, const struct sys_getvfsstat_args *, register_t *);
+
+int sys_statvfs1(struct lwp *, const struct sys_statvfs1_args *, register_t *);
+
+int sys_fstatvfs1(struct lwp *, const struct sys_fstatvfs1_args *, register_t *);
+
+int compat_30_sys_fhstatvfs1(struct lwp *, const struct compat_30_sys_fhstatvfs1_args *, register_t *);
+
+int sys_extattrctl(struct lwp *, const struct sys_extattrctl_args *, register_t *);
+
+int sys_extattr_set_file(struct lwp *, const struct sys_extattr_set_file_args *, register_t *);
+
+int sys_extattr_get_file(struct lwp *, const struct sys_extattr_get_file_args *, register_t *);
+
+int sys_extattr_delete_file(struct lwp *, const struct sys_extattr_delete_file_args *, register_t *);
+
+int sys_extattr_set_fd(struct lwp *, const struct sys_extattr_set_fd_args *, register_t *);
+
+int sys_extattr_get_fd(struct lwp *, const struct sys_extattr_get_fd_args *, register_t *);
+
+int sys_extattr_delete_fd(struct lwp *, const struct sys_extattr_delete_fd_args *, register_t *);
+
+int sys_extattr_set_link(struct lwp *, const struct sys_extattr_set_link_args *, register_t *);
+
+int sys_extattr_get_link(struct lwp *, const struct sys_extattr_get_link_args *, register_t *);
+
+int sys_extattr_delete_link(struct lwp *, const struct sys_extattr_delete_link_args *, register_t *);
+
+int sys_extattr_list_fd(struct lwp *, const struct sys_extattr_list_fd_args *, register_t *);
+
+int sys_extattr_list_file(struct lwp *, const struct sys_extattr_list_file_args *, register_t *);
+
+int sys_extattr_list_link(struct lwp *, const struct sys_extattr_list_link_args *, register_t *);
+
+int compat_50_sys_pselect(struct lwp *, const struct compat_50_sys_pselect_args *, register_t *);
+
+int compat_50_sys_pollts(struct lwp *, const struct compat_50_sys_pollts_args *, register_t *);
+
+int sys_setxattr(struct lwp *, const struct sys_setxattr_args *, register_t *);
+
+int sys_lsetxattr(struct lwp *, const struct sys_lsetxattr_args *, register_t *);
+
+int sys_fsetxattr(struct lwp *, const struct sys_fsetxattr_args *, register_t *);
+
+int sys_getxattr(struct lwp *, const struct sys_getxattr_args *, register_t *);
+
+int sys_lgetxattr(struct lwp *, const struct sys_lgetxattr_args *, register_t *);
+
+int sys_fgetxattr(struct lwp *, const struct sys_fgetxattr_args *, register_t *);
+
+int sys_listxattr(struct lwp *, const struct sys_listxattr_args *, register_t *);
+
+int sys_llistxattr(struct lwp *, const struct sys_llistxattr_args *, register_t *);
+
+int sys_flistxattr(struct lwp *, const struct sys_flistxattr_args *, register_t *);
+
+int sys_removexattr(struct lwp *, const struct sys_removexattr_args *, register_t *);
+
+int sys_lremovexattr(struct lwp *, const struct sys_lremovexattr_args *, register_t *);
+
+int sys_fremovexattr(struct lwp *, const struct sys_fremovexattr_args *, register_t *);
+
+int compat_50_sys___stat30(struct lwp *, const struct compat_50_sys___stat30_args *, register_t *);
+
+int compat_50_sys___fstat30(struct lwp *, const struct compat_50_sys___fstat30_args *, register_t *);
+
+int compat_50_sys___lstat30(struct lwp *, const struct compat_50_sys___lstat30_args *, register_t *);
+
+int sys___getdents30(struct lwp *, const struct sys___getdents30_args *, register_t *);
+
+int compat_30_sys___fhstat30(struct lwp *, const struct compat_30_sys___fhstat30_args *, register_t *);
+
+int compat_50_sys___ntp_gettime30(struct lwp *, const struct compat_50_sys___ntp_gettime30_args *, register_t *);
+
+int sys___socket30(struct lwp *, const struct sys___socket30_args *, register_t *);
+
+int sys___getfh30(struct lwp *, const struct sys___getfh30_args *, register_t *);
+
+int sys___fhopen40(struct lwp *, const struct sys___fhopen40_args *, register_t *);
+
+int sys___fhstatvfs140(struct lwp *, const struct sys___fhstatvfs140_args *, register_t *);
+
+int compat_50_sys___fhstat40(struct lwp *, const struct compat_50_sys___fhstat40_args *, register_t *);
+
+int sys_aio_cancel(struct lwp *, const struct sys_aio_cancel_args *, register_t *);
+
+int sys_aio_error(struct lwp *, const struct sys_aio_error_args *, register_t *);
+
+int sys_aio_fsync(struct lwp *, const struct sys_aio_fsync_args *, register_t *);
+
+int sys_aio_read(struct lwp *, const struct sys_aio_read_args *, register_t *);
+
+int sys_aio_return(struct lwp *, const struct sys_aio_return_args *, register_t *);
+
+int compat_50_sys_aio_suspend(struct lwp *, const struct compat_50_sys_aio_suspend_args *, register_t *);
+
+int sys_aio_write(struct lwp *, const struct sys_aio_write_args *, register_t *);
+
+int sys_lio_listio(struct lwp *, const struct sys_lio_listio_args *, register_t *);
+
+int sys___mount50(struct lwp *, const struct sys___mount50_args *, register_t *);
+
+int sys_mremap(struct lwp *, const struct sys_mremap_args *, register_t *);
+
+int sys_pset_create(struct lwp *, const struct sys_pset_create_args *, register_t *);
+
+int sys_pset_destroy(struct lwp *, const struct sys_pset_destroy_args *, register_t *);
+
+int sys_pset_assign(struct lwp *, const struct sys_pset_assign_args *, register_t *);
+
+int sys__pset_bind(struct lwp *, const struct sys__pset_bind_args *, register_t *);
+
+int sys___posix_fadvise50(struct lwp *, const struct sys___posix_fadvise50_args *, register_t *);
+
+int sys___select50(struct lwp *, const struct sys___select50_args *, register_t *);
+
+int sys___gettimeofday50(struct lwp *, const struct sys___gettimeofday50_args *, register_t *);
+
+int sys___settimeofday50(struct lwp *, const struct sys___settimeofday50_args *, register_t *);
+
+int sys___utimes50(struct lwp *, const struct sys___utimes50_args *, register_t *);
+
+int sys___adjtime50(struct lwp *, const struct sys___adjtime50_args *, register_t *);
+
+int sys___lfs_segwait50(struct lwp *, const struct sys___lfs_segwait50_args *, register_t *);
+
+int sys___futimes50(struct lwp *, const struct sys___futimes50_args *, register_t *);
+
+int sys___lutimes50(struct lwp *, const struct sys___lutimes50_args *, register_t *);
+
+int sys___setitimer50(struct lwp *, const struct sys___setitimer50_args *, register_t *);
+
+int sys___getitimer50(struct lwp *, const struct sys___getitimer50_args *, register_t *);
+
+int sys___clock_gettime50(struct lwp *, const struct sys___clock_gettime50_args *, register_t *);
+
+int sys___clock_settime50(struct lwp *, const struct sys___clock_settime50_args *, register_t *);
+
+int sys___clock_getres50(struct lwp *, const struct sys___clock_getres50_args *, register_t *);
+
+int sys___nanosleep50(struct lwp *, const struct sys___nanosleep50_args *, register_t *);
+
+int sys_____sigtimedwait50(struct lwp *, const struct sys_____sigtimedwait50_args *, register_t *);
+
+int sys___mq_timedsend50(struct lwp *, const struct sys___mq_timedsend50_args *, register_t *);
+
+int sys___mq_timedreceive50(struct lwp *, const struct sys___mq_timedreceive50_args *, register_t *);
+
+int sys____lwp_park50(struct lwp *, const struct sys____lwp_park50_args *, register_t *);
+
+int sys___kevent50(struct lwp *, const struct sys___kevent50_args *, register_t *);
+
+int sys___pselect50(struct lwp *, const struct sys___pselect50_args *, register_t *);
+
+int sys___pollts50(struct lwp *, const struct sys___pollts50_args *, register_t *);
+
+int sys___aio_suspend50(struct lwp *, const struct sys___aio_suspend50_args *, register_t *);
+
+int sys___stat50(struct lwp *, const struct sys___stat50_args *, register_t *);
+
+int sys___fstat50(struct lwp *, const struct sys___fstat50_args *, register_t *);
+
+int sys___lstat50(struct lwp *, const struct sys___lstat50_args *, register_t *);
+
+#if defined(SYSVSEM) || !defined(_KERNEL_OPT)
+int sys_____semctl50(struct lwp *, const struct sys_____semctl50_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
+int sys___shmctl50(struct lwp *, const struct sys___shmctl50_args *, register_t *);
+
+#else
+#endif
+#if defined(SYSVMSG) || !defined(_KERNEL_OPT)
+int sys___msgctl50(struct lwp *, const struct sys___msgctl50_args *, register_t *);
+
+#else
+#endif
+int sys___getrusage50(struct lwp *, const struct sys___getrusage50_args *, register_t *);
+
+int sys___timer_settime50(struct lwp *, const struct sys___timer_settime50_args *, register_t *);
+
+int sys___timer_gettime50(struct lwp *, const struct sys___timer_gettime50_args *, register_t *);
+
+#if defined(NTP) || !defined(_KERNEL_OPT)
+int sys___ntp_gettime50(struct lwp *, const struct sys___ntp_gettime50_args *, register_t *);
+
+#else
+#endif
+int sys___wait450(struct lwp *, const struct sys___wait450_args *, register_t *);
+
+int sys___mknod50(struct lwp *, const struct sys___mknod50_args *, register_t *);
+
+int sys___fhstat50(struct lwp *, const struct sys___fhstat50_args *, register_t *);
+
+int sys_pipe2(struct lwp *, const struct sys_pipe2_args *, register_t *);
+
+int sys_dup3(struct lwp *, const struct sys_dup3_args *, register_t *);
+
+int sys_kqueue1(struct lwp *, const struct sys_kqueue1_args *, register_t *);
+
+int sys_paccept(struct lwp *, const struct sys_paccept_args *, register_t *);
+
+int sys_linkat(struct lwp *, const struct sys_linkat_args *, register_t *);
+
+int sys_renameat(struct lwp *, const struct sys_renameat_args *, register_t *);
+
+int sys_mkfifoat(struct lwp *, const struct sys_mkfifoat_args *, register_t *);
+
+int sys_mknodat(struct lwp *, const struct sys_mknodat_args *, register_t *);
+
+int sys_mkdirat(struct lwp *, const struct sys_mkdirat_args *, register_t *);
+
+int sys_faccessat(struct lwp *, const struct sys_faccessat_args *, register_t *);
+
+int sys_fchmodat(struct lwp *, const struct sys_fchmodat_args *, register_t *);
+
+int sys_fchownat(struct lwp *, const struct sys_fchownat_args *, register_t *);
+
+int sys_fexecve(struct lwp *, const struct sys_fexecve_args *, register_t *);
+
+int sys_fstatat(struct lwp *, const struct sys_fstatat_args *, register_t *);
+
+int sys_utimensat(struct lwp *, const struct sys_utimensat_args *, register_t *);
+
+int sys_openat(struct lwp *, const struct sys_openat_args *, register_t *);
+
+int sys_readlinkat(struct lwp *, const struct sys_readlinkat_args *, register_t *);
+
+int sys_symlinkat(struct lwp *, const struct sys_symlinkat_args *, register_t *);
+
+int sys_unlinkat(struct lwp *, const struct sys_unlinkat_args *, register_t *);
+
+int sys_futimens(struct lwp *, const struct sys_futimens_args *, register_t *);
+
+int sys___quotactl(struct lwp *, const struct sys___quotactl_args *, register_t *);
+
+int sys_posix_spawn(struct lwp *, const struct sys_posix_spawn_args *, register_t *);
+
+int sys_recvmmsg(struct lwp *, const struct sys_recvmmsg_args *, register_t *);
+
+int sys_sendmmsg(struct lwp *, const struct sys_sendmmsg_args *, register_t *);
+
+int sys_clock_nanosleep(struct lwp *, const struct sys_clock_nanosleep_args *, register_t *);
+
+#endif /* !RUMP_CLIENT */
+#endif /* _SYS_SYSCALLARGS_H_ */
--- /dev/null
+/* $NetBSD: syscallvar.h,v 1.5 2009/06/02 23:21:38 pooka Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SYSCALLVAR_H_
+#define _SYS_SYSCALLVAR_H_
+
+#ifndef _KERNEL
+#error nothing of interest to userspace here
+#endif
+
+#include <sys/systm.h>
+#include <sys/proc.h>
+
+extern struct emul emul_netbsd;
+
+struct syscall_package {
+ u_short sp_code;
+ u_short sp_flags;
+ sy_call_t *sp_call;
+};
+
+void syscall_init(void);
+int syscall_establish(const struct emul *, const struct syscall_package *);
+int syscall_disestablish(const struct emul *, const struct syscall_package *);
+
+static inline int
+sy_call(const struct sysent *sy, struct lwp *l, const void *uap,
+ register_t *rval)
+{
+ int error;
+
+ l->l_sysent = sy;
+ error = (*sy->sy_call)(l, uap, rval);
+ l->l_sysent = NULL;
+
+ return error;
+}
+
+/* inclusion in the kernel currently depends on SYSCALL_DEBUG */
+extern const char * const syscallnames[];
+
+#endif /* _SYS_SYSCALLVAR_H_ */
-#ifndef _SYS_SYSCTL_H
-#define _SYS_SYSCTL_H
+/* $NetBSD: sysctl.h,v 1.203 2012/10/14 20:56:55 christos Exp $ */
/*
- * Used by gmon.
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Karels at Berkeley Software Design, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_SYSCTL_H_
+#define _SYS_SYSCTL_H_
+
+/*
+ * These are for the eproc structure defined below.
+ */
+#include <sys/param.h> /* precautionary upon removal from ucred.h */
+#include <sys/time.h>
+#include <sys/ucred.h>
+#include <sys/ucontext.h>
+#include <sys/proc.h>
+#include <sys/mallocvar.h>
+#include <uvm/uvm_extern.h>
+
+
+/* For offsetof() */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/systm.h>
+#else
+#include <stddef.h>
+#include <stdbool.h>
+#endif
+
+#ifdef _KERNEL
+#include <sys/cprng.h>
+#endif
+
+/*
+ * Definitions for sysctl call. The sysctl call uses a hierarchical name
+ * for objects that can be examined or modified. The name is expressed as
+ * a sequence of integers. Like a file path name, the meaning of each
+ * component depends on its place in the hierarchy. The top-level and kern
+ * identifiers are defined here, and other identifiers are defined in the
+ * respective subsystem header files.
+ */
+
+#define CTL_MAXNAME 12 /* largest number of components supported */
+#define SYSCTL_NAMELEN 32 /* longest name allowed for a node */
+
+#define CREATE_BASE (1024) /* start of dynamic mib allocation */
+#define SYSCTL_DEFSIZE 8 /* initial size of a child set */
+
+/*
+ * Each subsystem defined by sysctl defines a list of variables
+ * for that subsystem. Each name is either a node with further
+ * levels defined below it, or it is a leaf of some particular
+ * type given below. Each sysctl level defines a set of name/type
+ * pairs to be used by sysctl(1) in manipulating the subsystem.
+ */
+struct ctlname {
+ const char *ctl_name; /* subsystem name */
+ int ctl_type; /* type of name */
+};
+#define CTLTYPE_NODE 1 /* name is a node */
+#define CTLTYPE_INT 2 /* name describes an integer */
+#define CTLTYPE_STRING 3 /* name describes a string */
+#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
+#define CTLTYPE_STRUCT 5 /* name describes a structure */
+#define CTLTYPE_BOOL 6 /* name describes a bool */
+
+#ifdef _LP64
+#define CTLTYPE_LONG CTLTYPE_QUAD
+#else
+#define CTLTYPE_LONG CTLTYPE_INT
+#endif
+
+/*
+ * Flags that apply to each node, governing access and other features
+ */
+#define CTLFLAG_READONLY 0x00000000
+/* #define CTLFLAG_UNUSED1 0x00000010 */
+/* #define CTLFLAG_UNUSED2 0x00000020 */
+/* #define CTLFLAG_READ* 0x00000040 */
+#define CTLFLAG_READWRITE 0x00000070
+#define CTLFLAG_ANYWRITE 0x00000080
+#define CTLFLAG_PRIVATE 0x00000100
+#define CTLFLAG_PERMANENT 0x00000200
+#define CTLFLAG_OWNDATA 0x00000400
+#define CTLFLAG_IMMEDIATE 0x00000800
+#define CTLFLAG_HEX 0x00001000
+#define CTLFLAG_ROOT 0x00002000
+#define CTLFLAG_ANYNUMBER 0x00004000
+#define CTLFLAG_HIDDEN 0x00008000
+#define CTLFLAG_ALIAS 0x00010000
+#define CTLFLAG_MMAP 0x00020000
+#define CTLFLAG_OWNDESC 0x00040000
+#define CTLFLAG_UNSIGNED 0x00080000
+
+/*
+ * sysctl API version
+ */
+#define SYSCTL_VERS_MASK 0xff000000
+#define SYSCTL_VERS_0 0x00000000
+#define SYSCTL_VERS_1 0x01000000
+#define SYSCTL_VERSION SYSCTL_VERS_1
+#define SYSCTL_VERS(f) ((f) & SYSCTL_VERS_MASK)
+
+/*
+ * Flags that can be set by a create request from user-space
+ */
+#define SYSCTL_USERFLAGS (CTLFLAG_READWRITE|\
+ CTLFLAG_ANYWRITE|\
+ CTLFLAG_PRIVATE|\
+ CTLFLAG_OWNDATA|\
+ CTLFLAG_IMMEDIATE|\
+ CTLFLAG_HEX|\
+ CTLFLAG_HIDDEN)
+
+/*
+ * Accessor macros
+ */
+#define SYSCTL_TYPEMASK 0x0000000f
+#define SYSCTL_TYPE(x) ((x) & SYSCTL_TYPEMASK)
+#define SYSCTL_FLAGMASK 0x00fffff0
+#define SYSCTL_FLAGS(x) ((x) & SYSCTL_FLAGMASK)
+
+/*
+ * Meta-identifiers
+ */
+#define CTL_EOL -1 /* end of createv/destroyv list */
+#define CTL_QUERY -2 /* enumerates children of a node */
+#define CTL_CREATE -3 /* node create request */
+#define CTL_CREATESYM -4 /* node create request with symbol */
+#define CTL_DESTROY -5 /* node destroy request */
+#define CTL_MMAP -6 /* mmap request */
+#define CTL_DESCRIBE -7 /* get node descriptions */
+
+/*
+ * Top-level identifiers
+ */
+#define CTL_UNSPEC 0 /* unused */
+#define CTL_KERN 1 /* "high kernel": proc, limits */
+#define CTL_VM 2 /* virtual memory */
+#define CTL_VFS 3 /* file system, mount type is next */
+#define CTL_NET 4 /* network, see socket.h */
+#define CTL_DEBUG 5 /* debugging parameters */
+#define CTL_HW 6 /* generic CPU/io */
+#define CTL_MACHDEP 7 /* machine dependent */
+#define CTL_USER 8 /* user-level */
+#define CTL_DDB 9 /* in-kernel debugger */
+#define CTL_PROC 10 /* per-proc attr */
+#define CTL_VENDOR 11 /* vendor-specific data */
+#define CTL_EMUL 12 /* emulation-specific data */
+#define CTL_SECURITY 13 /* security */
+#define CTL_MAXID 14 /* number of valid top-level ids */
+
+/*
+ * The "vendor" toplevel name is to be used by vendors who wish to
+ * have their own private MIB tree. If you do that, please use
+ * vendor.<yourname>.*
+ */
+
+/*
+ * CTL_KERN identifiers
+ */
+#define KERN_OSTYPE 1 /* string: system version */
+#define KERN_OSRELEASE 2 /* string: system release */
+#define KERN_OSREV 3 /* int: system revision */
+#define KERN_VERSION 4 /* string: compile time info */
+#define KERN_MAXVNODES 5 /* int: max vnodes */
+#define KERN_MAXPROC 6 /* int: max processes */
+#define KERN_MAXFILES 7 /* int: max open files */
+#define KERN_ARGMAX 8 /* int: max arguments to exec */
+#define KERN_SECURELVL 9 /* int: system security level */
+#define KERN_HOSTNAME 10 /* string: hostname */
+#define KERN_HOSTID 11 /* int: host identifier */
+#define KERN_CLOCKRATE 12 /* struct: struct clockinfo */
+#define KERN_VNODE 13 /* struct: vnode structures */
+#define KERN_PROC 14 /* struct: process entries */
+#define KERN_FILE 15 /* struct: file entries */
+#define KERN_PROF 16 /* node: kernel profiling info */
+#define KERN_POSIX1 17 /* int: POSIX.1 version */
+#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
+#define KERN_JOB_CONTROL 19 /* int: is job control available */
+#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
+#define KERN_OBOOTTIME 21 /* struct: time kernel was booted */
+#define KERN_DOMAINNAME 22 /* string: (YP) domainname */
+#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
+#define KERN_RAWPARTITION 24 /* int: raw partition number */
+#define KERN_NTPTIME 25 /* struct: extended-precision time */
+#define KERN_TIMEX 26 /* struct: ntp timekeeping state */
+#define KERN_AUTONICETIME 27 /* int: proc time before autonice */
+#define KERN_AUTONICEVAL 28 /* int: auto nice value */
+#define KERN_RTC_OFFSET 29 /* int: offset of rtc from gmt */
+#define KERN_ROOT_DEVICE 30 /* string: root device */
+#define KERN_MSGBUFSIZE 31 /* int: max # of chars in msg buffer */
+#define KERN_FSYNC 32 /* int: file synchronization support */
+#define KERN_OLDSYSVMSG 33 /* old: SysV message queue suppoprt */
+#define KERN_OLDSYSVSEM 34 /* old: SysV semaphore support */
+#define KERN_OLDSYSVSHM 35 /* old: SysV shared memory support */
+#define KERN_OLDSHORTCORENAME 36 /* old, unimplemented */
+#define KERN_SYNCHRONIZED_IO 37 /* int: POSIX synchronized I/O */
+#define KERN_IOV_MAX 38 /* int: max iovec's for readv(2) etc. */
+#define KERN_MBUF 39 /* node: mbuf parameters */
+#define KERN_MAPPED_FILES 40 /* int: POSIX memory mapped files */
+#define KERN_MEMLOCK 41 /* int: POSIX memory locking */
+#define KERN_MEMLOCK_RANGE 42 /* int: POSIX memory range locking */
+#define KERN_MEMORY_PROTECTION 43 /* int: POSIX memory protections */
+#define KERN_LOGIN_NAME_MAX 44 /* int: max length login name + NUL */
+#define KERN_DEFCORENAME 45 /* old: sort core name format */
+#define KERN_LOGSIGEXIT 46 /* int: log signalled processes */
+#define KERN_PROC2 47 /* struct: process entries */
+#define KERN_PROC_ARGS 48 /* struct: process argv/env */
+#define KERN_FSCALE 49 /* int: fixpt FSCALE */
+#define KERN_CCPU 50 /* old: fixpt ccpu */
+#define KERN_CP_TIME 51 /* struct: CPU time counters */
+#define KERN_OLDSYSVIPC_INFO 52 /* old: number of valid kern ids */
+#define KERN_MSGBUF 53 /* kernel message buffer */
+#define KERN_CONSDEV 54 /* dev_t: console terminal device */
+#define KERN_MAXPTYS 55 /* int: maximum number of ptys */
+#define KERN_PIPE 56 /* node: pipe limits */
+#define KERN_MAXPHYS 57 /* int: kernel value of MAXPHYS */
+#define KERN_SBMAX 58 /* int: max socket buffer size */
+#define KERN_TKSTAT 59 /* tty in/out counters */
+#define KERN_MONOTONIC_CLOCK 60 /* int: POSIX monotonic clock */
+#define KERN_URND 61 /* int: random integer from urandom */
+#define KERN_LABELSECTOR 62 /* int: disklabel sector */
+#define KERN_LABELOFFSET 63 /* int: offset of label within sector */
+#define KERN_LWP 64 /* struct: lwp entries */
+#define KERN_FORKFSLEEP 65 /* int: sleep length on failed fork */
+#define KERN_POSIX_THREADS 66 /* int: POSIX Threads option */
+#define KERN_POSIX_SEMAPHORES 67 /* int: POSIX Semaphores option */
+#define KERN_POSIX_BARRIERS 68 /* int: POSIX Barriers option */
+#define KERN_POSIX_TIMERS 69 /* int: POSIX Timers option */
+#define KERN_POSIX_SPIN_LOCKS 70 /* int: POSIX Spin Locks option */
+#define KERN_POSIX_READER_WRITER_LOCKS 71 /* int: POSIX R/W Locks option */
+#define KERN_DUMP_ON_PANIC 72 /* int: dump on panic */
+#define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */
+#define KERN_ROOT_PARTITION 74 /* int: root partition */
+#define KERN_DRIVERS 75 /* struct: driver names and majors #s */
+#define KERN_BUF 76 /* struct: buffers */
+#define KERN_FILE2 77 /* struct: file entries */
+#define KERN_VERIEXEC 78 /* node: verified exec */
+#define KERN_CP_ID 79 /* struct: cpu id numbers */
+#define KERN_HARDCLOCK_TICKS 80 /* int: number of hardclock ticks */
+#define KERN_ARND 81 /* void *buf, size_t siz random */
+#define KERN_SYSVIPC 82 /* node: SysV IPC parameters */
+#define KERN_BOOTTIME 83 /* struct: time kernel was booted */
+#define KERN_EVCNT 84 /* struct: evcnts */
+#define KERN_MAXID 85 /* number of valid kern ids */
+
+
+#define CTL_KERN_NAMES { \
+ { 0, 0 }, \
+ { "ostype", CTLTYPE_STRING }, \
+ { "osrelease", CTLTYPE_STRING }, \
+ { "osrevision", CTLTYPE_INT }, \
+ { "version", CTLTYPE_STRING }, \
+ { "maxvnodes", CTLTYPE_INT }, \
+ { "maxproc", CTLTYPE_INT }, \
+ { "maxfiles", CTLTYPE_INT }, \
+ { "argmax", CTLTYPE_INT }, \
+ { "securelevel", CTLTYPE_INT }, \
+ { "hostname", CTLTYPE_STRING }, \
+ { "hostid", CTLTYPE_INT }, \
+ { "clockrate", CTLTYPE_STRUCT }, \
+ { "vnode", CTLTYPE_STRUCT }, \
+ { "proc", CTLTYPE_STRUCT }, \
+ { "file", CTLTYPE_STRUCT }, \
+ { "profiling", CTLTYPE_NODE }, \
+ { "posix1version", CTLTYPE_INT }, \
+ { "ngroups", CTLTYPE_INT }, \
+ { "job_control", CTLTYPE_INT }, \
+ { "saved_ids", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "domainname", CTLTYPE_STRING }, \
+ { "maxpartitions", CTLTYPE_INT }, \
+ { "rawpartition", CTLTYPE_INT }, \
+ { "ntptime", CTLTYPE_STRUCT }, \
+ { "timex", CTLTYPE_STRUCT }, \
+ { "autonicetime", CTLTYPE_INT }, \
+ { "autoniceval", CTLTYPE_INT }, \
+ { "rtc_offset", CTLTYPE_INT }, \
+ { "root_device", CTLTYPE_STRING }, \
+ { "msgbufsize", CTLTYPE_INT }, \
+ { "fsync", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "synchronized_io", CTLTYPE_INT }, \
+ { "iov_max", CTLTYPE_INT }, \
+ { "mbuf", CTLTYPE_NODE }, \
+ { "mapped_files", CTLTYPE_INT }, \
+ { "memlock", CTLTYPE_INT }, \
+ { "memlock_range", CTLTYPE_INT }, \
+ { "memory_protection", CTLTYPE_INT }, \
+ { "login_name_max", CTLTYPE_INT }, \
+ { "defcorename", CTLTYPE_STRING }, \
+ { "logsigexit", CTLTYPE_INT }, \
+ { "proc2", CTLTYPE_STRUCT }, \
+ { "proc_args", CTLTYPE_STRING }, \
+ { "fscale", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "cp_time", CTLTYPE_STRUCT }, \
+ { 0, 0 }, \
+ { "msgbuf", CTLTYPE_STRUCT }, \
+ { "consdev", CTLTYPE_STRUCT }, \
+ { "maxptys", CTLTYPE_INT }, \
+ { "pipe", CTLTYPE_NODE }, \
+ { "maxphys", CTLTYPE_INT }, \
+ { "sbmax", CTLTYPE_INT }, \
+ { "tkstat", CTLTYPE_NODE }, \
+ { "monotonic_clock", CTLTYPE_INT }, \
+ { "urandom", CTLTYPE_INT }, \
+ { "labelsector", CTLTYPE_INT }, \
+ { "labeloffset", CTLTYPE_INT }, \
+ { "lwp", CTLTYPE_STRUCT }, \
+ { "forkfsleep", CTLTYPE_INT }, \
+ { "posix_threads", CTLTYPE_INT }, \
+ { "posix_semaphores", CTLTYPE_INT }, \
+ { "posix_barriers", CTLTYPE_INT }, \
+ { "posix_timers", CTLTYPE_INT }, \
+ { "posix_spin_locks", CTLTYPE_INT }, \
+ { "posix_reader_writer_locks", CTLTYPE_INT }, \
+ { "dump_on_panic", CTLTYPE_INT}, \
+ { "somaxkva", CTLTYPE_INT}, \
+ { "root_partition", CTLTYPE_INT}, \
+ { "drivers", CTLTYPE_STRUCT }, \
+ { "buf", CTLTYPE_NODE }, \
+ { "file2", CTLTYPE_STRUCT }, \
+ { "veriexec", CTLTYPE_NODE }, \
+ { "cp_id", CTLTYPE_STRUCT }, \
+ { "hardclock_ticks", CTLTYPE_INT }, \
+ { "arandom", CTLTYPE_STRUCT }, \
+ { "sysvipc", CTLTYPE_STRUCT }, \
+ { "boottime", CTLTYPE_STRUCT }, \
+ { "evcnt", CTLTYPE_STRUCT }, \
+}
+
+/*
+ * KERN_CLOCKRATE structure
*/
struct clockinfo {
int hz; /* clock frequency */
int profhz; /* profiling clock frequency */
};
-#endif /* _SYS_SYSCTL_H */
+/*
+ * KERN_PROC subtypes
+ */
+#define KERN_PROC_ALL 0 /* everything */
+#define KERN_PROC_PID 1 /* by process id */
+#define KERN_PROC_PGRP 2 /* by process group id */
+#define KERN_PROC_SESSION 3 /* by session of pid */
+#define KERN_PROC_TTY 4 /* by controlling tty */
+#define KERN_PROC_UID 5 /* by effective uid */
+#define KERN_PROC_RUID 6 /* by real uid */
+#define KERN_PROC_GID 7 /* by effective gid */
+#define KERN_PROC_RGID 8 /* by real gid */
+
+/*
+ * KERN_PROC_TTY sub-subtypes
+ */
+#define KERN_PROC_TTY_NODEV NODEV /* no controlling tty */
+#define KERN_PROC_TTY_REVOKE ((dev_t)-2) /* revoked tty */
+
+struct ki_pcred {
+ void *p_pad;
+ uid_t p_ruid; /* Real user id */
+ uid_t p_svuid; /* Saved effective user id */
+ gid_t p_rgid; /* Real group id */
+ gid_t p_svgid; /* Saved effective group id */
+ int p_refcnt; /* Number of references */
+};
+
+struct ki_ucred {
+ uint32_t cr_ref; /* reference count */
+ uid_t cr_uid; /* effective user id */
+ gid_t cr_gid; /* effective group id */
+ uint32_t cr_ngroups; /* number of groups */
+ gid_t cr_groups[NGROUPS]; /* groups */
+};
+
+/*
+ * KERN_PROC subtype ops return arrays of augmented proc structures:
+ */
+struct kinfo_proc {
+ struct proc kp_proc; /* proc structure */
+ struct eproc {
+ struct proc *e_paddr; /* address of proc */
+ struct session *e_sess; /* session pointer */
+ struct ki_pcred e_pcred; /* process credentials */
+ struct ki_ucred e_ucred; /* current credentials */
+ struct vmspace e_vm; /* address space */
+ pid_t e_ppid; /* parent process id */
+ pid_t e_pgid; /* process group id */
+ short e_jobc; /* job control counter */
+ uint32_t e_tdev; /* XXX: controlling tty dev */
+ pid_t e_tpgid; /* tty process group id */
+ struct session *e_tsess; /* tty session pointer */
+#define WMESGLEN 8
+ char e_wmesg[WMESGLEN]; /* wchan message */
+ segsz_t e_xsize; /* text size */
+ short e_xrssize; /* text rss */
+ short e_xccount; /* text references */
+ short e_xswrss;
+ long e_flag;
+#define EPROC_CTTY 0x01 /* controlling tty vnode active */
+#define EPROC_SLEADER 0x02 /* session leader */
+ char e_login[MAXLOGNAME]; /* setlogin() name */
+ pid_t e_sid; /* session id */
+ long e_spare[3];
+ } kp_eproc;
+};
+
+/*
+ * Convert pointer to 64 bit unsigned integer for struct
+ * kinfo_proc2, etc.
+ */
+#define PTRTOUINT64(p) ((uint64_t)(uintptr_t)(p))
+#define UINT64TOPTR(u) ((void *)(uintptr_t)(u))
+
+/*
+ * KERN_PROC2 subtype ops return arrays of relatively fixed size
+ * structures of process info. Use 8 byte alignment, and new
+ * elements should only be added to the end of this structure so
+ * binary compatibility can be preserved.
+ */
+#define KI_NGROUPS 16
+#define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */
+#define KI_WMESGLEN 8
+#define KI_MAXLOGNAME 24 /* extra for 8 byte alignment */
+#define KI_MAXEMULLEN 16
+#define KI_LNAMELEN 20 /* extra 4 for alignment */
+
+#define KI_NOCPU (~(uint64_t)0)
+
+typedef struct {
+ uint32_t __bits[4];
+} ki_sigset_t;
+
+struct kinfo_proc2 {
+ uint64_t p_forw; /* PTR: linked run/sleep queue. */
+ uint64_t p_back;
+ uint64_t p_paddr; /* PTR: address of proc */
+
+ uint64_t p_addr; /* PTR: Kernel virtual addr of u-area */
+ uint64_t p_fd; /* PTR: Ptr to open files structure. */
+ uint64_t p_cwdi; /* PTR: cdir/rdir/cmask info */
+ uint64_t p_stats; /* PTR: Accounting/statistics */
+ uint64_t p_limit; /* PTR: Process limits. */
+ uint64_t p_vmspace; /* PTR: Address space. */
+ uint64_t p_sigacts; /* PTR: Signal actions, state */
+ uint64_t p_sess; /* PTR: session pointer */
+ uint64_t p_tsess; /* PTR: tty session pointer */
+ uint64_t p_ru; /* PTR: Exit information. XXX */
+
+ int32_t p_eflag; /* LONG: extra kinfo_proc2 flags */
+ int32_t p_exitsig; /* INT: signal to sent to parent on exit */
+ int32_t p_flag; /* INT: P_* flags. */
+
+ int32_t p_pid; /* PID_T: Process identifier. */
+ int32_t p_ppid; /* PID_T: Parent process id */
+ int32_t p_sid; /* PID_T: session id */
+ int32_t p__pgid; /* PID_T: process group id */
+ /* XXX: <sys/proc.h> hijacks p_pgid */
+ int32_t p_tpgid; /* PID_T: tty process group id */
+
+ uint32_t p_uid; /* UID_T: effective user id */
+ uint32_t p_ruid; /* UID_T: real user id */
+ uint32_t p_gid; /* GID_T: effective group id */
+ uint32_t p_rgid; /* GID_T: real group id */
+
+ uint32_t p_groups[KI_NGROUPS]; /* GID_T: groups */
+ int16_t p_ngroups; /* SHORT: number of groups */
+
+ int16_t p_jobc; /* SHORT: job control counter */
+ uint32_t p_tdev; /* XXX: DEV_T: controlling tty dev */
+
+ uint32_t p_estcpu; /* U_INT: Time averaged value of p_cpticks. */
+ uint32_t p_rtime_sec; /* STRUCT TIMEVAL: Real time. */
+ uint32_t p_rtime_usec; /* STRUCT TIMEVAL: Real time. */
+ int32_t p_cpticks; /* INT: Ticks of CPU time. */
+ uint32_t p_pctcpu; /* FIXPT_T: %cpu for this process during p_swtime */
+ uint32_t p_swtime; /* U_INT: Time swapped in or out. */
+ uint32_t p_slptime; /* U_INT: Time since last blocked. */
+ int32_t p_schedflags; /* INT: PSCHED_* flags */
+
+ uint64_t p_uticks; /* U_QUAD_T: Statclock hits in user mode. */
+ uint64_t p_sticks; /* U_QUAD_T: Statclock hits in system mode. */
+ uint64_t p_iticks; /* U_QUAD_T: Statclock hits processing intr. */
+
+ uint64_t p_tracep; /* PTR: Trace to vnode or file */
+ int32_t p_traceflag; /* INT: Kernel trace points. */
+
+ int32_t p_holdcnt; /* INT: If non-zero, don't swap. */
+
+ ki_sigset_t p_siglist; /* SIGSET_T: Signals arrived but not delivered. */
+ ki_sigset_t p_sigmask; /* SIGSET_T: Current signal mask. */
+ ki_sigset_t p_sigignore; /* SIGSET_T: Signals being ignored. */
+ ki_sigset_t p_sigcatch; /* SIGSET_T: Signals being caught by user. */
+
+ int8_t p_stat; /* CHAR: S* process status (from LWP). */
+ uint8_t p_priority; /* U_CHAR: Process priority. */
+ uint8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and p_nice. */
+ uint8_t p_nice; /* U_CHAR: Process "nice" value. */
+
+ uint16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */
+ uint16_t p_acflag; /* U_SHORT: Accounting flags. */
+
+ char p_comm[KI_MAXCOMLEN];
+
+ char p_wmesg[KI_WMESGLEN]; /* wchan message */
+ uint64_t p_wchan; /* PTR: sleep address. */
+
+ char p_login[KI_MAXLOGNAME]; /* setlogin() name */
+
+ int32_t p_vm_rssize; /* SEGSZ_T: current resident set size in pages */
+ int32_t p_vm_tsize; /* SEGSZ_T: text size (pages) */
+ int32_t p_vm_dsize; /* SEGSZ_T: data size (pages) */
+ int32_t p_vm_ssize; /* SEGSZ_T: stack size (pages) */
+
+ int64_t p_uvalid; /* CHAR: following p_u* parameters are valid */
+ /* XXX 64 bits for alignment */
+ uint32_t p_ustart_sec; /* STRUCT TIMEVAL: starting time. */
+ uint32_t p_ustart_usec; /* STRUCT TIMEVAL: starting time. */
+
+ uint32_t p_uutime_sec; /* STRUCT TIMEVAL: user time. */
+ uint32_t p_uutime_usec; /* STRUCT TIMEVAL: user time. */
+ uint32_t p_ustime_sec; /* STRUCT TIMEVAL: system time. */
+ uint32_t p_ustime_usec; /* STRUCT TIMEVAL: system time. */
+
+ uint64_t p_uru_maxrss; /* LONG: max resident set size. */
+ uint64_t p_uru_ixrss; /* LONG: integral shared memory size. */
+ uint64_t p_uru_idrss; /* LONG: integral unshared data ". */
+ uint64_t p_uru_isrss; /* LONG: integral unshared stack ". */
+ uint64_t p_uru_minflt; /* LONG: page reclaims. */
+ uint64_t p_uru_majflt; /* LONG: page faults. */
+ uint64_t p_uru_nswap; /* LONG: swaps. */
+ uint64_t p_uru_inblock; /* LONG: block input operations. */
+ uint64_t p_uru_oublock; /* LONG: block output operations. */
+ uint64_t p_uru_msgsnd; /* LONG: messages sent. */
+ uint64_t p_uru_msgrcv; /* LONG: messages received. */
+ uint64_t p_uru_nsignals; /* LONG: signals received. */
+ uint64_t p_uru_nvcsw; /* LONG: voluntary context switches. */
+ uint64_t p_uru_nivcsw; /* LONG: involuntary ". */
+
+ uint32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */
+ uint32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */
+ uint64_t p_cpuid; /* LONG: CPU id */
+ uint64_t p_realflag; /* INT: P_* flags (not including LWPs). */
+ uint64_t p_nlwps; /* LONG: Number of LWPs */
+ uint64_t p_nrlwps; /* LONG: Number of running LWPs */
+ uint64_t p_realstat; /* LONG: non-LWP process status */
+ uint32_t p_svuid; /* UID_T: saved user id */
+ uint32_t p_svgid; /* GID_T: saved group id */
+ char p_ename[KI_MAXEMULLEN]; /* emulation name */
+ int64_t p_vm_vsize; /* SEGSZ_T: total map size (pages) */
+ int64_t p_vm_msize; /* SEGSZ_T: stack-adjusted map size (pages) */
+};
+
+/*
+ * Compat flags for kinfo_proc, kinfo_proc2. Not guarenteed to be stable.
+ * Some of them used to be shared with LWP flags.
+ * XXXAD Trim to the minimum necessary...
+ */
+
+#define P_ADVLOCK 0x00000001
+#define P_CONTROLT 0x00000002
+#define L_INMEM 0x00000004
+#define P_INMEM /* 0x00000004 */ L_INMEM
+#define P_NOCLDSTOP 0x00000008
+#define P_PPWAIT 0x00000010
+#define P_PROFIL 0x00000020
+#define L_SELECT 0x00000040
+#define P_SELECT /* 0x00000040 */ L_SELECT
+#define L_SINTR 0x00000080
+#define P_SINTR /* 0x00000080 */ L_SINTR
+#define P_SUGID 0x00000100
+#define L_SYSTEM 0x00000200
+#define P_SYSTEM /* 0x00000200 */ L_SYSTEM
+#define L_SA 0x00000400
+#define P_SA /* 0x00000400 */ L_SA
+#define P_TRACED 0x00000800
+#define P_WAITED 0x00001000
+#define P_WEXIT 0x00002000
+#define P_EXEC 0x00004000
+#define P_OWEUPC 0x00008000
+#define P_FSTRACE 0x00010000
+#define P_NOCLDWAIT 0x00020000
+#define P_32 0x00040000
+#define P_CLDSIGIGN 0x00080000
+#define P_SYSTRACE 0x00200000
+#define P_CHTRACED 0x00400000
+#define P_STOPFORK 0x00800000
+#define P_STOPEXEC 0x01000000
+#define P_STOPEXIT 0x02000000
+#define P_SYSCALL 0x04000000
+#define P_PAXMPROTECT 0x08000000
+#define P_PAXNOMPROTECT 0x10000000
+
+/*
+ * LWP compat flags.
+ */
+#define L_DETACHED 0x00800000
+
+/*
+ * KERN_LWP structure. See notes on KERN_PROC2 about adding elements.
+ */
+struct kinfo_lwp {
+ uint64_t l_forw; /* PTR: linked run/sleep queue. */
+ uint64_t l_back;
+ uint64_t l_laddr; /* PTR: Address of LWP */
+ uint64_t l_addr; /* PTR: Kernel virtual addr of u-area */
+ int32_t l_lid; /* LWPID_T: LWP identifier */
+ int32_t l_flag; /* INT: L_* flags. */
+ uint32_t l_swtime; /* U_INT: Time swapped in or out. */
+ uint32_t l_slptime; /* U_INT: Time since last blocked. */
+ int32_t l_schedflags; /* INT: PSCHED_* flags */
+ int32_t l_holdcnt; /* INT: If non-zero, don't swap. */
+ uint8_t l_priority; /* U_CHAR: Process priority. */
+ uint8_t l_usrpri; /* U_CHAR: User-priority based on l_cpu and p_nice. */
+ int8_t l_stat; /* CHAR: S* process status. */
+ int8_t l_pad1; /* fill out to 4-byte boundary */
+ int32_t l_pad2; /* .. and then to an 8-byte boundary */
+ char l_wmesg[KI_WMESGLEN]; /* wchan message */
+ uint64_t l_wchan; /* PTR: sleep address. */
+ uint64_t l_cpuid; /* LONG: CPU id */
+ uint32_t l_rtime_sec; /* STRUCT TIMEVAL: Real time. */
+ uint32_t l_rtime_usec; /* STRUCT TIMEVAL: Real time. */
+ uint32_t l_cpticks; /* INT: ticks during l_swtime */
+ uint32_t l_pctcpu; /* FIXPT_T: cpu usage for ps */
+ uint32_t l_pid; /* PID_T: process identifier */
+ char l_name[KI_LNAMELEN]; /* CHAR[]: name, may be empty */
+};
+
+/*
+ * KERN_PROC_ARGS subtypes
+ */
+#define KERN_PROC_ARGV 1 /* argv */
+#define KERN_PROC_NARGV 2 /* number of strings in above */
+#define KERN_PROC_ENV 3 /* environ */
+#define KERN_PROC_NENV 4 /* number of strings in above */
+
+/*
+ * KERN_SYSVIPC subtypes
+ */
+#define KERN_SYSVIPC_INFO 1 /* struct: number of valid kern ids */
+#define KERN_SYSVIPC_MSG 2 /* int: SysV message queue suppoprt */
+#define KERN_SYSVIPC_SEM 3 /* int: SysV semaphore support */
+#define KERN_SYSVIPC_SHM 4 /* int: SysV shared memory support */
+#define KERN_SYSVIPC_SHMMAX 5 /* int: max shared memory segment size (bytes) */
+#define KERN_SYSVIPC_SHMMNI 6 /* int: max number of shared memory identifiers */
+#define KERN_SYSVIPC_SHMSEG 7 /* int: max shared memory segments per process */
+#define KERN_SYSVIPC_SHMMAXPGS 8 /* int: max amount of shared memory (pages) */
+#define KERN_SYSVIPC_SHMUSEPHYS 9 /* int: physical memory usage */
+
+/*
+ * KERN_SYSVIPC_INFO subtypes
+ */
+/* KERN_SYSVIPC_OMSG_INFO 1 */
+/* KERN_SYSVIPC_OSEM_INFO 2 */
+/* KERN_SYSVIPC_OSHM_INFO 3 */
+#define KERN_SYSVIPC_MSG_INFO 4 /* msginfo and msqid_ds */
+#define KERN_SYSVIPC_SEM_INFO 5 /* seminfo and semid_ds */
+#define KERN_SYSVIPC_SHM_INFO 6 /* shminfo and shmid_ds */
+
+/*
+ * tty counter sysctl variables
+ */
+#define KERN_TKSTAT_NIN 1 /* total input character */
+#define KERN_TKSTAT_NOUT 2 /* total output character */
+#define KERN_TKSTAT_CANCC 3 /* canonical input character */
+#define KERN_TKSTAT_RAWCC 4 /* raw input character */
+#define KERN_TKSTAT_MAXID 5 /* number of valid TKSTAT ids */
+
+#define KERN_TKSTAT_NAMES { \
+ { 0, 0 }, \
+ { "nin", CTLTYPE_QUAD }, \
+ { "nout", CTLTYPE_QUAD }, \
+ { "cancc", CTLTYPE_QUAD }, \
+ { "rawcc", CTLTYPE_QUAD }, \
+}
+
+/*
+ * kern.drivers returns an array of these.
+ */
+
+struct kinfo_drivers {
+ devmajor_t d_cmajor;
+ devmajor_t d_bmajor;
+ char d_name[24];
+};
+
+/*
+ * KERN_BUF subtypes, like KERN_PROC2, where the four following mib
+ * entries specify "which type of buf", "which particular buf",
+ * "sizeof buf", and "how many". Currently, only "all buf" is
+ * defined.
+ */
+#define KERN_BUF_ALL 0 /* all buffers */
+
+/*
+ * kern.buf returns an array of these structures, which are designed
+ * both to be immune to 32/64 bit emulation issues and to provide
+ * backwards compatibility. Note that the order here differs slightly
+ * from the real struct buf in order to achieve proper 64 bit
+ * alignment.
+ */
+struct buf_sysctl {
+ uint32_t b_flags; /* LONG: B_* flags */
+ int32_t b_error; /* INT: Errno value */
+ int32_t b_prio; /* INT: Hint for buffer queue discipline */
+ uint32_t b_dev; /* DEV_T: Device associated with buffer */
+ uint64_t b_bufsize; /* LONG: Allocated buffer size */
+ uint64_t b_bcount; /* LONG: Valid bytes in buffer */
+ uint64_t b_resid; /* LONG: Remaining I/O */
+ uint64_t b_addr; /* CADDR_T: Memory, superblocks, indirect... */
+ uint64_t b_blkno; /* DADDR_T: Underlying physical block number */
+ uint64_t b_rawblkno; /* DADDR_T: Raw underlying physical block */
+ uint64_t b_iodone; /* PTR: Function called upon completion */
+ uint64_t b_proc; /* PTR: Associated proc if B_PHYS set */
+ uint64_t b_vp; /* PTR: File vnode */
+ uint64_t b_saveaddr; /* PTR: Original b_addr for physio */
+ uint64_t b_lblkno; /* DADDR_T: Logical block number */
+};
+
+/*
+ * kern.file2 returns an array of these structures, which are designed
+ * both to be immune to be immune to 32/64 bit emulation issues and to
+ * provide backwards compatibility. The order differs slightly from
+ * that of the real struct file, and some fields are taken from other
+ * structures (struct vnode, struct proc) in order to make the file
+ * information more useful.
+ */
+struct kinfo_file {
+ uint64_t ki_fileaddr; /* PTR: address of struct file */
+ uint32_t ki_flag; /* INT: flags (see fcntl.h) */
+ uint32_t ki_iflags; /* INT: internal flags */
+ uint32_t ki_ftype; /* INT: descriptor type */
+ uint32_t ki_count; /* UINT: reference count */
+ uint32_t ki_msgcount; /* UINT: references from msg queue */
+ uint32_t ki_usecount; /* INT: number active users */
+ uint64_t ki_fucred; /* PTR: creds for descriptor */
+ uint32_t ki_fuid; /* UID_T: descriptor credentials */
+ uint32_t ki_fgid; /* GID_T: descriptor credentials */
+ uint64_t ki_fops; /* PTR: address of fileops */
+ uint64_t ki_foffset; /* OFF_T: offset */
+ uint64_t ki_fdata; /* PTR: descriptor data */
+
+ /* vnode information to glue this file to something */
+ uint64_t ki_vun; /* PTR: socket, specinfo, etc */
+ uint64_t ki_vsize; /* OFF_T: size of file */
+ uint32_t ki_vtype; /* ENUM: vnode type */
+ uint32_t ki_vtag; /* ENUM: type of underlying data */
+ uint64_t ki_vdata; /* PTR: private data for fs */
+
+ /* process information when retrieved via KERN_FILE_BYPID */
+ uint32_t ki_pid; /* PID_T: process id */
+ int32_t ki_fd; /* INT: descriptor number */
+ uint32_t ki_ofileflags; /* CHAR: open file flags */
+ uint32_t _ki_padto64bits;
+};
+
+#define KERN_FILE_BYFILE 1
+#define KERN_FILE_BYPID 2
+#define KERN_FILESLOP 10
+
+/*
+ * kern.evcnt returns an array of these structures, which are designed both to
+ * be immune to 32/64 bit emulation issues. Note that the struct here differs
+ * from the real struct evcnt but contains the same information in order to
+ * accomodate sysctl.
+ */
+struct evcnt_sysctl {
+ uint64_t ev_count; /* current count */
+ uint64_t ev_addr; /* kernel address of evcnt */
+ uint64_t ev_parent; /* kernel address of parent */
+ uint8_t ev_type; /* EVCNT_TRAP_* */
+ uint8_t ev_grouplen; /* length of group with NUL */
+ uint8_t ev_namelen; /* length of name with NUL */
+ uint8_t ev_len; /* multiply by 8 */
+ /*
+ * Now the group and name strings follow (both include the trailing
+ * NUL). ev_name start at &ev_strings[ev_grouplen+1]
+ */
+ char ev_strings[0];
+};
+
+#define KERN_EVCNT_COUNT_ANY 0
+#define KERN_EVCNT_COUNT_NONZERO 1
+
+/*
+ * CTL_HW identifiers
+ */
+#define HW_MACHINE 1 /* string: machine class */
+#define HW_MODEL 2 /* string: specific machine model */
+#define HW_NCPU 3 /* int: number of cpus */
+#define HW_BYTEORDER 4 /* int: machine byte order */
+#define HW_PHYSMEM 5 /* int: total memory (bytes) */
+#define HW_USERMEM 6 /* int: non-kernel memory (bytes) */
+#define HW_PAGESIZE 7 /* int: software page size */
+#define HW_DISKNAMES 8 /* string: disk drive names */
+#define HW_IOSTATS 9 /* struct: iostats[] */
+#define HW_MACHINE_ARCH 10 /* string: machine architecture */
+#define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */
+#define HW_CNMAGIC 12 /* string: console magic sequence(s) */
+#define HW_PHYSMEM64 13 /* quad: total memory (bytes) */
+#define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */
+#define HW_IOSTATNAMES 15 /* string: iostat names */
+#define HW_MAXID 15 /* number of valid hw ids */
+#define HW_NCPUONLINE 16 /* number CPUs online */
+
+#define CTL_HW_NAMES { \
+ { 0, 0 }, \
+ { "machine", CTLTYPE_STRING }, \
+ { "model", CTLTYPE_STRING }, \
+ { "ncpu", CTLTYPE_INT }, \
+ { "byteorder", CTLTYPE_INT }, \
+ { "physmem", CTLTYPE_INT }, \
+ { "usermem", CTLTYPE_INT }, \
+ { "pagesize", CTLTYPE_INT }, \
+ { "drivenames", CTLTYPE_STRING }, \
+ { "drivestats", CTLTYPE_STRUCT }, \
+ { "machine_arch", CTLTYPE_STRING }, \
+ { "alignbytes", CTLTYPE_INT }, \
+ { "cnmagic", CTLTYPE_STRING }, \
+ { "physmem64", CTLTYPE_QUAD }, \
+ { "usermem64", CTLTYPE_QUAD }, \
+ { "ncpuonline", CTLTYPE_INT }, \
+}
+
+/*
+ * CTL_USER definitions
+ */
+#define USER_CS_PATH 1 /* string: _CS_PATH */
+#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
+#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
+#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
+#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
+#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
+#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
+#define USER_LINE_MAX 8 /* int: LINE_MAX */
+#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
+#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
+#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
+#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
+#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
+#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
+#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
+#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
+#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
+#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
+#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
+#define USER_TZNAME_MAX 20 /* int: _POSIX_TZNAME_MAX */
+#define USER_ATEXIT_MAX 21 /* int: {ATEXIT_MAX} */
+#define USER_MAXID 22 /* number of valid user ids */
+
+#define CTL_USER_NAMES { \
+ { 0, 0 }, \
+ { "cs_path", CTLTYPE_STRING }, \
+ { "bc_base_max", CTLTYPE_INT }, \
+ { "bc_dim_max", CTLTYPE_INT }, \
+ { "bc_scale_max", CTLTYPE_INT }, \
+ { "bc_string_max", CTLTYPE_INT }, \
+ { "coll_weights_max", CTLTYPE_INT }, \
+ { "expr_nest_max", CTLTYPE_INT }, \
+ { "line_max", CTLTYPE_INT }, \
+ { "re_dup_max", CTLTYPE_INT }, \
+ { "posix2_version", CTLTYPE_INT }, \
+ { "posix2_c_bind", CTLTYPE_INT }, \
+ { "posix2_c_dev", CTLTYPE_INT }, \
+ { "posix2_char_term", CTLTYPE_INT }, \
+ { "posix2_fort_dev", CTLTYPE_INT }, \
+ { "posix2_fort_run", CTLTYPE_INT }, \
+ { "posix2_localedef", CTLTYPE_INT }, \
+ { "posix2_sw_dev", CTLTYPE_INT }, \
+ { "posix2_upe", CTLTYPE_INT }, \
+ { "stream_max", CTLTYPE_INT }, \
+ { "tzname_max", CTLTYPE_INT }, \
+ { "atexit_max", CTLTYPE_INT }, \
+}
+
+/*
+ * CTL_DDB definitions
+ */
+#define DDBCTL_RADIX 1 /* int: Input and output radix */
+#define DDBCTL_MAXOFF 2 /* int: max symbol offset */
+#define DDBCTL_MAXWIDTH 3 /* int: width of the display line */
+#define DDBCTL_LINES 4 /* int: number of display lines */
+#define DDBCTL_TABSTOPS 5 /* int: tab width */
+#define DDBCTL_ONPANIC 6 /* int: DDB on panic if non-zero */
+#define DDBCTL_FROMCONSOLE 7 /* int: DDB via console if non-zero */
+#define DDBCTL_MAXID 8 /* number of valid DDB ids */
+
+#define CTL_DDB_NAMES { \
+ { 0, 0 }, \
+ { "radix", CTLTYPE_INT }, \
+ { "maxoff", CTLTYPE_INT }, \
+ { "maxwidth", CTLTYPE_INT }, \
+ { "lines", CTLTYPE_INT }, \
+ { "tabstops", CTLTYPE_INT }, \
+ { "onpanic", CTLTYPE_INT }, \
+ { "fromconsole", CTLTYPE_INT }, \
+}
+
+/*
+ * CTL_DEBUG definitions
+ *
+ * Second level identifier specifies which debug variable.
+ * Third level identifier specifies which structure component.
+ */
+#define CTL_DEBUG_NAME 0 /* string: variable name */
+#define CTL_DEBUG_VALUE 1 /* int: variable value */
+#define CTL_DEBUG_MAXID 20
+
+/*
+ * CTL_PROC subtype. Either a PID, or a magic value for the current proc.
+ */
+
+#define PROC_CURPROC (~((u_int)1 << 31))
+
+/*
+ * CTL_PROC tree: either corename (string), or a limit
+ * (rlimit.<type>.{hard,soft}, int).
+ */
+#define PROC_PID_CORENAME 1
+#define PROC_PID_LIMIT 2
+#define PROC_PID_STOPFORK 3
+#define PROC_PID_STOPEXEC 4
+#define PROC_PID_STOPEXIT 5
+#define PROC_PID_MAXID 6
+
+#define PROC_PID_NAMES { \
+ { 0, 0 }, \
+ { "corename", CTLTYPE_STRING }, \
+ { "rlimit", CTLTYPE_NODE }, \
+ { "stopfork", CTLTYPE_INT }, \
+ { "stopexec", CTLTYPE_INT }, \
+ { "stopexit", CTLTYPE_INT }, \
+}
+
+/* Limit types from <sys/resources.h> */
+#define PROC_PID_LIMIT_CPU (RLIMIT_CPU+1)
+#define PROC_PID_LIMIT_FSIZE (RLIMIT_FSIZE+1)
+#define PROC_PID_LIMIT_DATA (RLIMIT_DATA+1)
+#define PROC_PID_LIMIT_STACK (RLIMIT_STACK+1)
+#define PROC_PID_LIMIT_CORE (RLIMIT_CORE+1)
+#define PROC_PID_LIMIT_RSS (RLIMIT_RSS+1)
+#define PROC_PID_LIMIT_MEMLOCK (RLIMIT_MEMLOCK+1)
+#define PROC_PID_LIMIT_NPROC (RLIMIT_NPROC+1)
+#define PROC_PID_LIMIT_NOFILE (RLIMIT_NOFILE+1)
+#define PROC_PID_LIMIT_SBSIZE (RLIMIT_SBSIZE+1)
+#define PROC_PID_LIMIT_AS (RLIMIT_AS+1)
+#define PROC_PID_LIMIT_NTHR (RLIMIT_NTHR+1)
+#define PROC_PID_LIMIT_MAXID (RLIM_NLIMITS+1)
+
+#define PROC_PID_LIMIT_NAMES { \
+ { 0, 0 }, \
+ { "cputime", CTLTYPE_NODE }, \
+ { "filesize", CTLTYPE_NODE }, \
+ { "datasize", CTLTYPE_NODE }, \
+ { "stacksize", CTLTYPE_NODE }, \
+ { "coredumpsize", CTLTYPE_NODE }, \
+ { "memoryuse", CTLTYPE_NODE }, \
+ { "memorylocked", CTLTYPE_NODE }, \
+ { "maxproc", CTLTYPE_NODE }, \
+ { "descriptors", CTLTYPE_NODE }, \
+ { "sbsize", CTLTYPE_NODE }, \
+ { "vmemoryuse", CTLTYPE_NODE }, \
+ { "maxlwp", CTLTYPE_NODE }, \
+}
+/* for each type, either hard or soft value */
+#define PROC_PID_LIMIT_TYPE_SOFT 1
+#define PROC_PID_LIMIT_TYPE_HARD 2
+#define PROC_PID_LIMIT_TYPE_MAXID 3
+
+#define PROC_PID_LIMIT_TYPE_NAMES { \
+ {0, 0}, \
+ { "soft", CTLTYPE_QUAD }, \
+ { "hard", CTLTYPE_QUAD }, \
+}
+
+/*
+ * CTL_EMUL definitions
+ *
+ * Second level identifier specifies which emulation variable.
+ * Subsequent levels are specified in the emulations themselves.
+ */
+#define EMUL_LINUX 1
+#define EMUL_LINUX32 5
+
+#define EMUL_MAXID 6
+
+#ifdef _KERNEL
+
+#if defined(_KERNEL_OPT)
+#include "opt_sysctl.h"
+#endif
+
+/* Root node of the kernel sysctl tree */
+extern struct sysctlnode sysctl_root;
+
+/*
+ * A log of nodes created by a setup function or set of setup
+ * functions so that they can be torn down in one "transaction"
+ * when no longer needed.
+ *
+ * Users of the log merely pass a pointer to a pointer, and the sysctl
+ * infrastructure takes care of the rest.
+ */
+struct sysctllog;
+
+/*
+ * CTL_DEBUG variables.
+ *
+ * These are declared as separate variables so that they can be
+ * individually initialized at the location of their associated
+ * variable. The loader prevents multiple use by issuing errors
+ * if a variable is initialized in more than one place. They are
+ * aggregated into an array in debug_sysctl(), so that it can
+ * conveniently locate them when querried. If more debugging
+ * variables are added, they must also be declared here and also
+ * entered into the array.
+ *
+ * Note that the debug subtree is largely obsolescent in terms of
+ * functionality now that we have dynamic sysctl, but the
+ * infrastructure is retained for backwards compatibility.
+ */
+struct ctldebug {
+ const char *debugname; /* name of debugging variable */
+ int *debugvar; /* pointer to debugging variable */
+};
+#ifdef DEBUG
+extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
+extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
+extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
+extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
+#endif /* DEBUG */
+
+#define SYSCTLFN_PROTO const int *, u_int, void *, \
+ size_t *, const void *, size_t, \
+ const int *, struct lwp *, const struct sysctlnode *
+#define SYSCTLFN_ARGS const int *name, u_int namelen, \
+ void *oldp, size_t *oldlenp, \
+ const void *newp, size_t newlen, \
+ const int *oname, struct lwp *l, \
+ const struct sysctlnode *rnode
+#define SYSCTLFN_CALL(node) name, namelen, oldp, \
+ oldlenp, newp, newlen, \
+ oname, l, node
+
+#ifdef _MODULE
+
+#define SYSCTL_SETUP_PROTO(name) \
+ void name(struct sysctllog **)
+#ifdef SYSCTL_DEBUG_SETUP
+#define SYSCTL_SETUP(name, desc) \
+ SYSCTL_SETUP_PROTO(name); \
+ static void __CONCAT(___,name)(struct sysctllog **); \
+ void name(struct sysctllog **clog) { \
+ printf("%s\n", desc); \
+ __CONCAT(___,name)(clog); } \
+ __link_set_add_text(sysctl_funcs, name); \
+ static void __CONCAT(___,name)(struct sysctllog **clog)
+#else /* !SYSCTL_DEBUG_SETUP */
+#define SYSCTL_SETUP(name, desc) \
+ SYSCTL_SETUP_PROTO(name); \
+ __link_set_add_text(sysctl_funcs, name); \
+ void name(struct sysctllog **clog)
+#endif /* !SYSCTL_DEBUG_SETUP */
+
+#else /* !_MODULE */
+
+#define SYSCTL_SETUP_PROTO(name)
+#ifdef SYSCTL_DEBUG_SETUP
+#define SYSCTL_SETUP(name, desc) \
+ static void __CONCAT(___,name)(struct sysctllog **); \
+ static void name(struct sysctllog **clog) { \
+ printf("%s\n", desc); \
+ __CONCAT(___,name)(clog); } \
+ __link_set_add_text(sysctl_funcs, name); \
+ static void __CONCAT(___,name)(struct sysctllog **clog)
+#else /* !SYSCTL_DEBUG_SETUP */
+#define SYSCTL_SETUP(name, desc) \
+ static void name(struct sysctllog **); \
+ __link_set_add_text(sysctl_funcs, name); \
+ static void name(struct sysctllog **clog)
+#endif /* !SYSCTL_DEBUG_SETUP */
+
+#endif /* !_MODULE */
+
+/*
+ * Internal sysctl function calling convention:
+ *
+ * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen,
+ * origname, lwp, node);
+ *
+ * The name parameter points at the next component of the name to be
+ * interpreted. The namelen parameter is the number of integers in
+ * the name. The origname parameter points to the start of the name
+ * being parsed. The node parameter points to the node on which the
+ * current operation is to be performed.
+ */
+typedef int (*sysctlfn)(SYSCTLFN_PROTO);
+
+/*
+ * used in more than just sysctl
+ */
+void fill_eproc(struct proc *, struct eproc *, bool);
+
+/*
+ * subsystem setup
+ */
+void sysctl_init(void);
+void sysctl_finalize(void);
+
+/*
+ * typical syscall call order
+ */
+void sysctl_lock(bool);
+int sysctl_dispatch(SYSCTLFN_PROTO);
+void sysctl_unlock(void);
+void sysctl_relock(void);
+
+/*
+ * tree navigation primitives (must obtain lock before using these)
+ */
+int sysctl_locate(struct lwp *, const int *, u_int,
+ const struct sysctlnode **, int *);
+int sysctl_query(SYSCTLFN_PROTO);
+int sysctl_create(SYSCTLFN_PROTO);
+int sysctl_destroy(SYSCTLFN_PROTO);
+int sysctl_lookup(SYSCTLFN_PROTO);
+int sysctl_describe(SYSCTLFN_PROTO);
+
+/*
+ * simple variadic interface for adding/removing nodes
+ */
+int sysctl_createv(struct sysctllog **, int,
+ const struct sysctlnode **, const struct sysctlnode **,
+ int, int, const char *, const char *,
+ sysctlfn, u_quad_t, void *, size_t, ...);
+int sysctl_destroyv(struct sysctlnode *, ...);
+
+#define VERIFY_FN(ctl_type, c_type) \
+__always_inline static __inline void * \
+__sysctl_verify_##ctl_type##_arg(c_type *arg) \
+{ \
+ return arg; \
+}
+
+VERIFY_FN(CTLTYPE_NODE, struct sysctlnode);
+VERIFY_FN(CTLTYPE_INT, int);
+VERIFY_FN(CTLTYPE_STRING, char);
+VERIFY_FN(CTLTYPE_QUAD, int64_t);
+VERIFY_FN(CTLTYPE_STRUCT, void);
+VERIFY_FN(CTLTYPE_BOOL, bool);
+VERIFY_FN(CTLTYPE_LONG, long);
+#undef VERIFY_FN
+
+#define sysctl_createv(lg, cfl, rn, cn, fl, type, nm, desc, fn, qv, newp, ...) \
+ sysctl_createv(lg, cfl, rn, cn, fl, type, nm, desc, fn, qv, \
+ __sysctl_verify_##type##_arg(newp), __VA_ARGS__)
+
+/*
+ * miscellany
+ */
+void sysctl_dump(const struct sysctlnode *);
+void sysctl_free(struct sysctlnode *);
+void sysctl_teardown(struct sysctllog **);
+void sysctl_log_print(const struct sysctllog *);
+
+#ifdef SYSCTL_INCLUDE_DESCR
+#define SYSCTL_DESCR(s) s
+#else /* SYSCTL_INCLUDE_DESCR */
+#define SYSCTL_DESCR(s) NULL
+#endif /* SYSCTL_INCLUDE_DESCR */
+
+/*
+ * simple interface similar to old interface for in-kernel consumption
+ */
+int old_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct lwp *);
+
+/*
+ * these helpers are in other files (XXX so should the nodes be) or
+ * are used by more than one node
+ */
+int sysctl_hw_tapenames(SYSCTLFN_PROTO);
+int sysctl_hw_tapestats(SYSCTLFN_PROTO);
+int sysctl_kern_vnode(SYSCTLFN_PROTO);
+int sysctl_net_inet_ip_ports(SYSCTLFN_PROTO);
+int sysctl_consdev(SYSCTLFN_PROTO);
+int sysctl_root_device(SYSCTLFN_PROTO);
+int sysctl_vfs_generic_fstypes(SYSCTLFN_PROTO);
+
+/*
+ * primitive helper stubs
+ */
+int sysctl_needfunc(SYSCTLFN_PROTO);
+int sysctl_notavail(SYSCTLFN_PROTO);
+int sysctl_null(SYSCTLFN_PROTO);
+
+int sysctl_copyin(struct lwp *, const void *, void *, size_t);
+int sysctl_copyout(struct lwp *, const void *, void *, size_t);
+int sysctl_copyinstr(struct lwp *, const void *, void *, size_t, size_t *);
+
+u_int sysctl_map_flags(const u_int *, u_int);
+
+MALLOC_DECLARE(M_SYSCTLNODE);
+MALLOC_DECLARE(M_SYSCTLDATA);
+
+extern const u_int sysctl_lwpflagmap[];
+
+extern cprng_strong_t *sysctl_prng;
+
+#else /* !_KERNEL */
+#include <sys/cdefs.h>
+
+typedef void *sysctlfn;
+
+__BEGIN_DECLS
+int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
+int sysctlbyname(const char *, void *, size_t *, const void *, size_t);
+int sysctlgetmibinfo(const char *, int *, u_int *,
+ char *, size_t *, struct sysctlnode **, int);
+int sysctlnametomib(const char *, int *, size_t *);
+int proc_compare(const struct kinfo_proc2 *, const struct kinfo_lwp *,
+ const struct kinfo_proc2 *, const struct kinfo_lwp *);
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#ifdef __COMPAT_SYSCTL
+/*
+ * old node definitions go here
+ */
+#endif /* __COMPAT_SYSCTL */
+
+/*
+ * padding makes alignment magically "work" for 32/64 compatibility at
+ * the expense of making things bigger on 32 bit platforms.
+ */
+#if defined(_LP64) || (BYTE_ORDER == LITTLE_ENDIAN)
+#define __sysc_pad(type) union { uint64_t __sysc_upad; \
+ struct { type __sysc_sdatum; } __sysc_ustr; }
+#else
+#define __sysc_pad(type) union { uint64_t __sysc_upad; \
+ struct { uint32_t __sysc_spad; type __sysc_sdatum; } __sysc_ustr; }
+#endif
+#define __sysc_unpad(x) x.__sysc_ustr.__sysc_sdatum
+
+/*
+ * The following is for gcc2, which doesn't handle __sysc_unpad().
+ * The code gets a little less ugly this way.
+ */
+#define sysc_init_field(field, value) \
+ .field = { .__sysc_ustr = { .__sysc_sdatum = (value), }, }
+
+struct sysctlnode {
+ uint32_t sysctl_flags; /* flags and type */
+ int32_t sysctl_num; /* mib number */
+ char sysctl_name[SYSCTL_NAMELEN]; /* node name */
+ uint32_t sysctl_ver; /* node's version vs. rest of tree */
+ uint32_t __rsvd;
+ union {
+ struct {
+ uint32_t suc_csize; /* size of child node array */
+ uint32_t suc_clen; /* number of valid children */
+ __sysc_pad(struct sysctlnode*) _suc_child; /* array of child nodes */
+ } scu_child;
+ struct {
+ __sysc_pad(void*) _sud_data; /* pointer to external data */
+ __sysc_pad(size_t) _sud_offset; /* offset to data */
+ } scu_data;
+ int32_t scu_alias; /* node this node refers to */
+ int32_t scu_idata; /* immediate "int" data */
+ u_quad_t scu_qdata; /* immediate "u_quad_t" data */
+ bool scu_bdata; /* immediate bool data */
+ } sysctl_un;
+ __sysc_pad(size_t) _sysctl_size; /* size of instrumented data */
+ __sysc_pad(sysctlfn) _sysctl_func; /* access helper function */
+ __sysc_pad(struct sysctlnode*) _sysctl_parent; /* parent of this node */
+ __sysc_pad(const char *) _sysctl_desc; /* description of node */
+};
+
+/*
+ * padded data
+ */
+#define suc_child __sysc_unpad(_suc_child)
+#define sud_data __sysc_unpad(_sud_data)
+#define sud_offset __sysc_unpad(_sud_offset)
+#define sysctl_size __sysc_unpad(_sysctl_size)
+#define sysctl_func __sysc_unpad(_sysctl_func)
+#define sysctl_parent __sysc_unpad(_sysctl_parent)
+#define sysctl_desc __sysc_unpad(_sysctl_desc)
+
+/*
+ * nested data (may also be padded)
+ */
+#define sysctl_csize sysctl_un.scu_child.suc_csize
+#define sysctl_clen sysctl_un.scu_child.suc_clen
+#define sysctl_child sysctl_un.scu_child.suc_child
+#define sysctl_data sysctl_un.scu_data.sud_data
+#define sysctl_offset sysctl_un.scu_data.sud_offset
+#define sysctl_alias sysctl_un.scu_alias
+#define sysctl_idata sysctl_un.scu_idata
+#define sysctl_qdata sysctl_un.scu_qdata
+#define sysctl_bdata sysctl_un.scu_bdata
+
+/*
+ * when requesting a description of a node (a set of nodes, actually),
+ * you get back an "array" of these, where the actual length of the
+ * descr_str is noted in descr_len (which includes the trailing nul
+ * byte), rounded up to the nearest four (sizeof(int32_t) actually).
+ *
+ * NEXT_DESCR() will take a pointer to a description and advance it to
+ * the next description.
+ */
+struct sysctldesc {
+ int32_t descr_num; /* mib number of node */
+ uint32_t descr_ver; /* version of node */
+ uint32_t descr_len; /* length of description string */
+ char descr_str[1]; /* not really 1...see above */
+};
+
+#define __sysc_desc_roundup(x) ((((x) - 1) | (sizeof(int32_t) - 1)) + 1)
+#define __sysc_desc_adv(d, l) \
+ (/*XXXUNCONST ptr cast*/(struct sysctldesc *) \
+ __UNCONST(((const char*)(d)) + offsetof(struct sysctldesc, descr_str) +\
+ __sysc_desc_roundup(l)))
+#define NEXT_DESCR(d) __sysc_desc_adv((d), (d)->descr_len)
+
+static __inline const struct sysctlnode *
+sysctl_rootof(const struct sysctlnode *n)
+{
+ while (n->sysctl_parent != NULL)
+ n = n->sysctl_parent;
+ return (n);
+}
+
+#endif /* !_SYS_SYSCTL_H_ */
--- /dev/null
+/* $NetBSD: systm.h,v 1.257 2012/08/03 18:08:01 matt Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1988, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)systm.h 8.7 (Berkeley) 3/29/95
+ */
+
+#ifndef _SYS_SYSTM_H_
+#define _SYS_SYSTM_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_ddb.h"
+#include "opt_multiprocessor.h"
+#endif
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <stdbool.h>
+#endif
+
+#include <machine/endian.h>
+
+#include <sys/types.h>
+#include <sys/stdarg.h>
+
+#include <sys/device_if.h>
+
+struct clockframe;
+struct lwp;
+struct proc;
+struct timeval;
+struct tty;
+struct uio;
+struct vnode;
+struct vmspace;
+struct vm_map;
+
+extern const char *panicstr; /* panic message */
+extern int doing_shutdown; /* shutting down */
+
+extern const char copyright[]; /* system copyright */
+extern char cpu_model[]; /* machine/cpu model name */
+extern char machine[]; /* machine type */
+extern char machine_arch[]; /* machine architecture */
+extern const char osrelease[]; /* short system version */
+extern const char ostype[]; /* system type */
+extern const char kernel_ident[];/* kernel configuration ID */
+extern const char version[]; /* system version */
+
+extern int autonicetime; /* time (in seconds) before autoniceval */
+extern int autoniceval; /* proc priority after autonicetime */
+
+extern int selwait; /* select timeout address */
+
+extern int maxmem; /* max memory per process */
+extern int physmem; /* physical memory */
+
+extern dev_t dumpdev; /* dump device */
+extern dev_t dumpcdev; /* dump device (character equivalent) */
+extern long dumplo; /* offset into dumpdev */
+extern int dumpsize; /* size of dump in pages */
+extern const char *dumpspec; /* how dump device was specified */
+
+extern dev_t rootdev; /* root device */
+extern struct vnode *rootvp; /* vnode equivalent to above */
+extern device_t root_device; /* device equivalent to above */
+extern const char *rootspec; /* how root device was specified */
+
+extern int ncpu; /* number of CPUs configured */
+extern int ncpuonline; /* number of CPUs online */
+#if defined(_KERNEL)
+extern bool mp_online; /* secondary processors are started */
+#endif /* defined(_KERNEL) */
+
+extern const char hexdigits[]; /* "0123456789abcdef" in subr_prf.c */
+extern const char HEXDIGITS[]; /* "0123456789ABCDEF" in subr_prf.c */
+
+/*
+ * These represent the swap pseudo-device (`sw'). This device
+ * is used by the swap pager to indirect through the routines
+ * in sys/vm/vm_swap.c.
+ */
+extern const dev_t swapdev; /* swapping device */
+extern struct vnode *swapdev_vp;/* vnode equivalent to above */
+
+extern const dev_t zerodev; /* /dev/zero */
+
+typedef int sy_call_t(struct lwp *, const void *, register_t *);
+
+extern struct sysent { /* system call table */
+ short sy_narg; /* number of args */
+ short sy_argsize; /* total size of arguments */
+ int sy_flags; /* flags. see below */
+ sy_call_t *sy_call; /* implementing function */
+} sysent[];
+extern int nsysent;
+#if BYTE_ORDER == BIG_ENDIAN
+#define SCARG(p,k) ((p)->k.be.datum) /* get arg from args pointer */
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define SCARG(p,k) ((p)->k.le.datum) /* get arg from args pointer */
+#else
+#error "what byte order is this machine?"
+#endif
+
+#define SYCALL_INDIRECT 0x0000002 /* indirect (ie syscall() or __syscall()) */
+#define SYCALL_NARGS64_MASK 0x000f000 /* count of 64bit args */
+#define SYCALL_RET_64 0x0010000 /* retval is a 64bit integer value */
+#define SYCALL_ARG0_64 0x0020000
+#define SYCALL_ARG1_64 0x0040000
+#define SYCALL_ARG2_64 0x0080000
+#define SYCALL_ARG3_64 0x0100000
+#define SYCALL_ARG4_64 0x0200000
+#define SYCALL_ARG5_64 0x0400000
+#define SYCALL_ARG6_64 0x0800000
+#define SYCALL_ARG7_64 0x1000000
+#define SYCALL_NOSYS 0x2000000 /* permanent nosys in sysent[] */
+#define SYCALL_ARG_PTR 0x3000000 /* at least one argument is a pointer */
+#define SYCALL_RET_64_P(sy) ((sy)->sy_flags & SYCALL_RET_64)
+#define SYCALL_ARG_64_P(sy, n) ((sy)->sy_flags & (SYCALL_ARG0_64 << (n)))
+#define SYCALL_ARG_64_MASK(sy) (((sy)->sy_flags >> 17) & 0xff)
+#define SYCALL_NARGS64(sy) (((sy)->sy_flags >> 12) & 0x0f)
+#define SYCALL_NARGS64_VAL(n) ((n) << 12)
+
+extern int boothowto; /* reboot flags, from console subsystem */
+#define bootverbose (boothowto & AB_VERBOSE)
+#define bootquiet (boothowto & AB_QUIET)
+
+extern void (*v_putc)(int); /* Virtual console putc routine */
+
+/*
+ * General function declarations.
+ */
+void voidop(void);
+int nullop(void *);
+int enodev(void);
+int enosys(void);
+int enoioctl(void);
+int enxio(void);
+int eopnotsupp(void);
+
+enum hashtype {
+ HASH_LIST,
+ HASH_SLIST,
+ HASH_TAILQ
+};
+
+#ifdef _KERNEL
+void *hashinit(u_int, enum hashtype, bool, u_long *);
+void hashdone(void *, enum hashtype, u_long);
+int seltrue(dev_t, int, struct lwp *);
+int sys_nosys(struct lwp *, const void *, register_t *);
+int sys_nomodule(struct lwp *, const void *, register_t *);
+
+void aprint_normal(const char *, ...) __printflike(1, 2);
+void aprint_error(const char *, ...) __printflike(1, 2);
+void aprint_naive(const char *, ...) __printflike(1, 2);
+void aprint_verbose(const char *, ...) __printflike(1, 2);
+void aprint_debug(const char *, ...) __printflike(1, 2);
+
+void device_printf(device_t, const char *fmt, ...) __printflike(2, 3);
+
+void aprint_normal_dev(device_t, const char *, ...) __printflike(2, 3);
+void aprint_error_dev(device_t, const char *, ...) __printflike(2, 3);
+void aprint_naive_dev(device_t, const char *, ...) __printflike(2, 3);
+void aprint_verbose_dev(device_t, const char *, ...) __printflike(2, 3);
+void aprint_debug_dev(device_t, const char *, ...) __printflike(2, 3);
+
+struct ifnet;
+
+void aprint_normal_ifnet(struct ifnet *, const char *, ...)
+ __printflike(2, 3);
+void aprint_error_ifnet(struct ifnet *, const char *, ...)
+ __printflike(2, 3);
+void aprint_naive_ifnet(struct ifnet *, const char *, ...)
+ __printflike(2, 3);
+void aprint_verbose_ifnet(struct ifnet *, const char *, ...)
+ __printflike(2, 3);
+void aprint_debug_ifnet(struct ifnet *, const char *, ...)
+ __printflike(2, 3);
+
+int aprint_get_error_count(void);
+
+void printf_tolog(const char *, ...) __printflike(1, 2);
+
+void printf_nolog(const char *, ...) __printflike(1, 2);
+
+void printf(const char *, ...) __printflike(1, 2);
+
+int sprintf(char *, const char *, ...) __printflike(2, 3);
+
+int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
+
+void vprintf(const char *, va_list) __printflike(1, 0);
+
+int vsprintf(char *, const char *, va_list) __printflike(2, 0);
+
+int vsnprintf(char *, size_t, const char *, va_list) __printflike(3, 0);
+
+int humanize_number(char *, size_t, uint64_t, const char *, int);
+
+void twiddle(void);
+void banner(void);
+#endif /* _KERNEL */
+
+void panic(const char *, ...) __dead __printflike(1, 2);
+void vpanic(const char *, va_list) __dead __printflike(1, 0);
+void uprintf(const char *, ...) __printflike(1, 2);
+void uprintf_locked(const char *, ...) __printflike(1, 2);
+void ttyprintf(struct tty *, const char *, ...) __printflike(2, 3);
+
+int format_bytes(char *, size_t, uint64_t);
+
+void tablefull(const char *, const char *);
+
+int kcopy(const void *, void *, size_t);
+
+#ifdef _KERNEL
+#define bcopy(src, dst, len) memcpy((dst), (src), (len))
+#define bzero(src, len) memset((src), 0, (len))
+#define bcmp(a, b, len) memcmp((a), (b), (len))
+#endif /* KERNEL */
+
+int copystr(const void *, void *, size_t, size_t *);
+int copyinstr(const void *, void *, size_t, size_t *);
+int copyoutstr(const void *, void *, size_t, size_t *);
+int copyin(const void *, void *, size_t);
+int copyout(const void *, void *, size_t);
+
+#ifdef _KERNEL
+typedef int (*copyin_t)(const void *, void *, size_t);
+typedef int (*copyout_t)(const void *, void *, size_t);
+#endif
+
+int copyin_proc(struct proc *, const void *, void *, size_t);
+int copyout_proc(struct proc *, const void *, void *, size_t);
+int copyin_vmspace(struct vmspace *, const void *, void *, size_t);
+int copyout_vmspace(struct vmspace *, const void *, void *, size_t);
+
+int ioctl_copyin(int ioctlflags, const void *src, void *dst, size_t len);
+int ioctl_copyout(int ioctlflags, const void *src, void *dst, size_t len);
+
+int ucas_ptr(volatile void *, void *, void *, void *);
+int ucas_int(volatile int *, int, int, int *);
+
+int subyte(void *, int);
+int suibyte(void *, int);
+int susword(void *, short);
+int suisword(void *, short);
+int suswintr(void *, short);
+int suword(void *, long);
+int suiword(void *, long);
+
+int fubyte(const void *);
+int fuibyte(const void *);
+int fusword(const void *);
+int fuisword(const void *);
+int fuswintr(const void *);
+long fuword(const void *);
+long fuiword(const void *);
+
+void hardclock(struct clockframe *);
+void softclock(void *);
+void statclock(struct clockframe *);
+
+#ifdef NTP
+void ntp_init(void);
+#ifdef PPS_SYNC
+struct timespec;
+void hardpps(struct timespec *, long);
+#endif /* PPS_SYNC */
+#else
+void ntp_init(void); /* also provides adjtime() functionality */
+#endif /* NTP */
+
+void ssp_init(void);
+
+void initclocks(void);
+void inittodr(time_t);
+void resettodr(void);
+void cpu_initclocks(void);
+void setrootfstime(time_t);
+
+void startprofclock(struct proc *);
+void stopprofclock(struct proc *);
+void proftick(struct clockframe *);
+void setstatclockrate(int);
+
+/*
+ * Critical polling hooks. Functions to be run while the kernel stays
+ * elevated IPL for a "long" time. (watchdogs).
+ */
+void *critpollhook_establish(void (*)(void *), void *);
+void critpollhook_disestablish(void *);
+void docritpollhooks(void);
+
+/*
+ * Shutdown hooks. Functions to be run with all interrupts disabled
+ * immediately before the system is halted or rebooted.
+ */
+void *shutdownhook_establish(void (*)(void *), void *);
+void shutdownhook_disestablish(void *);
+void doshutdownhooks(void);
+
+/*
+ * Power management hooks.
+ */
+void *powerhook_establish(const char *, void (*)(int, void *), void *);
+void powerhook_disestablish(void *);
+void dopowerhooks(int);
+#define PWR_RESUME 0
+#define PWR_SUSPEND 1
+#define PWR_STANDBY 2
+#define PWR_SOFTRESUME 3
+#define PWR_SOFTSUSPEND 4
+#define PWR_SOFTSTANDBY 5
+#define PWR_NAMES \
+ "resume", /* 0 */ \
+ "suspend", /* 1 */ \
+ "standby", /* 2 */ \
+ "softresume", /* 3 */ \
+ "softsuspend", /* 4 */ \
+ "softstandby" /* 5 */
+
+/*
+ * Mountroot hooks (and mountroot declaration). Device drivers establish
+ * these to be executed just before (*mountroot)() if the passed device is
+ * selected as the root device.
+ */
+
+#define ROOT_FSTYPE_ANY "?"
+
+extern const char *rootfstype;
+void *mountroothook_establish(void (*)(device_t), device_t);
+void mountroothook_disestablish(void *);
+void mountroothook_destroy(void);
+void domountroothook(device_t);
+
+/*
+ * Exec hooks. Subsystems may want to do cleanup when a process
+ * execs.
+ */
+void *exechook_establish(void (*)(struct proc *, void *), void *);
+void exechook_disestablish(void *);
+void doexechooks(struct proc *);
+
+/*
+ * Exit hooks. Subsystems may want to do cleanup when a process exits.
+ */
+void *exithook_establish(void (*)(struct proc *, void *), void *);
+void exithook_disestablish(void *);
+void doexithooks(struct proc *);
+
+/*
+ * Fork hooks. Subsystems may want to do special processing when a process
+ * forks.
+ */
+void *forkhook_establish(void (*)(struct proc *, struct proc *));
+void forkhook_disestablish(void *);
+void doforkhooks(struct proc *, struct proc *);
+
+/*
+ * kernel syscall tracing/debugging hooks.
+ */
+#ifdef _KERNEL
+bool trace_is_enabled(struct proc *);
+int trace_enter(register_t, const register_t *, int);
+void trace_exit(register_t, register_t [], int);
+#endif
+
+int uiomove(void *, size_t, struct uio *);
+int uiomove_frombuf(void *, size_t, struct uio *);
+
+#ifdef _KERNEL
+int setjmp(label_t *) __returns_twice;
+void longjmp(label_t *) __dead;
+#endif
+
+void consinit(void);
+
+void cpu_startup(void);
+void cpu_configure(void);
+void cpu_rootconf(void);
+void cpu_dumpconf(void);
+
+#ifdef GPROF
+void kmstartup(void);
+#endif
+
+void machdep_init(void);
+
+#ifdef _KERNEL
+#include <lib/libkern/libkern.h>
+
+/*
+ * Stuff to handle debugger magic key sequences.
+ */
+#define CNS_LEN 128
+#define CNS_MAGIC_VAL(x) ((x)&0x1ff)
+#define CNS_MAGIC_NEXT(x) (((x)>>9)&0x7f)
+#define CNS_TERM 0x7f /* End of sequence */
+
+typedef struct cnm_state {
+ int cnm_state;
+ u_short *cnm_magic;
+} cnm_state_t;
+
+/* Override db_console() in MD headers */
+#ifndef cn_trap
+#define cn_trap() console_debugger()
+#endif
+#ifndef cn_isconsole
+#define cn_isconsole(d) (cn_tab != NULL && (d) == cn_tab->cn_dev)
+#endif
+
+void cn_init_magic(cnm_state_t *);
+void cn_destroy_magic(cnm_state_t *);
+int cn_set_magic(const char *);
+int cn_get_magic(char *, size_t);
+/* This should be called for each byte read */
+#ifndef cn_check_magic
+#define cn_check_magic(d, k, s) \
+ do { \
+ if (cn_isconsole(d)) { \
+ int _v = (s).cnm_magic[(s).cnm_state]; \
+ if ((k) == CNS_MAGIC_VAL(_v)) { \
+ (s).cnm_state = CNS_MAGIC_NEXT(_v); \
+ if ((s).cnm_state == CNS_TERM) { \
+ cn_trap(); \
+ (s).cnm_state = 0; \
+ } \
+ } else { \
+ (s).cnm_state = 0; \
+ } \
+ } \
+ } while (/* CONSTCOND */ 0)
+#endif
+
+/* Encode out-of-band events this way when passing to cn_check_magic() */
+#define CNC_BREAK 0x100
+
+#if defined(DDB) || defined(sun3) || defined(sun2)
+/* note that cpu_Debugger() is always available on sun[23] */
+void cpu_Debugger(void);
+#define Debugger cpu_Debugger
+#endif
+
+#ifdef DDB
+/*
+ * Enter debugger(s) from console attention if enabled
+ */
+extern int db_fromconsole; /* XXX ddb/ddbvar.h */
+#define console_debugger() if (db_fromconsole) Debugger()
+#elif defined(Debugger)
+#define console_debugger() Debugger()
+#else
+#define console_debugger() do {} while (/* CONSTCOND */ 0) /* NOP */
+#endif
+#endif /* _KERNEL */
+
+/* For SYSCALL_DEBUG */
+void scdebug_call(register_t, const register_t[]);
+void scdebug_ret(register_t, int, const register_t[]);
+
+void kernel_lock_init(void);
+void _kernel_lock(int);
+void _kernel_unlock(int, int *);
+bool _kernel_locked_p(void);
+
+#ifdef _KERNEL
+void kernconfig_lock_init(void);
+void kernconfig_lock(void);
+void kernconfig_unlock(void);
+bool kernconfig_is_held(void);
+#endif
+
+#if defined(MULTIPROCESSOR) || defined(_MODULE)
+#define KERNEL_LOCK(count, lwp) \
+do { \
+ if ((count) != 0) \
+ _kernel_lock((count)); \
+} while (/* CONSTCOND */ 0)
+#define KERNEL_UNLOCK(all, lwp, p) _kernel_unlock((all), (p))
+#define KERNEL_LOCKED_P() _kernel_locked_p()
+#else
+#define KERNEL_LOCK(count, lwp) do {(void)(count); (void)(lwp);} while (/* CONSTCOND */ 0) /*NOP*/
+#define KERNEL_UNLOCK(all, lwp, ptr) do {(void)(all); (void)(lwp); (void)(ptr);} while (/* CONSTCOND */ 0) /*NOP*/
+#define KERNEL_LOCKED_P() (true)
+#endif
+
+#define KERNEL_UNLOCK_LAST(l) KERNEL_UNLOCK(-1, (l), NULL)
+#define KERNEL_UNLOCK_ALL(l, p) KERNEL_UNLOCK(0, (l), (p))
+#define KERNEL_UNLOCK_ONE(l) KERNEL_UNLOCK(1, (l), NULL)
+
+/* Preemption control. */
+#ifdef _KERNEL
+void kpreempt_disable(void);
+void kpreempt_enable(void);
+bool kpreempt_disabled(void);
+#endif
+
+void assert_sleepable(void);
+#if defined(DEBUG)
+#define ASSERT_SLEEPABLE() assert_sleepable()
+#else /* defined(DEBUG) */
+#define ASSERT_SLEEPABLE() /* nothing */
+#endif /* defined(DEBUG) */
+
+vaddr_t calc_cache_size(struct vm_map *, int, int);
+
+#endif /* !_SYS_SYSTM_H_ */
--- /dev/null
+/* $NetBSD: tape.h,v 1.3 2005/12/26 18:41:36 perry Exp $ */
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Brett Lymn
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_TAPE_H_
+#define _SYS_TAPE_H_
+
+#include <sys/queue.h>
+
+#define TAPENAMELEN 16
+
+/* The following structure is 64-bit alignment safe */
+struct tape_sysctl {
+ char name[TAPENAMELEN];
+ int32_t busy;
+ int32_t pad;
+ uint64_t xfer;
+ uint64_t bytes;
+ uint32_t attachtime_sec;
+ uint32_t attachtime_usec;
+ uint32_t timestamp_sec;
+ uint32_t timestamp_usec;
+ uint32_t time_sec;
+ uint32_t time_usec;
+ uint64_t rxfer;
+ uint64_t rbytes;
+ uint64_t wxfer;
+ uint64_t wbytes;
+};
+
+/*
+ * Statistics for the tape device - in a separate structure so userland can
+ * see them.
+ */
+
+struct tape {
+ char *name; /* name of drive */
+ int busy; /* drive is busy */
+ uint64_t rxfer; /* total number of read transfers */
+ uint64_t wxfer; /* total number of write transfers */
+ uint64_t rbytes; /* total bytes read */
+ uint64_t wbytes; /* total bytes written */
+ struct timeval attachtime; /* time tape was attached */
+ struct timeval timestamp; /* timestamp of last unbusy */
+ struct timeval time; /* total time spent busy */
+
+ TAILQ_ENTRY(tape) link;
+};
+
+/* Head of the tape stats list, define here so userland can get at it */
+TAILQ_HEAD(tapelist_head, tape); /* the tapelist is a TAILQ */
+
+#endif
+
--- /dev/null
+/* $NetBSD: timeb.h,v 1.14 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)timeb.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_TIMEB_H_
+#define _SYS_TIMEB_H_
+
+/* The ftime(2) system call structure -- deprecated. */
+struct timeb {
+ time_t time; /* seconds since the Epoch */
+ unsigned short millitm; /* + milliseconds since the Epoch */
+ short timezone; /* minutes west of CUT */
+ short dstflag; /* DST == non-zero */
+};
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int ftime(struct timeb *);
+__END_DECLS
+#endif /* _KERNEL */
+
+
+#endif /* !_SYS_TIMEB_H_ */
--- /dev/null
+/* $NetBSD: timepps.h,v 1.20 2012/03/21 05:42:26 matt Exp $ */
+
+/*
+ * Copyright (c) 1998 Jonathan Stone
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jonathan Stone for
+ * the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_TIMEPPS_H_
+#define _SYS_TIMEPPS_H_
+
+/*
+ * This header file complies with "Pulse-Per-Second API for UNIX-like
+ * Operating Systems, Version 1.0", draft-mogul-pps-api-05.txt
+ */
+
+#include <sys/ioccom.h>
+
+#define PPS_API_VERS_1 1 /* API version number */
+
+/*
+ * PPSAPI type definitions
+ */
+typedef int32_t pps_handle_t; /* represents a PPS source */
+typedef uint32_t pps_seq_t; /* sequence number, at least 32 bits */
+
+typedef union pps_timeu {
+ struct timespec tspec;
+ struct { /* NTP long fixed-point format */
+ unsigned int integral;
+ unsigned int fractional;
+ } ntplfp;
+ unsigned long longpair[2];
+} pps_timeu_t;
+
+
+/*
+ * timestamp information
+ */
+typedef struct {
+ pps_seq_t assert_sequence; /* assert event seq # */
+ pps_seq_t clear_sequence; /* clear event seq # */
+ pps_timeu_t assert_tu;
+ pps_timeu_t clear_tu;
+ int current_mode; /* current mode bits */
+} pps_info_t;
+
+#define assert_timestamp assert_tu.tspec
+#define clear_timestamp clear_tu.tspec
+
+
+/*
+ * Parameter structure
+ */
+typedef struct {
+ int api_version; /* API version number */
+ int mode; /* mode bits */
+ pps_timeu_t assert_off_tu;
+ pps_timeu_t clear_off_tu;
+} pps_params_t;
+#define assert_offset assert_off_tu.tspec
+#define clear_offset clear_off_tu.tspec
+
+
+/*
+ * Device/implementation parameters (mode, edge bits)
+ */
+#define PPS_CAPTUREASSERT 0x01
+#define PPS_CAPTURECLEAR 0x02
+#define PPS_CAPTUREBOTH 0x03
+#define PPS_OFFSETASSERT 0x10
+#define PPS_OFFSETCLEAR 0x20
+#define PPS_CANWAIT 0x100
+#define PPS_CANPOLL 0x200
+
+/*
+ * Kernel actions
+ */
+#define PPS_ECHOASSERT 0x40
+#define PPS_ECHOCLEAR 0x80
+
+
+/*
+ * timestamp formats (tsformat, mode)
+ */
+#define PPS_TSFMT_TSPEC 0x1000
+#define PPS_TSFMT_NTPLFP 0x2000
+
+/*
+ * Kernel discipline actions (kernel_consumer)
+ */
+#define PPS_KC_HARDPPS 0
+#define PPS_KC_HARDPPS_PLL 1
+#define PPS_KC_HARDPPS_FLL 2
+
+/*
+ * IOCTL definitions
+ */
+#define PPS_IOC_CREATE _IO('1', 1)
+#define PPS_IOC_DESTROY _IO('1', 2)
+#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t)
+#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t)
+#define PPS_IOC_GETCAP _IOR('1', 5, int)
+#define PPS_IOC_FETCH _IOWR('1', 6, pps_info_t)
+#define PPS_IOC_KCBIND _IOW('1', 7, int)
+
+#ifdef _KERNEL
+
+#include <sys/mutex.h>
+
+extern kmutex_t timecounter_lock;
+
+struct pps_state {
+ /* Capture information. */
+ struct timehands *capth;
+ unsigned capgen;
+ u_int64_t capcount;
+
+ /* State information. */
+ pps_params_t ppsparam;
+ pps_info_t ppsinfo;
+ int kcmode;
+ int ppscap;
+ struct timecounter *ppstc;
+ u_int64_t ppscount[3];
+};
+
+void pps_capture(struct pps_state *);
+void pps_event(struct pps_state *, int);
+void pps_init(struct pps_state *);
+int pps_ioctl(unsigned long, void *, struct pps_state *);
+
+#else /* !_KERNEL */
+
+#include <sys/cdefs.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+static __inline int time_pps_create(int, pps_handle_t *);
+static __inline int time_pps_destroy(pps_handle_t);
+static __inline int time_pps_setparams(pps_handle_t, const pps_params_t *);
+static __inline int time_pps_getparams(pps_handle_t, pps_params_t *);
+static __inline int time_pps_getcap(pps_handle_t, int *);
+static __inline int time_pps_fetch(pps_handle_t, const int, pps_info_t *,
+ const struct timespec *);
+#if 0
+static __inline int time_pps_wait(pps_handle_t, const struct timespec *,
+ pps_info_t *);
+#endif
+
+static __inline int time_pps_kcbind(pps_handle_t, const int, const int,
+ const int);
+
+static __inline int
+time_pps_create(int filedes, pps_handle_t *handle)
+{
+
+ *handle = filedes;
+ return (0);
+}
+
+static __inline int
+time_pps_destroy(pps_handle_t handle)
+{
+
+ return (0);
+}
+
+static __inline int
+time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams)
+{
+
+ return (ioctl(handle, PPS_IOC_SETPARAMS, __UNCONST(ppsparams)));
+}
+
+static __inline int
+time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams)
+{
+
+ return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams));
+}
+
+static __inline int
+time_pps_getcap(pps_handle_t handle, int *mode)
+{
+
+ return (ioctl(handle, PPS_IOC_GETCAP, mode));
+}
+
+static __inline int
+time_pps_fetch(pps_handle_t handle, const int tsformat, pps_info_t *ppsinfobuf,
+ const struct timespec *timeout)
+{
+
+ return (ioctl(handle, PPS_IOC_FETCH, ppsinfobuf));
+}
+
+static __inline int
+time_pps_kcbind(pps_handle_t handle, const int kernel_consumer, const int edge,
+ const int tsformat)
+{
+
+ if (tsformat != PPS_TSFMT_TSPEC) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return (ioctl(handle, PPS_IOC_KCBIND, __UNCONST(&edge)));
+}
+#endif /* !_KERNEL*/
+#endif /* SYS_TIMEPPS_H_ */
--- /dev/null
+/* $NetBSD: timetc.h,v 1.6 2009/01/11 02:45:56 christos Exp $ */
+
+/*-
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD: src/sys/sys/timetc.h,v 1.58 2003/08/16 08:23:52 phk Exp $
+ */
+
+#ifndef _SYS_TIMETC_H_
+#define _SYS_TIMETC_H_
+
+#ifndef _KERNEL
+#error "no user-serviceable parts inside"
+#endif
+
+/*
+ * max recommended timecounter name length
+ *
+ * it is not a functional limit but names longer
+ * then that will not be controllable via
+ * sysctl. see kern/kern_tc.c for the sysctl
+ * implementation.
+ */
+#define MAX_TCNAMELEN 64
+
+/*-
+ * `struct timecounter' is the interface between the hardware which implements
+ * a timecounter and the MI code which uses this to keep track of time.
+ *
+ * A timecounter is a binary counter which has two properties:
+ * * it runs at a fixed, known frequency.
+ * * it has sufficient bits to not roll over in less than approximately
+ * max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta,
+ * for some indeterminate value of delta.)
+ */
+
+struct timecounter;
+typedef u_int timecounter_get_t(struct timecounter *);
+typedef void timecounter_pps_t(struct timecounter *);
+
+struct timecounter {
+ timecounter_get_t *tc_get_timecount;
+ /*
+ * This function reads the counter. It is not required to
+ * mask any unimplemented bits out, as long as they are
+ * constant.
+ */
+ timecounter_pps_t *tc_poll_pps;
+ /*
+ * This function is optional. It will be called whenever the
+ * timecounter is rewound, and is intended to check for PPS
+ * events. Normal hardware does not need it but timecounters
+ * which latch PPS in hardware (like sys/pci/xrpu.c) do.
+ */
+ u_int tc_counter_mask;
+ /* This mask should mask off any unimplemented bits. */
+ u_int64_t tc_frequency;
+ /* Frequency of the counter in Hz. */
+ const char *tc_name;
+ /* Name of the timecounter. */
+ int tc_quality;
+ /*
+ * Used to determine if this timecounter is better than
+ * another timecounter higher means better. Negative
+ * means "only use at explicit request".
+ */
+
+ void *tc_priv;
+ /* Pointer to the timecounter's private parts. */
+ struct timecounter *tc_next;
+ /* Pointer to the next timecounter. */
+};
+
+extern struct timecounter *timecounter;
+
+u_int64_t tc_getfrequency(void);
+void tc_init(struct timecounter *tc);
+int tc_detach(struct timecounter *);
+void tc_setclock(const struct timespec *ts);
+void tc_ticktock(void);
+void tc_gonebad(struct timecounter *);
+
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_kern_timecounter);
+#endif
+
+#endif /* !_SYS_TIMETC_H_ */
--- /dev/null
+/* $NetBSD: timevar.h,v 1.32 2012/10/02 01:44:29 christos Exp $ */
+
+/*
+ * Copyright (c) 2005, 2008 The NetBSD Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)time.h 8.5 (Berkeley) 5/4/95
+ */
+
+#ifndef _SYS_TIMEVAR_H_
+#define _SYS_TIMEVAR_H_
+
+#include <sys/callout.h>
+#include <sys/queue.h>
+#include <sys/signal.h>
+#include <sys/systm.h>
+
+/*
+ * Structure used to manage timers in a process.
+ */
+struct ptimer {
+ union {
+ callout_t pt_ch;
+ struct {
+ LIST_ENTRY(ptimer) pt_list;
+ int pt_active;
+ } pt_nonreal;
+ } pt_data;
+ struct sigevent pt_ev;
+ struct itimerspec pt_time;
+ struct ksiginfo pt_info;
+ int pt_overruns; /* Overruns currently accumulating */
+ int pt_poverruns; /* Overruns associated w/ a delivery */
+ int pt_type;
+ int pt_entry;
+ int pt_queued;
+ struct proc *pt_proc;
+ TAILQ_ENTRY(ptimer) pt_chain;
+};
+
+#define pt_ch pt_data.pt_ch
+#define pt_list pt_data.pt_nonreal.pt_list
+#define pt_active pt_data.pt_nonreal.pt_active
+
+#define TIMER_MAX 32 /* See ptimers->pts_fired if you enlarge this */
+#define TIMERS_ALL 0
+#define TIMERS_POSIX 1
+
+LIST_HEAD(ptlist, ptimer);
+
+struct ptimers {
+ struct ptlist pts_virtual;
+ struct ptlist pts_prof;
+ struct ptimer *pts_timers[TIMER_MAX];
+ int pts_fired;
+};
+
+/*
+ * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
+ *
+ * Functions without the "get" prefix returns the best timestamp
+ * we can produce in the given format.
+ *
+ * "bin" == struct bintime == seconds + 64 bit fraction of seconds.
+ * "nano" == struct timespec == seconds + nanoseconds.
+ * "micro" == struct timeval == seconds + microseconds.
+ *
+ * Functions containing "up" returns time relative to boot and
+ * should be used for calculating time intervals.
+ *
+ * Functions without "up" returns GMT time.
+ *
+ * Functions with the "get" prefix returns a less precise result
+ * much faster than the functions without "get" prefix and should
+ * be used where a precision of 1/HZ (eg 10 msec on a 100HZ machine)
+ * is acceptable or where performance is priority.
+ * (NB: "precision", _not_ "resolution" !)
+ *
+ */
+
+void binuptime(struct bintime *);
+void nanouptime(struct timespec *);
+void microuptime(struct timeval *);
+
+void bintime(struct bintime *);
+void nanotime(struct timespec *);
+void microtime(struct timeval *);
+
+void getbinuptime(struct bintime *);
+void getnanouptime(struct timespec *);
+void getmicrouptime(struct timeval *);
+
+void getbintime(struct bintime *);
+void getnanotime(struct timespec *);
+void getmicrotime(struct timeval *);
+
+/* Other functions */
+int abstimeout2timo(struct timespec *, int *);
+void adjtime1(const struct timeval *, struct timeval *, struct proc *);
+int clock_getres1(clockid_t, struct timespec *);
+int clock_gettime1(clockid_t, struct timespec *);
+int clock_settime1(struct proc *, clockid_t, const struct timespec *, bool);
+int dogetitimer(struct proc *, int, struct itimerval *);
+int dosetitimer(struct proc *, int, struct itimerval *);
+int dotimer_gettime(int, struct proc *, struct itimerspec *);
+int dotimer_settime(int, struct itimerspec *, struct itimerspec *, int,
+ struct proc *);
+int tshzto(const struct timespec *);
+int tshztoup(const struct timespec *);
+int tvhzto(const struct timeval *);
+void inittimecounter(void);
+int itimerfix(struct timeval *);
+int itimespecfix(struct timespec *);
+int ppsratecheck(struct timeval *, int *, int);
+int ratecheck(struct timeval *, const struct timeval *);
+void realtimerexpire(void *);
+int settime(struct proc *p, struct timespec *);
+int nanosleep1(struct lwp *, clockid_t, int, struct timespec *,
+ struct timespec *);
+int settimeofday1(const struct timeval *, bool,
+ const void *, struct lwp *, bool);
+int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t,
+ struct lwp *);
+void timer_gettime(struct ptimer *, struct itimerspec *);
+void timer_settime(struct ptimer *);
+struct ptimers *timers_alloc(struct proc *);
+void timers_free(struct proc *, int);
+void timer_tick(struct lwp *, bool);
+int tstohz(const struct timespec *);
+int tvtohz(const struct timeval *);
+int inittimeleft(struct timespec *, struct timespec *);
+int gettimeleft(struct timespec *, struct timespec *);
+void timerupcall(struct lwp *);
+void time_init(void);
+void time_init2(void);
+bool time_wraps(struct timespec *, struct timespec *);
+
+extern volatile time_t time_second; /* current second in the epoch */
+extern volatile time_t time_uptime; /* system uptime in seconds */
+
+#endif /* !_SYS_TIMEVAR_H_ */
--- /dev/null
+/* $NetBSD: timex.h,v 1.18 2009/04/05 19:59:26 christos Exp $ */
+
+/*-
+ ***********************************************************************
+ * *
+ * Copyright (c) David L. Mills 1993-2001 *
+ * *
+ * Permission to use, copy, modify, and distribute this software and *
+ * its documentation for any purpose and without fee is hereby *
+ * granted, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission *
+ * notice appear in supporting documentation, and that the name *
+ * University of Delaware not be used in advertising or publicity *
+ * pertaining to distribution of the software without specific, *
+ * written prior permission. The University of Delaware makes no *
+ * representations about the suitability this software for any *
+ * purpose. It is provided "as is" without express or implied *
+ * warranty. *
+ * *
+ **********************************************************************/
+
+/*
+ * Modification history timex.h
+ *
+ * 16 Aug 00 David L. Mills
+ * API Version 4. Added MOD_TAI and tai member of ntptimeval
+ * structure.
+ *
+ * 17 Nov 98 David L. Mills
+ * Revised for nanosecond kernel and user interface.
+ *
+ * 26 Sep 94 David L. Mills
+ * Added defines for hybrid phase/frequency-lock loop.
+ *
+ * 19 Mar 94 David L. Mills
+ * Moved defines from kernel routines to header file and added new
+ * defines for PPS phase-lock loop.
+ *
+ * 20 Feb 94 David L. Mills
+ * Revised status codes and structures for external clock and PPS
+ * signal discipline.
+ *
+ * 28 Nov 93 David L. Mills
+ * Adjusted parameters to improve stability and increase poll
+ * interval.
+ *
+ * 17 Sep 93 David L. Mills
+ * Created file
+ *
+ * $FreeBSD: src/sys/sys/timex.h,v 1.18 2005/01/07 02:29:24 imp Exp $
+ */
+/*
+ * This header file defines the Network Time Protocol (NTP) interfaces
+ * for user and daemon application programs. These are implemented using
+ * defined syscalls and data structures and require specific kernel
+ * support.
+ *
+ * The original precision time kernels developed from 1993 have an
+ * ultimate resolution of one microsecond; however, the most recent
+ * kernels have an ultimate resolution of one nanosecond. In these
+ * kernels, a ntp_adjtime() syscalls can be used to determine which
+ * resolution is in use and to select either one at any time. The
+ * resolution selected affects the scaling of certain fields in the
+ * ntp_gettime() and ntp_adjtime() syscalls, as described below.
+ *
+ * NAME
+ * ntp_gettime - NTP user application interface
+ *
+ * SYNOPSIS
+ * #include <sys/timex.h>
+ *
+ * int ntp_gettime(struct ntptimeval *ntv);
+ *
+ * DESCRIPTION
+ * The time returned by ntp_gettime() is in a timespec structure,
+ * but may be in either microsecond (seconds and microseconds) or
+ * nanosecond (seconds and nanoseconds) format. The particular
+ * format in use is determined by the STA_NANO bit of the status
+ * word returned by the ntp_adjtime() syscall.
+ *
+ * NAME
+ * ntp_adjtime - NTP daemon application interface
+ *
+ * SYNOPSIS
+ * #include <sys/timex.h>
+ * #include <sys/syscall.h>
+ *
+ * int syscall(SYS_ntp_adjtime, tptr);
+ * int SYS_ntp_adjtime;
+ * struct timex *tptr;
+ *
+ * DESCRIPTION
+ * Certain fields of the timex structure are interpreted in either
+ * microseconds or nanoseconds according to the state of the
+ * STA_NANO bit in the status word. See the description below for
+ * further information.
+ */
+
+#ifndef _SYS_TIMEX_H_
+#define _SYS_TIMEX_H_ 1
+#define NTP_API 4 /* NTP API version */
+
+#include <sys/syscall.h>
+
+/*
+ * The following defines establish the performance envelope of the
+ * kernel discipline loop. Phase or frequency errors greater than
+ * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals
+ * less than MINSEC, the loop always operates in PLL mode; while, for
+ * update intervals greater than MAXSEC, the loop always operates in FLL
+ * mode. Between these two limits the operating mode is selected by the
+ * STA_FLL bit in the status word.
+ */
+#define MAXPHASE 500000000L /* max phase error (ns) */
+#define MAXFREQ 500000L /* max freq error (ns/s) */
+#define MINSEC 256 /* min FLL update interval (s) */
+#define MAXSEC 2048 /* max PLL update interval (s) */
+#define NANOSECOND 1000000000L /* nanoseconds in one second */
+#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */
+#define MAXTC 10 /* max time constant */
+
+/*
+ * The following defines and structures define the user interface for
+ * the ntp_gettime() and ntp_adjtime() syscalls.
+ *
+ * Control mode codes (timex.modes)
+ */
+#define MOD_OFFSET 0x0001 /* set time offset */
+#define MOD_FREQUENCY 0x0002 /* set frequency offset */
+#define MOD_MAXERROR 0x0004 /* set maximum time error */
+#define MOD_ESTERROR 0x0008 /* set estimated time error */
+#define MOD_STATUS 0x0010 /* set clock status bits */
+#define MOD_TIMECONST 0x0020 /* set PLL time constant */
+#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */
+#define MOD_TAI 0x0080 /* set TAI offset */
+#define MOD_MICRO 0x1000 /* select microsecond resolution */
+#define MOD_NANO 0x2000 /* select nanosecond resolution */
+#define MOD_CLKB 0x4000 /* select clock B */
+#define MOD_CLKA 0x8000 /* select clock A */
+
+/*
+ * Status codes (timex.status)
+ */
+#define STA_PLL 0x0001 /* enable PLL updates (rw) */
+#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
+#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
+#define STA_FLL 0x0008 /* enable FLL mode (rw) */
+#define STA_INS 0x0010 /* insert leap (rw) */
+#define STA_DEL 0x0020 /* delete leap (rw) */
+#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
+#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
+#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
+#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
+#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
+#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
+#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
+#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
+#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
+#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
+
+#define STA_FMT "\177\020\
+b\0PLL\0\
+b\1PPSFREQ\0\
+b\2PPSTIME\0\
+b\3FLL\0\
+b\4INS\0\
+b\5DEL\0\
+b\6UNSYNC\0\
+b\7FREQHOLD\0\
+b\10PPSSIGNAL\0\
+b\11PPSJITTER\0\
+b\12PPSWANDER\0\
+b\13PPSERROR\0\
+b\14CLOCKERR\0\
+b\15NANO\0\
+f\16\1MODE\0=\0PLL\0=\1FLL\0\
+f\17\1CLK\0=\0A\0=\1B\0"
+
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+
+/*
+ * Clock states (time_state)
+ */
+#define TIME_OK 0 /* no leap second warning */
+#define TIME_INS 1 /* insert leap second warning */
+#define TIME_DEL 2 /* delete leap second warning */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occured */
+#define TIME_ERROR 5 /* error (see status word) */
+
+/*
+ * NTP user interface (ntp_gettime()) - used to read kernel clock values
+ *
+ * Note: The time member is in microseconds if STA_NANO is zero and
+ * nanoseconds if not.
+ */
+struct ntptimeval {
+ struct timespec time; /* current time (ns) (ro) */
+ long maxerror; /* maximum error (us) (ro) */
+ long esterror; /* estimated error (us) (ro) */
+ long tai; /* TAI offset */
+ int time_state; /* time status */
+};
+
+/*
+ * NTP daemon interface (ntp_adjtime()) - used to discipline CPU clock
+ * oscillator and determine status.
+ *
+ * Note: The offset, precision and jitter members are in microseconds if
+ * STA_NANO is zero and nanoseconds if not.
+ */
+struct timex {
+ unsigned int modes; /* clock mode bits (wo) */
+ long offset; /* time offset (ns/us) (rw) */
+ long freq; /* frequency offset (scaled PPM) (rw) */
+ long maxerror; /* maximum error (us) (rw) */
+ long esterror; /* estimated error (us) (rw) */
+ int status; /* clock status bits (rw) */
+ long constant; /* poll interval (log2 s) (rw) */
+ long precision; /* clock precision (ns/us) (ro) */
+ long tolerance; /* clock frequency tolerance (scaled
+ * PPM) (ro) */
+ /*
+ * The following read-only structure members are implemented
+ * only if the PPS signal discipline is configured in the
+ * kernel. They are included in all configurations to insure
+ * portability.
+ */
+ long ppsfreq; /* PPS frequency (scaled PPM) (ro) */
+ long jitter; /* PPS jitter (ns/us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long stabil; /* PPS stability (scaled PPM) (ro) */
+ long jitcnt; /* jitter limit exceeded (ro) */
+ long calcnt; /* calibration intervals (ro) */
+ long errcnt; /* calibration errors (ro) */
+ long stbcnt; /* stability limit exceeded (ro) */
+};
+
+#ifdef _KERNEL
+#include <sys/mutex.h>
+
+void ntp_update_second(int64_t *adjustment, time_t *newsec);
+void ntp_adjtime1(struct timex *);
+void ntp_gettime(struct ntptimeval *);
+int ntp_timestatus(void);
+
+extern kmutex_t timecounter_lock;
+#else /* !_KERNEL */
+
+__BEGIN_DECLS
+#ifndef __LIBC12_SOURCE__
+int ntp_gettime(struct ntptimeval *) __RENAME(__ntp_gettime50);
+#endif
+int ntp_adjtime(struct timex *);
+__END_DECLS
+#endif /* _KERNEL */
+
+#endif /* _SYS_TIMEX_H_ */
--- /dev/null
+/* $NetBSD: tprintf.h,v 1.18 2011/11/21 04:36:06 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tprintf.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_TPRINTF_H_
+#define _SYS_TPRINTF_H_
+
+typedef struct session *tpr_t;
+
+tpr_t tprintf_open(struct proc *);
+void tprintf_close(tpr_t);
+
+void tprintf(tpr_t, const char *fmt, ...) __printflike(2, 3);
+
+#endif /* _SYS_TPRINTF_H_ */
--- /dev/null
+/* $NetBSD: trace.h,v 1.11 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)trace.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_TRACE_H_
+#define _SYS_TRACE_H_
+
+/*
+ * File system buffer tracing points; all trace <pack(dev, size), bn>
+ */
+#define TR_BREADHIT 0 /* buffer read found in cache */
+#define TR_BREADMISS 1 /* buffer read not in cache */
+#define TR_BWRITE 2 /* buffer written */
+#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */
+#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */
+#define TR_XFODMISS 5 /* exe fod read */
+#define TR_XFODHIT 6 /* exe fod read */
+#define TR_BRELSE 7 /* brelse */
+#define TR_BREALLOC 8 /* expand/contract a buffer */
+
+/*
+ * Memory allocator trace points; all trace the amount of memory involved
+ */
+#define TR_MALL 10 /* memory allocated */
+
+/*
+ * Paging trace points: all are <vaddr, pid>
+ */
+#define TR_INTRANS 20 /* page intransit block */
+#define TR_EINTRANS 21 /* page intransit wait done */
+#define TR_FRECLAIM 22 /* reclaim from free list */
+#define TR_RECLAIM 23 /* reclaim from loop */
+#define TR_XSFREC 24 /* reclaim from free list instead of drum */
+#define TR_XIFREC 25 /* reclaim from free list instead of fsys */
+#define TR_WAITMEM 26 /* wait for memory in pagein */
+#define TR_EWAITMEM 27 /* end memory wait in pagein */
+#define TR_ZFOD 28 /* zfod page fault */
+#define TR_EXFOD 29 /* exec fod page fault */
+#define TR_VRFOD 30 /* vread fod page fault */
+#define TR_CACHEFOD 31 /* fod in file system cache */
+#define TR_SWAPIN 32 /* drum page fault */
+#define TR_PGINDONE 33 /* page in done */
+#define TR_SWAPIO 34 /* swap i/o request arrives */
+
+/*
+ * System call trace points.
+ */
+#define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */
+
+/*
+ * Miscellaneous
+ */
+#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */
+
+/*
+ * This defines the size of the trace flags array.
+ */
+#define TR_NFLAGS 100 /* generous */
+
+#define TRCSIZ 4096
+
+/*
+ * Specifications of the vtrace() system call, which takes one argument.
+ */
+#define VTRACE 64+51
+
+#define VTR_DISABLE 0 /* set a trace flag to 0 */
+#define VTR_ENABLE 1 /* set a trace flag to 1 */
+#define VTR_VALUE 2 /* return value of a trace flag */
+#define VTR_UALARM 3 /* set alarm to go off (sig 16) */
+ /* in specified number of hz */
+#define VTR_STAMP 4 /* user specified stamp */
+
+#ifdef _KERNEL
+#ifdef TRACE
+struct proc *traceproc;
+int tracewhich, tracebuf[TRCSIZ];
+u_int tracex;
+char traceflags[TR_NFLAGS];
+#define pack(v,b) (((v)->v_mount->mnt_stat.f_fsidx.__fsid_val[0])<<16)|(b)
+#define trace(a,b,c) { \
+ if (traceflags[a]) \
+ trace1(a,b,c); \
+}
+#else
+#define trace(a,b,c)
+#endif /* TRACE */
+#endif /* _KERNEL */
+
+#endif /* !_SYS_TRACE_H_ */
--- /dev/null
+/* $NetBSD: tty.h,v 1.90 2011/09/24 00:05:38 christos Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tty.h 8.7 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_TTY_H_
+#define _SYS_TTY_H_
+
+#include <sys/termios.h>
+#include <sys/select.h>
+#include <sys/selinfo.h> /* For struct selinfo. */
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/queue.h>
+#include <sys/callout.h>
+
+/*
+ * Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have
+ * exactly the same behaviour as in true clists.
+ * if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
+ * (but, saves memory and CPU time)
+ *
+ * *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!!
+ */
+struct clist {
+ u_char *c_cf; /* points to first character */
+ u_char *c_cl; /* points to next open character */
+ u_char *c_cs; /* start of ring buffer */
+ u_char *c_ce; /* c_ce + c_len */
+ u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
+ int c_cc; /* count of characters in queue */
+ int c_cn; /* total ring buffer length */
+};
+
+/* tty signal types */
+enum ttysigtype {
+ TTYSIG_PG1,
+ TTYSIG_PG2,
+ TTYSIG_LEADER,
+ TTYSIG_COUNT
+};
+
+/*
+ * Per-tty structure.
+ *
+ * Should be split in two, into device and tty drivers.
+ * Glue could be masks of what to echo and circular buffer
+ * (low, high, timeout).
+ */
+struct tty {
+ TAILQ_ENTRY(tty) tty_link; /* Link in global tty list. */
+ struct clist t_rawq; /* Device raw input queue. */
+ long t_rawcc; /* Raw input queue statistics. */
+ kcondvar_t t_rawcv; /* notifier */
+ kcondvar_t t_rawcvf; /* notifier */
+ struct clist t_canq; /* Device canonical queue. */
+ long t_cancc; /* Canonical queue statistics. */
+ kcondvar_t t_cancv; /* notifier */
+ kcondvar_t t_cancvf; /* notifier */
+ struct clist t_outq; /* Device output queue. */
+ long t_outcc; /* Output queue statistics. */
+ kcondvar_t t_outcv; /* notifier */
+ kcondvar_t t_outcvf; /* notifier */
+ callout_t t_rstrt_ch; /* for delayed output start */
+ struct linesw *t_linesw; /* Interface to device drivers. */
+ dev_t t_dev; /* Device. */
+ int t_state; /* Device and driver (TS*) state. */
+ int t_wopen; /* Processes waiting for open. */
+ int t_flags; /* Tty flags. */
+ int t_qsize; /* Tty character queue size */
+ struct pgrp *t_pgrp; /* Foreground process group. */
+ struct session *t_session; /* Enclosing session. */
+ struct selinfo t_rsel; /* Tty read/oob select. */
+ struct selinfo t_wsel; /* Tty write select. */
+ struct termios t_termios; /* Termios state. */
+ struct winsize t_winsize; /* Window size. */
+ /* Start output. */
+ void (*t_oproc)(struct tty *);
+ /* Set hardware state. */
+ int (*t_param)(struct tty *, struct termios *);
+ /* Set hardware flow control. */
+ int (*t_hwiflow)(struct tty *, int);
+ void *t_sc; /* XXX: net/if_sl.c:sl_softc. */
+ short t_column; /* Tty output column. */
+ short t_rocount, t_rocol; /* Tty. */
+ int t_hiwat; /* High water mark. */
+ int t_lowat; /* Low water mark. */
+ short t_gen; /* Generation number. */
+ sigset_t t_sigs[TTYSIG_COUNT]; /* Pending signals */
+ int t_sigcount; /* # pending signals */
+ TAILQ_ENTRY(tty) t_sigqueue; /* entry on pending signal list */
+};
+
+#define t_cc t_termios.c_cc
+#define t_cflag t_termios.c_cflag
+#define t_iflag t_termios.c_iflag
+#define t_ispeed t_termios.c_ispeed
+#define t_lflag t_termios.c_lflag
+#define t_oflag t_termios.c_oflag
+#define t_ospeed t_termios.c_ospeed
+
+#define TTIPRI 25 /* Sleep priority for tty reads. */
+#define TTOPRI 26 /* Sleep priority for tty writes. */
+
+#define TTMASK 15
+#define OBUFSIZ 100
+#define TTYHOG tp->t_qsize
+
+#ifdef _KERNEL
+#define TTMAXHIWAT roundup(tp->t_qsize << 1, 64)
+#define TTMINHIWAT roundup(tp->t_qsize >> 3, 64)
+#define TTMAXLOWAT (tp->t_qsize >> 2)
+#define TTMINLOWAT (tp->t_qsize >> 5)
+#define TTROUND 64
+#endif /* _KERNEL */
+
+/* These flags are kept in t_state. */
+#define TS_SIGINFO 0x00001 /* Ignore mask on dispatch SIGINFO */
+#define TS_ASYNC 0x00002 /* Tty in async I/O mode. */
+#define TS_BUSY 0x00004 /* Draining output. */
+#define TS_CARR_ON 0x00008 /* Carrier is present. */
+#define TS_DIALOUT 0x00010 /* Tty used for dialout. */
+#define TS_FLUSH 0x00020 /* Outq has been flushed during DMA. */
+#define TS_ISOPEN 0x00040 /* Open has completed. */
+#define TS_TBLOCK 0x00080 /* Further input blocked. */
+#define TS_TIMEOUT 0x00100 /* Wait for output char processing. */
+#define TS_TTSTOP 0x00200 /* Output paused. */
+#define TS_XCLUDE 0x00400 /* Tty requires exclusivity. */
+
+/* State for intra-line fancy editing work. */
+#define TS_BKSL 0x00800 /* State for lowercase \ work. */
+#define TS_CNTTB 0x01000 /* Counting tab width, ignore FLUSHO. */
+#define TS_ERASE 0x02000 /* Within a \.../ for PRTRUB. */
+#define TS_LNCH 0x04000 /* Next character is literal. */
+#define TS_TYPEN 0x08000 /* Retyping suspended input (PENDIN). */
+#define TS_LOCAL (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN)
+
+/* Character type information. */
+#define ORDINARY 0
+#define CONTROL 1
+#define BACKSPACE 2
+#define NEWLINE 3
+#define TAB 4
+#define VTAB 5
+#define RETURN 6
+
+struct speedtab {
+ int sp_speed; /* Speed. */
+ int sp_code; /* Code. */
+};
+
+/* Modem control commands (driver). */
+#define DMSET 0
+#define DMBIS 1
+#define DMBIC 2
+#define DMGET 3
+
+/* Flags on a character passed to ttyinput. */
+#define TTY_CHARMASK 0x000000ff /* Character mask */
+#define TTY_QUOTE 0x00000100 /* Character quoted */
+#define TTY_ERRORMASK 0xff000000 /* Error mask */
+#define TTY_FE 0x01000000 /* Framing error or BREAK condition */
+#define TTY_PE 0x02000000 /* Parity error */
+
+/* Is tp controlling terminal for p? */
+#define isctty(p, tp) \
+ ((p)->p_session == (tp)->t_session && (p)->p_lflag & PL_CONTROLT)
+
+/* Is p in background of tp? */
+#define isbackground(p, tp) \
+ (isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp)
+
+/*
+ * ttylist_head is defined here so that user-land has access to it.
+ */
+TAILQ_HEAD(ttylist_head, tty); /* the ttylist is a TAILQ */
+
+#ifdef _KERNEL
+
+extern kmutex_t tty_lock;
+
+extern int tty_count; /* number of ttys in global ttylist */
+extern struct ttychars ttydefaults;
+
+/* Symbolic sleep message strings. */
+extern const char ttclos[];
+
+int b_to_q(const u_char *, int, struct clist *);
+void catq(struct clist *, struct clist *);
+void clist_init(void);
+int getc(struct clist *);
+void ndflush(struct clist *, int);
+int ndqb(struct clist *, int);
+u_char *nextc(struct clist *, u_char *, int *);
+int putc(int, struct clist *);
+int q_to_b(struct clist *, u_char *, int);
+int unputc(struct clist *);
+
+int nullmodem(struct tty *, int);
+int tputchar(int, int, struct tty *);
+int ttioctl(struct tty *, u_long, void *, int, struct lwp *);
+int ttread(struct tty *, struct uio *, int);
+void ttrstrt(void *);
+int ttpoll(struct tty *, int, struct lwp *);
+void ttsetwater(struct tty *);
+int ttspeedtab(int, const struct speedtab *);
+int ttstart(struct tty *);
+void ttwakeup(struct tty *);
+int ttwrite(struct tty *, struct uio *, int);
+void ttychars(struct tty *);
+int ttycheckoutq(struct tty *, int);
+int ttyclose(struct tty *);
+void ttyflush(struct tty *, int);
+void ttygetinfo(struct tty *, int, char *, size_t);
+void ttyputinfo(struct tty *, char *);
+int ttyinput(int, struct tty *);
+int ttyinput_wlock(int, struct tty *); /* XXX see wsdisplay.c */
+int ttylclose(struct tty *, int);
+int ttylopen(dev_t, struct tty *);
+int ttykqfilter(dev_t, struct knote *);
+int ttymodem(struct tty *, int);
+int ttyopen(struct tty *, int, int);
+int ttyoutput(int, struct tty *);
+void ttypend(struct tty *);
+void ttyretype(struct tty *);
+void ttyrub(int, struct tty *);
+int ttysleep(struct tty *, kcondvar_t *, bool, int);
+int ttypause(struct tty *, int);
+int ttywait(struct tty *);
+int ttywflush(struct tty *);
+void ttysig(struct tty *, enum ttysigtype, int);
+void tty_attach(struct tty *);
+void tty_detach(struct tty *);
+void tty_init(void);
+struct tty
+ *tty_alloc(void);
+void tty_free(struct tty *);
+u_char *firstc(struct clist *, int *);
+bool ttypull(struct tty *);
+
+int clalloc(struct clist *, int, int);
+void clfree(struct clist *);
+
+extern int (*ttcompatvec)(struct tty *, u_long, void *, int, struct lwp *);
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_TTY_H_ */
--- /dev/null
+/* $NetBSD: ttychars.h,v 1.9 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ttychars.h 8.2 (Berkeley) 1/4/94
+ */
+
+/*
+ * 4.3 COMPATIBILITY FILE
+ *
+ * User visible structures and constants related to terminal handling.
+ */
+#ifndef _SYS_TTYCHARS_H_
+#define _SYS_TTYCHARS_H_
+
+struct ttychars {
+ char tc_erase; /* erase last character */
+ char tc_kill; /* erase entire line */
+ char tc_intrc; /* interrupt */
+ char tc_quitc; /* quit */
+ char tc_startc; /* start output */
+ char tc_stopc; /* stop output */
+ char tc_eofc; /* end-of-file */
+ char tc_brkc; /* input delimiter (like nl) */
+ char tc_suspc; /* stop process signal */
+ char tc_dsuspc; /* delayed stop process signal */
+ char tc_rprntc; /* reprint line */
+ char tc_flushc; /* flush output (toggles) */
+ char tc_werasc; /* word erase */
+ char tc_lnextc; /* literal next character */
+};
+#endif /* !_SYS_TTYCHARS_H_ */
+
+#ifdef USE_OLD_TTY
+#include <sys/ttydefaults.h> /* to pick up character defaults */
+#endif
--- /dev/null
+/* $NetBSD: ttydev.h,v 1.9 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ttydev.h 8.2 (Berkeley) 1/4/94
+ */
+
+/* COMPATABILITY HEADER FILE */
+
+#ifndef _SYS_TTYDEV_H_
+#define _SYS_TTYDEV_H_
+
+#ifdef USE_OLD_TTY
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define EXTA 14
+#define EXTB 15
+#define B57600 16
+#define B115200 17
+#endif /* USE_OLD_TTY */
+
+#endif /* !_SYS_TTYDEV_H_ */
--- /dev/null
+/* $NetBSD: uidinfo.h,v 1.3 2012/06/09 02:31:15 christos Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_UIDINFO_H_
+#define _SYS_UIDINFO_H_
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/mutex.h>
+
+/*
+ * Structure associated with user caching.
+ */
+struct uidinfo {
+ SLIST_ENTRY(uidinfo) ui_hash;
+ uid_t ui_uid;
+ u_long ui_proccnt; /* Number of processes */
+ u_long ui_lwpcnt; /* Number of lwps */
+ u_long ui_lockcnt; /* Number of locks */
+ u_long ui_sbsize; /* Socket buffer size */
+};
+
+int chgproccnt(uid_t, int);
+int chglwpcnt(uid_t, int);
+int chgsbsize(struct uidinfo *, u_long *, u_long, rlim_t);
+struct uidinfo *uid_find(uid_t);
+void uid_init(void);
+
+#endif /* _SYS_UIDINFO_H_ */
--- /dev/null
+/* $NetBSD: unpcb.h,v 1.17 2008/04/24 11:38:39 ad Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)unpcb.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_UNPCB_H_
+#define _SYS_UNPCB_H_
+
+#include <sys/un.h>
+#include <sys/mutex.h>
+
+/*
+ * Protocol control block for an active
+ * instance of a UNIX internal protocol.
+ *
+ * A socket may be associated with an vnode in the
+ * file system. If so, the unp_vnode pointer holds
+ * a reference count to this vnode, which should be irele'd
+ * when the socket goes away.
+ *
+ * A socket may be connected to another socket, in which
+ * case the control block of the socket to which it is connected
+ * is given by unp_conn.
+ *
+ * A socket may be referenced by a number of sockets (e.g. several
+ * sockets may be connected to a datagram socket.) These sockets
+ * are in a linked list starting with unp_refs, linked through
+ * unp_nextref and null-terminated. Note that a socket may be referenced
+ * by a number of other sockets and may also reference a socket (not
+ * necessarily one which is referencing it). This generates
+ * the need for unp_refs and unp_nextref to be separate fields.
+ *
+ * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
+ * so that changes in the sockbuf may be computed to modify
+ * back pressure on the sender accordingly.
+ *
+ * The unp_ctime holds the creation time of the socket: it might be part of
+ * a socketpair created by pipe(2), and POSIX requires pipe(2) to initialize
+ * a stat structure's st_[acm]time members with the pipe's creation time.
+ * N.B.: updating st_[am]time when reading/writing the pipe is not required,
+ * so we just use a single timespec and do not implement that.
+ */
+struct unpcb {
+ struct socket *unp_socket; /* pointer back to socket */
+ struct vnode *unp_vnode; /* if associated with file */
+ ino_t unp_ino; /* fake inode number */
+ struct unpcb *unp_conn; /* control block of connected socket */
+ struct unpcb *unp_refs; /* referencing socket linked list */
+ struct unpcb *unp_nextref; /* link in unp_refs list */
+ struct sockaddr_un *unp_addr; /* bound address of socket */
+ kmutex_t *unp_streamlock; /* lock for est. stream connections */
+ size_t unp_addrlen; /* size of socket address */
+ int unp_cc; /* copy of rcv.sb_cc */
+ int unp_mbcnt; /* copy of rcv.sb_mbcnt */
+ struct timespec unp_ctime; /* holds creation time */
+ int unp_flags; /* misc flags; see below*/
+ struct unpcbid unp_connid; /* pid and eids of peer */
+};
+
+/*
+ * Flags in unp_flags.
+ *
+ * UNP_EIDSVALID - indicates that the unp_connid member is filled in
+ * and is really the effective ids of the connected peer. This is used
+ * to determine whether the contents should be sent to the user or
+ * not.
+ *
+ * UNP_EIDSBIND - indicates that the unp_connid member is filled
+ * in with data for the listening process. This is set up in unp_bind() when
+ * it fills in unp_connid for later consumption by unp_connect().
+ */
+#define UNP_WANTCRED 0x0001 /* credentials wanted */
+#define UNP_CONNWAIT 0x0002 /* connect blocks until accepted */
+#define UNP_EIDSVALID 0x0004 /* unp_connid contains valid data */
+#define UNP_EIDSBIND 0x0008 /* unp_connid was set by bind() */
+#define UNP_BUSY 0x0010 /* busy connecting or binding */
+
+#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
+
+#endif /* !_SYS_UNPCB_H_ */
--- /dev/null
+/* $NetBSD: user.h,v 1.18 2011/01/14 02:06:34 rmind Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)user.h 8.2 (Berkeley) 9/23/93
+ */
+
+#ifndef _SYS_USER_H_
+#define _SYS_USER_H_
+
+#ifdef _KERNEL
+#error "This header has been obsoleted and will be removed."
+#endif
+
+#include <machine/pcb.h>
+
+struct user {
+ struct pcb u_pcb;
+};
+
+#endif /* !_SYS_USER_H_ */
--- /dev/null
+/* $NetBSD: userconf.h,v 1.7 2011/05/31 23:28:53 dyoung Exp $ */
+
+/*-
+ * Copyright (c) 2001, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_USERCONF_H_
+#define _SYS_USERCONF_H_
+
+#include <sys/cpu.h>
+
+void userconf_bootinfo(void);
+void userconf_init(void);
+void userconf_prompt(void);
+int userconf_parse(char *);
+
+#endif /* !_SYS_USERCONF_H_ */
--- /dev/null
+/* $NetBSD: userret.h,v 1.25 2012/02/19 21:07:00 rmind Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2000, 2003, 2006, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum, and Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _SYS_USERRET_H_
+#define _SYS_USERRET_H_
+
+#include <sys/lockdebug.h>
+#include <sys/userret.h>
+#include <sys/intr.h>
+
+/*
+ * Define the MI code needed before returning to user mode, for
+ * trap and syscall.
+ */
+static __inline void
+mi_userret(struct lwp *l)
+{
+#ifndef __HAVE_PREEMPTION
+ struct cpu_info *ci;
+#endif
+
+ KASSERT(l->l_blcnt == 0);
+#ifndef __HAVE_PREEMPTION
+ KASSERT(curcpu()->ci_biglock_count == 0);
+#endif
+
+ /*
+ * Handle "exceptional" events: pending signals, stop/exit actions,
+ * etc. Note that the event must be flagged BEFORE any AST is
+ * posted as we are reading unlocked.
+ */
+#ifdef __HAVE_PREEMPTION
+ if (__predict_false(l->l_flag & LW_USERRET)) {
+ lwp_userret(l);
+ }
+ l->l_kpriority = false;
+ /*
+ * cpu_set_curpri(prio) is a MD optimized version of:
+ *
+ * kpreempt_disable();
+ * curcpu()->ci_schedstate.spc_curpriority = prio;
+ * kpreempt_enable();
+ */
+ cpu_set_curpri(l->l_priority); /* XXX this needs to die */
+#else
+ ci = l->l_cpu;
+ if (((l->l_flag & LW_USERRET) | ci->ci_data.cpu_softints) != 0) {
+ lwp_userret(l);
+ ci = l->l_cpu;
+ }
+ l->l_kpriority = false;
+ ci->ci_schedstate.spc_curpriority = l->l_priority;
+#endif
+
+ LOCKDEBUG_BARRIER(NULL, 0);
+ KASSERT(l->l_nopreempt == 0);
+}
+
+#endif /* !_SYS_USERRET_H_ */
--- /dev/null
+/* $NetBSD: vadvise.h,v 1.10 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vadvise.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_VADVISE_H_
+#define _SYS_VADVISE_H_
+
+/*
+ * Parameters to vadvise() to tell system of particular paging
+ * behaviour:
+ * VA_NORM Normal strategy
+ * VA_ANOM Sampling page behaviour is not a win, don't bother
+ * Suitable during GCs in LISP, or sequential or random
+ * page referencing.
+ * VA_SEQL Sequential behaviour expected.
+ * VA_FLUSH Invalidate all page table entries.
+ */
+#define VA_NORM 0
+#define VA_ANOM 1
+#define VA_SEQL 2
+#define VA_FLUSH 3
+
+#ifndef _KERNEL
+__BEGIN_DECLS
+int vadvise(int);
+__END_DECLS
+#endif
+
+#endif /* !_SYS_VADVISE_H_ */
--- /dev/null
+/* $NetBSD: verified_exec.h,v 1.58 2010/11/19 06:44:34 dholland Exp $ */
+
+/*-
+ * Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
+ * Copyright (c) 2005, 2006 Brett Lymn <blymn@NetBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the authors may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VERIFIED_EXEC_H_
+#define _SYS_VERIFIED_EXEC_H_
+
+#include <sys/ioccom.h>
+
+#if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H)
+#include <sys/types.h>
+#include <prop/proplib.h>
+
+struct mount;
+struct vnode;
+
+#ifdef notyet
+struct vm_page;
+#endif /* notyet */
+#endif /* _KERNEL */
+
+/* Flags for a Veriexec entry. These can be OR'd together. */
+#define VERIEXEC_DIRECT 0x01 /* Direct execution (exec) */
+#define VERIEXEC_INDIRECT 0x02 /* Indirect execution (#!) */
+#define VERIEXEC_FILE 0x04 /* Plain file (open) */
+#define VERIEXEC_UNTRUSTED 0x10 /* Untrusted storage */
+
+/* Operations for the Veriexec pseudo-device. */
+#define VERIEXEC_LOAD _IOW('X', 0x1, struct plistref)
+#define VERIEXEC_TABLESIZE _IOW('X', 0x2, struct plistref)
+#define VERIEXEC_DELETE _IOW('X', 0x3, struct plistref)
+#define VERIEXEC_QUERY _IOWR('X', 0x4, struct plistref)
+#define VERIEXEC_DUMP _IOR('X', 0x5, struct plistref)
+#define VERIEXEC_FLUSH _IO('X', 0x6)
+
+/* Veriexec modes (strict levels). */
+#define VERIEXEC_LEARNING 0 /* Learning mode. */
+#define VERIEXEC_IDS 1 /* Intrusion detection mode. */
+#define VERIEXEC_IPS 2 /* Intrusion prevention mode. */
+#define VERIEXEC_LOCKDOWN 3 /* Lockdown mode. */
+
+/* Valid status field values. */
+#define FINGERPRINT_NOTEVAL 0 /* fingerprint has not been evaluated */
+#define FINGERPRINT_VALID 1 /* fingerprint evaluated and matches list */
+#define FINGERPRINT_NOMATCH 2 /* fingerprint evaluated but does not match */
+
+/* Per-page fingerprint status. */
+#define PAGE_FP_NONE 0 /* no per-page fingerprints. */
+#define PAGE_FP_READY 1 /* per-page fingerprints ready for use. */
+#define PAGE_FP_FAIL 2 /* mismatch in per-page fingerprints. */
+
+#if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H)
+
+#if NVERIEXEC > 0
+/* FUTURE: remove this macro entirely - dholland 20100215 */
+#define VERIEXEC_PATH_GET(from, cto, to) \
+ do { \
+ to = NULL; \
+ cto = from; \
+ } \
+ } while (/*CONSTCOND*/0)
+#define VERIEXEC_PATH_PUT(to) \
+ do { \
+ (void)(to); \
+ } while (/*CONSTCOND*/0)
+#else
+#define VERIEXEC_PATH_GET(from, cto, to) \
+ cto = from
+#define VERIEXEC_PATH_PUT(to) \
+ (void)to
+
+#endif
+
+/*
+ * Fingerprint operations vector for Veriexec.
+ * Function types: init, update, final.
+ */
+typedef void (*veriexec_fpop_init_t)(void *);
+typedef void (*veriexec_fpop_update_t)(void *, u_char *, u_int);
+typedef void (*veriexec_fpop_final_t)(u_char *, void *);
+
+void veriexec_init(void);
+int veriexec_fpops_add(const char *, size_t, size_t, veriexec_fpop_init_t,
+ veriexec_fpop_update_t, veriexec_fpop_final_t);
+int veriexec_file_add(struct lwp *, prop_dictionary_t);
+int veriexec_verify(struct lwp *, struct vnode *, const u_char *, int,
+ bool *);
+#ifdef notyet
+int veriexec_page_verify(struct veriexec_file_entry *, struct vm_page *,
+ size_t, struct lwp *);
+#endif /* notyet */
+bool veriexec_lookup(struct vnode *);
+int veriexec_file_delete(struct lwp *, struct vnode *);
+int veriexec_table_delete(struct lwp *, struct mount *);
+int veriexec_convert(struct vnode *, prop_dictionary_t);
+int veriexec_dump(struct lwp *, prop_array_t);
+int veriexec_flush(struct lwp *);
+void veriexec_purge(struct vnode *);
+int veriexec_removechk(struct lwp *, struct vnode *, const char *);
+int veriexec_renamechk(struct lwp *, struct vnode *, const char *,
+ struct vnode *, const char *);
+int veriexec_unmountchk(struct mount *);
+int veriexec_openchk(struct lwp *, struct vnode *, const char *, int);
+#endif /* _KERNEL */
+
+#endif /* !_SYS_VERIFIED_EXEC_H_ */
--- /dev/null
+/* $NetBSD: vfs_syscalls.h,v 1.18 2012/03/13 18:41:02 elad Exp $ */
+
+/*
+ * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VFS_SYSCALLS_H_
+#define _SYS_VFS_SYSCALLS_H_
+
+#include <sys/types.h>
+#include <sys/fstypes.h>
+
+struct stat;
+struct statvfs;
+struct quotactl_args;
+
+/*
+ * syscall helpers for compat code.
+ */
+
+/* Status functions to kernel 'struct stat' buffers */
+int do_sys_stat(const char *, unsigned int, struct stat *);
+int do_fhstat(struct lwp *, const void *, size_t, struct stat *);
+int do_fhstatvfs(struct lwp *, const void *, size_t, struct statvfs *, int);
+
+/* VFS status functions to kernel buffers */
+int do_sys_pstatvfs(struct lwp *, const char *, int, struct statvfs *);
+int do_sys_fstatvfs(struct lwp *, int, int, struct statvfs *);
+/* VFS status - call copyfn() for each entry */
+int do_sys_getvfsstat(struct lwp *, void *, size_t, int, int (*)(const void *, void *, size_t), size_t, register_t *);
+
+int do_sys_utimes(struct lwp *, struct vnode *, const char *, int,
+ const struct timeval *, enum uio_seg);
+int do_sys_utimens(struct lwp *, struct vnode *, const char *, int flag,
+ const struct timespec *, enum uio_seg);
+
+int vfs_copyinfh_alloc(const void *, size_t, fhandle_t **);
+void vfs_copyinfh_free(fhandle_t *);
+
+int dofhopen(struct lwp *, const void *, size_t, int, register_t *);
+
+int do_sys_unlink(const char *, enum uio_seg);
+int do_sys_rename(const char *, const char *, enum uio_seg, int);
+int do_sys_mknod(struct lwp *, const char *, mode_t, dev_t, register_t *,
+ enum uio_seg);
+int do_sys_mkdir(const char *, mode_t, enum uio_seg);
+int do_sys_symlink(const char *, const char *, enum uio_seg);
+int do_sys_quotactl(const char *, const struct quotactl_args *);
+void do_sys_sync(struct lwp *);
+
+int chdir_lookup(const char *, int, struct vnode **, struct lwp *);
+void change_root(struct cwdinfo *, struct vnode *, struct lwp *);
+
+#endif /* _SYS_VFS_SYSCALLS_H_ */
--- /dev/null
+/* $NetBSD: videoio.h,v 1.8 2011/08/13 02:49:06 jakllsch Exp $ */
+
+/*-
+ * Copyright (c) 2005, 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications */
+
+#ifndef _HAVE_SYS_VIDEOIO_H
+#define _HAVE_SYS_VIDEOIO_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+#ifdef _KERNEL
+#include <compat/sys/time.h>
+#endif
+
+#ifndef _KERNEL
+#define __u64 uint64_t
+#define __u32 uint32_t
+#define __u16 uint16_t
+#define __u8 uint8_t
+#define __s64 int64_t
+#define __s32 int32_t
+#define __s16 int16_t
+#define __s8 int8_t
+#endif
+
+typedef uint64_t v4l2_std_id;
+#define v4l2_fourcc(a,b,c,d) (((uint32_t)(a) << 0) | \
+ ((uint32_t)(b) << 8) | \
+ ((uint32_t)(c) << 16) | \
+ ((uint32_t)(d) << 24))
+#if 0
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
+#define V4L2_CTRL_ID2CLASS(id) ((id >> 16) & 0xfff)
+#define V4L2_CTRL_ID2CID(id) (id & 0xffff)
+
+enum v4l2_colorspace {
+ V4L2_COLORSPACE_SMPTE170M = 1,
+ V4L2_COLORSPACE_SMPTE240M,
+ V4L2_COLORSPACE_REC709,
+ V4L2_COLORSPACE_BT878,
+ V4L2_COLORSPACE_470_SYSTEM_M,
+ V4L2_COLORSPACE_470_SYSTEM_BG,
+ V4L2_COLORSPACE_JPEG,
+ V4L2_COLORSPACE_SRGB
+};
+
+enum v4l2_field {
+ V4L2_FIELD_ANY = 0,
+ V4L2_FIELD_NONE,
+ V4L2_FIELD_TOP,
+ V4L2_FIELD_BOTTOM,
+ V4L2_FIELD_INTERLACED,
+ V4L2_FIELD_SEQ_TB,
+ V4L2_FIELD_SEQ_BT,
+ V4L2_FIELD_ALTERNATE
+};
+
+enum v4l2_buf_type {
+ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT,
+ V4L2_BUF_TYPE_VIDEO_OVERLAY,
+ V4L2_BUF_TYPE_VBI_CAPTURE,
+ V4L2_BUF_TYPE_VBI_OUTPUT,
+ V4L2_BUF_TYPE_PRIVATE = 0x80
+};
+
+enum v4l2_memory {
+ V4L2_MEMORY_MMAP = 1,
+ V4L2_MEMORY_USERPTR,
+ V4L2_MEMORY_OVERLAY
+};
+
+enum v4l2_priority {
+ V4L2_PRIORITY_UNSET = 0,
+ V4L2_PRIORITY_BACKGROUND,
+ V4L2_PRIORITY_INTERACTIVE,
+ V4L2_PRIORITY_RECORD,
+ V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE
+};
+
+enum v4l2_tuner_type {
+ V4L2_TUNER_RADIO = 1,
+ V4L2_TUNER_ANALOG_TV
+};
+
+enum v4l2_ctrl_type {
+ V4L2_CTRL_TYPE_INTEGER = 1,
+ V4L2_CTRL_TYPE_BOOLEAN,
+ V4L2_CTRL_TYPE_MENU,
+ V4L2_CTRL_TYPE_BUTTON
+};
+
+struct v4l2_timecode {
+ uint32_t type;
+ uint32_t flags;
+ uint8_t frames;
+ uint8_t seconds;
+ uint8_t minutes;
+ uint8_t hours;
+ uint8_t userbits[4];
+};
+
+struct v4l2_pix_format {
+ uint32_t width;
+ uint32_t height;
+ uint32_t pixelformat;
+ enum v4l2_field field;
+ uint32_t bytesperline;
+ uint32_t sizeimage;
+ enum v4l2_colorspace colorspace;
+ uint32_t priv;
+};
+
+struct v4l2_buffer {
+ uint32_t index;
+ enum v4l2_buf_type type;
+ uint32_t bytesused;
+ uint32_t flags;
+ enum v4l2_field field;
+ struct timeval timestamp;
+ struct v4l2_timecode timecode;
+ uint32_t sequence;
+ enum v4l2_memory memory;
+ union {
+ uint32_t offset;
+ unsigned long userptr;
+ } m;
+ uint32_t length;
+ uint32_t input;
+ uint32_t reserved;
+};
+
+#ifdef _KERNEL
+struct v4l2_buffer50 {
+ uint32_t index;
+ enum v4l2_buf_type type;
+ uint32_t bytesused;
+ uint32_t flags;
+ enum v4l2_field field;
+ struct timeval50 timestamp;
+ struct v4l2_timecode timecode;
+ uint32_t sequence;
+ enum v4l2_memory memory;
+ union {
+ uint32_t offset;
+ unsigned long userptr;
+ } m;
+ uint32_t length;
+ uint32_t input;
+ uint32_t reserved;
+};
+
+#endif
+struct v4l2_rect {
+ int32_t left;
+ int32_t top;
+ int32_t width;
+ int32_t height;
+};
+
+struct v4l2_fract {
+ uint32_t numerator;
+ uint32_t denominator;
+};
+
+struct v4l2_fmtdesc {
+ uint32_t index;
+ enum v4l2_buf_type type;
+ uint32_t flags;
+ uint8_t description[32];
+ uint32_t pixelformat;
+ uint32_t reserved[4];
+};
+
+struct v4l2_clip {
+ struct v4l2_rect c;
+ struct v4l2_clip *next;
+};
+
+struct v4l2_window {
+ struct v4l2_rect w;
+ enum v4l2_field field;
+ uint32_t chromakey;
+ struct v4l2_clip *clips;
+ uint32_t clipcount;
+ void *bitmap;
+};
+
+struct v4l2_vbi_format {
+ uint32_t sampling_rate;
+ uint32_t offset;
+ uint32_t samples_per_line;
+ uint32_t sample_format;
+ uint32_t start[2];
+ uint32_t count[2];
+ uint32_t flags;
+ uint32_t reserved[2];
+};
+
+/* In the API docs, but not the Linux implementation
+ *
+ * struct v4l2_sliced_vbi_format {
+ * uint32_t service_set;
+ * uint32_t packet_size;
+ * uint32_t io_size;
+ * uint32_t reserved;
+ * };
+ *
+ *
+ * struct v4l2_sliced_data {
+ * uint32_t id;
+ * uint32_t line;
+ * uint8_t data[];
+ * };
+ */
+
+struct v4l2_cropcap {
+ enum v4l2_buf_type type;
+ struct v4l2_rect bounds;
+ struct v4l2_rect defrect;
+ struct v4l2_fract pixelaspect;
+};
+
+struct v4l2_input {
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t type;
+ uint32_t audioset;
+ uint32_t tuner;
+ v4l2_std_id std;
+ uint32_t status;
+ uint32_t reserved[4];
+};
+
+struct v4l2_output {
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t type;
+ uint32_t audioset;
+ uint32_t modulator;
+ v4l2_std_id std;
+ uint32_t reserved[4];
+};
+
+struct v4l2_audio {
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t capability;
+ uint32_t mode;
+ uint32_t reserved[2];
+};
+
+struct v4l2_audioout {
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t capability;
+ uint32_t mode;
+ uint32_t reserved[2];
+};
+
+struct v4l2_compression {
+ uint32_t quality;
+ uint32_t keyframerate;
+ uint32_t pframerate;
+ uint32_t reserved[5];
+};
+
+struct v4l2_crop {
+ enum v4l2_buf_type type;
+ struct v4l2_rect c;
+};
+
+struct v4l2_control {
+ uint32_t id;
+ int32_t value;
+};
+
+struct v4l2_framebuffer {
+ uint32_t capability;
+ uint32_t flags;
+ void *base;
+ struct v4l2_pix_format fmt;
+};
+
+struct v4l2_standard {
+ uint32_t index;
+ v4l2_std_id id;
+ uint8_t name[24];
+ struct v4l2_fract frameperiod;
+ uint32_t framelines;
+ uint32_t reserved[4];
+};
+
+struct v4l2_format {
+ enum v4l2_buf_type type;
+ union {
+ struct v4l2_pix_format pix;
+ struct v4l2_window win;
+ struct v4l2_vbi_format vbi;
+ uint8_t raw_data[200];
+ } fmt;
+};
+
+struct v4l2_frequency {
+ uint32_t tuner;
+ enum v4l2_tuner_type type;
+ uint32_t frequency;
+ uint32_t reserved[8];
+};
+
+struct v4l2_jpegcompression {
+ int quality;
+ int APPn;
+ int APP_len;
+ char APP_data[60];
+ int COM_len;
+ char COM_data[60];
+ uint32_t jpeg_markers;
+};
+
+struct v4l2_modulator {
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t capability;
+ uint32_t rangelow;
+ uint32_t rangehigh;
+ uint32_t txsubchans;
+ uint32_t reserved[4];
+};
+
+struct v4l2_captureparm {
+ uint32_t capability;
+ uint32_t capturemode;
+ struct v4l2_fract timeperframe;
+ uint32_t extendedmode;
+ uint32_t readbuffers;
+ uint32_t reserved[4];
+};
+
+struct v4l2_outputparm {
+ uint32_t capability;
+ uint32_t outputmode;
+ struct v4l2_fract timeperframe;
+ uint32_t extendedmode;
+ uint32_t writebuffers;
+ uint32_t reserved[4];
+};
+
+struct v4l2_streamparm {
+ enum v4l2_buf_type type;
+ union {
+ struct v4l2_captureparm capture;
+ struct v4l2_outputparm output;
+ uint8_t raw_data[200];
+ } parm;
+};
+
+struct v4l2_tuner {
+ uint32_t index;
+ uint8_t name[32];
+ enum v4l2_tuner_type type;
+ uint32_t capability;
+ uint32_t rangelow;
+ uint32_t rangehigh;
+ uint32_t rxsubchans;
+ uint32_t audmode;
+ uint32_t signal;
+ int32_t afc;
+ uint32_t reserved[4];
+};
+
+struct v4l2_capability {
+ uint8_t driver[16];
+ uint8_t card[32];
+ uint8_t bus_info[32];
+ uint32_t version;
+ uint32_t capabilities;
+ uint32_t reserved[4];
+};
+
+struct v4l2_queryctrl {
+ uint32_t id;
+ enum v4l2_ctrl_type type;
+ uint8_t name[32];
+ int32_t minimum;
+ int32_t maximum;
+ int32_t step;
+ int32_t default_value;
+ uint32_t flags;
+ uint32_t reserved[2];
+};
+
+struct v4l2_querymenu {
+ uint32_t id;
+ uint32_t index;
+ uint8_t name[32];
+ uint32_t reserved;
+};
+
+struct v4l2_requestbuffers {
+ uint32_t count;
+ enum v4l2_buf_type type;
+ enum v4l2_memory memory;
+ uint32_t reserved[2];
+};
+
+/* Timecode types */
+#define V4L2_TC_TYPE_24FPS 1
+#define V4L2_TC_TYPE_25FPS 2
+#define V4L2_TC_TYPE_30FPS 3
+#define V4L2_TC_TYPE_50FPS 4
+#define V4L2_TC_TYPE_60FPS 5
+
+/* Timecode flags */
+#define V4L2_TC_FLAG_DROPFRAME 0x0001
+#define V4L2_TC_FLAG_COLORFRAME 0x0002
+#define V4L2_TC_USERBITS_field 0x000c
+#define V4L2_TC_USERBITS_USERDEFINED 0x0000
+#define V4L2_TC_USERBITS_8BITCHARS 0x0008
+
+/* Buffer flags */
+#define V4L2_BUF_FLAG_MAPPED 0x0001
+#define V4L2_BUF_FLAG_QUEUED 0x0002
+#define V4L2_BUF_FLAG_DONE 0x0004
+#define V4L2_BUF_FLAG_KEYFRAME 0x0008
+#define V4L2_BUF_FLAG_PFRAME 0x0010
+#define V4L2_BUF_FLAG_BFRAME 0x0020
+#define V4L2_BUF_FLAG_TIMECODE 0x0100
+#define V4L2_BUF_FLAG_INPUT 0x0200
+
+/* Image format description flags */
+#define V4L2_FMT_FLAG_COMPRESSED 0x0001
+
+/* Input types */
+#define V4L2_INPUT_TYPE_TUNER 1
+#define V4L2_INPUT_TYPE_CAMERA 2
+
+/* Input status flags */
+#define V4L2_IN_ST_NO_POWER 0x00000001
+#define V4L2_IN_ST_NO_SIGNAL 0x00000002
+#define V4L2_IN_ST_NO_COLOR 0x00000004
+#define V4L2_IN_ST_NO_H_LOCK 0x00000100
+#define V4L2_IN_ST_COLOR_KILL 0x00000200
+#define V4L2_IN_ST_NO_SYNC 0x00010000
+#define V4L2_IN_ST_NO_EQU 0x00020000
+#define V4L2_IN_ST_NO_CARRIER 0x00040000
+#define V4L2_IN_ST_MACROVISION 0x01000000
+#define V4L2_IN_ST_NO_ACCESS 0x02000000
+#define V4L2_IN_ST_VTR 0x04000000
+
+/* Output types */
+#define V4L2_OUTPUT_TYPE_MODULATOR 1
+#define V4L2_OUTPUT_TYPE_ANALOG 2
+#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
+
+/* Audio capability flags */
+#define V4L2_AUDCAP_STEREO 0x00001
+#define V4L2_AUDCAP_AVL 0x00002
+
+/* Audio modes */
+#define V4L2_AUDMODE_AVL 0x00001
+
+/* Frame buffer capability flags */
+#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
+#define V4L2_FBUF_CAP_CHROMAKEY 0x0002
+#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
+#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
+
+/* Frame buffer flags */
+#define V4L2_FBUF_FLAG_PRIMARY 0x0001
+#define V4L2_FBUF_FLAG_OVERLAY 0x0002
+#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
+
+/* JPEG markers flags */
+#define V4L2_JPEG_MARKER_DHT (1 << 3)
+#define V4L2_JPEG_MARKER_DQT (1 << 4)
+#define V4L2_JPEG_MARKER_DRI (1 << 5)
+#define V4L2_JPEG_MARKER_COM (1 << 6)
+#define V4L2_JPEG_MARKER_APP (1 << 7)
+
+/* Streaming parameters capabilities */
+#define V4L2_CAP_TIMEPERFRAME 0x1000
+
+/* Capture parameters flags */
+#define V4L2_MODE_HIGHQUALITY 0x0001
+
+/* Tuner and modulator capability flags */
+#define V4L2_TUNER_CAP_LOW 0x0001
+#define V4L2_TUNER_CAP_NORM 0x0002
+#define V4L2_TUNER_CAP_STEREO 0x0010
+#define V4L2_TUNER_CAP_LANG2 0x0020
+#define V4L2_TUNER_CAP_SAP 0x0020
+#define V4L2_TUNER_CAP_LANG1 0x0040
+
+/* Tuner and modulation audio transmission flags */
+#define V4L2_TUNER_SUB_MONO 0x0001
+#define V4L2_TUNER_SUB_STEREO 0x0002
+#define V4L2_TUNER_SUB_LANG2 0x0004
+#define V4L2_TUNER_SUB_SAP 0x0004
+#define V4L2_TUNER_SUB_LANG1 0x0008
+
+/* Tuner audio modes */
+#define V4L2_TUNER_MODE_MONO 0
+#define V4L2_TUNER_MODE_STEREO 1
+#define V4L2_TUNER_MODE_LANG2 2
+#define V4L2_TUNER_MODE_SAP 2
+#define V4L2_TUNER_MODE_LANG1 3
+#define V4L2_TUNER_MODE_LANG1_LANG2 4
+
+/* Control flags */
+#define V4L2_CTRL_FLAG_DISABLED 0x0001
+#define V4L2_CTRL_FLAG_GRABBED 0x0002
+#define V4L2_CTRL_FLAG_READ_ONLY 0x0004
+#define V4L2_CTRL_FLAG_UPDATE 0x0008
+#define V4L2_CTRL_FLAG_INACTIVE 0x0010
+#define V4L2_CTRL_FLAG_SLIDER 0x0020
+
+/* Control IDs defined by V4L2 */
+#define V4L2_CID_BASE 0x00980900
+#define V4L2_CID_PRIVATE_BASE 0x08000000
+
+#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE + 0)
+#define V4L2_CID_CONTRAST (V4L2_CID_BASE + 1)
+#define V4L2_CID_SATURATION (V4L2_CID_BASE + 2)
+#define V4L2_CID_HUE (V4L2_CID_BASE + 3)
+#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE + 5)
+#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE + 6)
+#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE + 7)
+#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE + 8)
+#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE + 9)
+#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE + 10)
+#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE + 11)
+#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE + 12)
+#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE + 13)
+#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE + 14)
+#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE + 15)
+#define V4L2_CID_GAMMA (V4L2_CID_BASE + 16)
+#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA)
+#define V4L2_CID_EXPOSURE (V4L2_CID_BASE + 17)
+#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE + 18)
+#define V4L2_CID_GAIN (V4L2_CID_BASE + 19)
+#define V4L2_CID_HFLIP (V4L2_CID_BASE + 20)
+#define V4L2_CID_VFLIP (V4L2_CID_BASE + 21)
+#define V4L2_CID_HCENTER_DEPRECATED (V4L2_CID_BASE + 22)
+#define V4L2_CID_VCENTER_DEPRECATED (V4L2_CID_BASE + 23)
+#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
+#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
+#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE + 24)
+#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE + 25)
+#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE + 26)
+#define V4L2_CID_SHARPNESS (V4L2_CID_BASE + 27)
+#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE + 28)
+#define V4L2_CID_LASTP1 (V4L2_CID_BASE + 29)
+
+/* Pixel formats */
+#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1')
+#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O')
+#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')
+#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q')
+#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R')
+#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3')
+#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3')
+#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4')
+#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4')
+#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y')
+#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')
+#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')
+#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P')
+#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2')
+#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2')
+#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9')
+#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9')
+#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P')
+#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('Y', '1', '1', 'P')
+#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2')
+#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1')
+/* http://www.siliconimaging.com/RGB%20Bayer.htm */
+#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')
+/* Reserved pixel formats */
+#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V')
+#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4')
+#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G')
+#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')
+#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')
+#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')
+#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')
+#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0')
+
+/* Video standards */
+#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
+#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
+#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
+#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
+#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
+#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
+#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
+#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
+#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
+#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
+#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
+#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
+#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
+#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
+#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
+#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
+#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
+#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
+#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
+#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
+#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
+#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
+#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
+#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B | \
+ V4L2_STD_PAL_B1 | \
+ V4L2_STD_PAL_G)
+#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D | \
+ V4L2_STD_PAL_D1 | \
+ V4L2_STD_PAL_K)
+#define V4L2_STD_PAL (V4L2_STD_PAL_BG | \
+ V4L2_STD_PAL_DK | \
+ V4L2_STD_PAL_H | \
+ V4L2_STD_PAL_I)
+#define V4L2_STD_NTSC (V4L2_STD_NTSC_M | \
+ V4L2_STD_NTSC_M_JP)
+#define V4L2_STD_SECAM (V4L2_STD_SECAM_B | \
+ V4L2_STD_SECAM_D | \
+ V4L2_STD_SECAM_G | \
+ V4L2_STD_SECAM_H | \
+ V4L2_STD_SECAM_K | \
+ V4L2_STD_SECAM_K1 | \
+ V4L2_STD_SECAM_L)
+#define V4L2_STD_525_60 (V4L2_STD_PAL_M | \
+ V4L2_STD_PAL_60 | \
+ V4L2_STD_NTSC)
+#define V4L2_STD_625_50 (V4L2_STD_PAL | \
+ V4L2_STD_PAL_N | \
+ V4L2_STD_PAL_Nc | \
+ V4L2_STD_SECAM)
+#define V4L2_STD_UNKNOWN 0
+#define V4L2_STD_ALL (V4L2_STD_525_60 | \
+ V4L2_STD_625_50)
+
+/* Raw VBI format flags */
+#define V4L2_VBI_UNSYNC 0x0001
+#define V4L2_VBI_INTERLACED 0x0002
+
+/* Device capabilities */
+#define V4L2_CAP_VIDEO_CAPTURE 0x00000001
+#define V4L2_CAP_VIDEO_OUTPUT 0x00000002
+#define V4L2_CAP_VIDEO_OVERLAY 0x00000004
+#define V4L2_CAP_VBI_CAPTURE 0x00000010
+#define V4L2_CAP_VBI_OUTPUT 0x00000020
+#define V4L2_CAP_RDS_CAPTURE 0x00000100
+#define V4L2_CAP_TUNER 0x00010000
+#define V4L2_CAP_AUDIO 0x00020000
+#define V4L2_CAP_READWRITE 0x01000000
+#define V4L2_CAP_ASYNCIO 0x02000000
+#define V4L2_CAP_STREAMING 0x04000000
+#define V4L2_CAP_BITMASK \
+ "\20\1VIDEO_CAPTURE\2VIDEO_OUTPUT\3VIDEO_OVERLAY" \
+ "\5VBI_CAPTURE\6VBI_OUTPUT\10RDS_CAPTURE" \
+ "\21TUNER\22AUDIO\31READWRITE" \
+ "\32ASYNCIO\33STREAMING"
+
+/* Device ioctls -- try to keep them the same as Linux for compat_linux */
+#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
+#define VIDIOC_RESERVED _IO('V', 1)
+#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
+#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
+#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
+/* 6 and 7 are VIDIOC_[SG]_COMP, which are unsupported */
+#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
+#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
+#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
+#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
+#define VIDIOC_OVERLAY _IOW('V', 14, int)
+#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
+#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
+#define VIDIOC_STREAMON _IOW('V', 18, int)
+#define VIDIOC_STREAMOFF _IOW('V', 19, int)
+#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
+#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
+#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
+#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
+#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
+#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
+#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
+#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
+#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
+#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
+#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
+#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
+#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
+#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
+#define VIDIOC_G_INPUT _IOR('V', 38, int)
+#define VIDIOC_S_INPUT _IOWR('V', 39, int)
+#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
+#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
+#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
+#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
+#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
+#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
+#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
+#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
+#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
+#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
+#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
+#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
+#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
+#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
+#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
+#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
+#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
+#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
+#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
+#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
+
+#ifdef _KERNEL
+#define VIDIOC_QUERYBUF50 _IOWR('V', 9, struct v4l2_buffer50)
+#define VIDIOC_QBUF50 _IOWR('V', 15, struct v4l2_buffer50)
+#define VIDIOC_DQBUF50 _IOWR('V', 17, struct v4l2_buffer50)
+#endif
+
+#endif /* !_HAVE_SYS_VIDEOIO_H */
--- /dev/null
+/* $NetBSD: vmem.h,v 1.17 2012/01/27 19:48:41 para Exp $ */
+
+/*-
+ * Copyright (c)2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VMEM_H_
+#define _SYS_VMEM_H_
+
+#include <sys/types.h>
+
+#if !defined(_KERNEL)
+#include <stdbool.h>
+#endif /* !defined(_KERNEL) */
+
+typedef struct vmem vmem_t;
+
+typedef unsigned int vm_flag_t;
+
+typedef uintptr_t vmem_addr_t;
+typedef size_t vmem_size_t;
+#define VMEM_ADDR_MIN 0
+#define VMEM_ADDR_MAX (~(vmem_addr_t)0)
+
+typedef int (vmem_import_t)(vmem_t *, vmem_size_t, vm_flag_t, vmem_addr_t *);
+typedef void (vmem_release_t)(vmem_t *, vmem_addr_t, vmem_size_t);
+
+typedef int (vmem_ximport_t)(vmem_t *, vmem_size_t, vmem_size_t *,
+ vm_flag_t, vmem_addr_t *);
+
+extern vmem_t *kmem_arena;
+extern vmem_t *kmem_meta_arena;
+extern vmem_t *kmem_va_arena;
+
+void vmem_bootstrap(void);
+void vmem_init(vmem_t *vm);
+
+vmem_t *vmem_create(const char *, vmem_addr_t, vmem_size_t, vmem_size_t,
+ vmem_import_t *, vmem_release_t *, vmem_t *, vmem_size_t,
+ vm_flag_t, int);
+vmem_t *vmem_xcreate(const char *, vmem_addr_t, vmem_size_t, vmem_size_t,
+ vmem_ximport_t *, vmem_release_t *, vmem_t *, vmem_size_t,
+ vm_flag_t, int);
+void vmem_destroy(vmem_t *);
+int vmem_alloc(vmem_t *, vmem_size_t, vm_flag_t, vmem_addr_t *);
+void vmem_free(vmem_t *, vmem_addr_t, vmem_size_t);
+int vmem_xalloc(vmem_t *, vmem_size_t, vmem_size_t, vmem_size_t,
+ vmem_size_t, vmem_addr_t, vmem_addr_t, vm_flag_t, vmem_addr_t *);
+void vmem_xfree(vmem_t *, vmem_addr_t, vmem_size_t);
+int vmem_add(vmem_t *, vmem_addr_t, vmem_size_t, vm_flag_t);
+vmem_size_t vmem_roundup_size(vmem_t *, vmem_size_t);
+vmem_size_t vmem_size(vmem_t *, int typemask);
+void vmem_rehash_start(void);
+void vmem_whatis(uintptr_t, void (*)(const char *, ...) __printflike(1, 2));
+void vmem_print(uintptr_t, const char *, void (*)(const char *, ...)
+ __printflike(1, 2));
+void vmem_printall(const char *, void (*)(const char *, ...)
+ __printflike(1, 2));
+
+/* vm_flag_t */
+#define VM_SLEEP 0x00000001
+#define VM_NOSLEEP 0x00000002
+#define VM_INSTANTFIT 0x00001000
+#define VM_BESTFIT 0x00002000
+#define VM_BOOTSTRAP 0x00010000
+#define VM_POPULATING 0x00040000
+#define VM_LARGEIMPORT 0x00080000
+#define VM_XIMPORT 0x00100000
+
+/* vmem_size typemask */
+#define VMEM_ALLOC 0x01
+#define VMEM_FREE 0x02
+
+#endif /* !_SYS_VMEM_H_ */
--- /dev/null
+/* $NetBSD: vmmeter.h,v 1.19 2009/10/21 21:12:07 rmind Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_VMMETER_H_
+#define _SYS_VMMETER_H_
+
+/* systemwide totals computed every five seconds */
+struct vmtotal
+{
+ int16_t t_rq; /* length of the run queue */
+ int16_t t_dw; /* jobs in ``disk wait'' (neg priority) */
+ int16_t t_pw; /* jobs in page wait */
+ int16_t t_sl; /* jobs sleeping in core */
+ int16_t _reserved1;
+ int32_t t_vm; /* total virtual memory */
+ int32_t t_avm; /* active virtual memory */
+ int32_t t_rm; /* total real memory in use */
+ int32_t t_arm; /* active real memory */
+ int32_t t_vmshr; /* shared virtual memory */
+ int32_t t_avmshr; /* active shared virtual memory */
+ int32_t t_rmshr; /* shared real memory */
+ int32_t t_armshr; /* active shared real memory */
+ int32_t t_free; /* free memory pages */
+};
+
+/*
+ * Optional instrumentation.
+ */
+#ifdef PGINPROF
+
+#define NDMON 128
+#define NSMON 128
+
+#define DRES 20
+#define SRES 5
+
+#define PMONMIN 20
+#define PRES 50
+#define NPMON 64
+
+#define RMONMIN 130
+#define RRES 5
+#define NRMON 64
+
+/* data and stack size distribution counters */
+u_int dmon[NDMON+1];
+u_int smon[NSMON+1];
+
+/* page in time distribution counters */
+u_int pmon[NPMON+2];
+
+/* reclaim time distribution counters */
+u_int rmon[NRMON+2];
+
+int pmonmin;
+int pres;
+int rmonmin;
+int rres;
+
+u_int rectime; /* accumulator for reclaim times */
+u_int pgintime; /* accumulator for page in times */
+#endif /* PGINPROF */
+
+#endif /* !_SYS_VMMETER_H_ */
--- /dev/null
+/* $NetBSD: vnode.h,v 1.236 2011/11/24 15:51:30 ahoka Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vnode.h 8.17 (Berkeley) 5/20/95
+ */
+
+#ifndef _SYS_VNODE_H_
+#define _SYS_VNODE_H_
+
+#include <sys/event.h>
+#include <sys/queue.h>
+#include <sys/condvar.h>
+#include <sys/rwlock.h>
+#include <sys/mutex.h>
+
+/* XXX: clean up includes later */
+#include <uvm/uvm_param.h> /* XXX */
+#include <uvm/uvm_pglist.h> /* XXX */
+#include <uvm/uvm_object.h> /* XXX */
+#include <uvm/uvm_extern.h> /* XXX */
+
+struct namecache;
+struct uvm_ractx;
+
+/*
+ * The vnode is the focus of all file activity in UNIX. There is a
+ * unique vnode allocated for each active file, each current directory,
+ * each mounted-on file, text file, and the root.
+ */
+
+/*
+ * Vnode types. VNON means no type. __VTYPE_DEFINED allows other
+ * sources to override this definition. __VTYPE_DEFINED should be
+ * considered a temporary feature.
+ */
+#ifndef __VTYPE_DEFINED
+#define __VTYPE_DEFINED
+enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
+#endif /* __VTYPE_DEFINED */
+
+#define VNODE_TYPES \
+ "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
+
+/*
+ * Vnode tag types.
+ * These are for the benefit of external programs only (e.g., pstat)
+ * and should NEVER be inspected by the kernel.
+ */
+enum vtagtype {
+ VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
+ VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
+ VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
+ VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
+ VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
+ VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
+};
+
+#define VNODE_TAGS \
+ "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
+ "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
+ "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
+ "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
+ "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
+ "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
+
+struct vnode;
+struct buf;
+
+LIST_HEAD(buflists, buf);
+TAILQ_HEAD(vnodelst, vnode);
+
+/*
+ * Reading or writing any of these items requires holding the appropriate
+ * lock. Field markings and the corresponding locks:
+ *
+ * : stable, reference to the vnode is required
+ * f vnode_free_list_lock, or vrele_lock if VI_INACTPEND
+ * i v_interlock
+ * m mntvnode_lock
+ * n namecache_lock
+ * s syncer_data_lock
+ * u locked by underlying filesystem
+ * v vnode lock
+ * x v_interlock + bufcache_lock to modify, either to inspect
+ *
+ * Each underlying filesystem allocates its own private area and hangs
+ * it from v_data.
+ */
+struct vnode {
+ struct uvm_object v_uobj; /* i: the VM object */
+ kcondvar_t v_cv; /* i: synchronization */
+ voff_t v_size; /* i: size of file */
+ voff_t v_writesize; /* i: new size after write */
+ int v_iflag; /* i: VI_* flags */
+ int v_vflag; /* v: VV_* flags */
+ int v_uflag; /* u: VU_* flags */
+ int v_numoutput; /* i: # of pending writes */
+ int v_writecount; /* i: ref count of writers */
+ int v_holdcnt; /* i: page & buffer refs */
+ int v_synclist_slot; /* s: synclist slot index */
+ struct mount *v_mount; /* v: ptr to vfs we are in */
+ int (**v_op)(void *); /* :: vnode operations vector */
+ TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */
+ struct vnodelst *v_freelisthd; /* f: which freelist? */
+ TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */
+ struct buflists v_cleanblkhd; /* x: clean blocklist head */
+ struct buflists v_dirtyblkhd; /* x: dirty blocklist head */
+ TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */
+ LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */
+ LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */
+ union {
+ struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */
+ struct socket *vu_socket; /* v: unix ipc (VSOCK) */
+ struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */
+ struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */
+ struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */
+ } v_un;
+ enum vtype v_type; /* :: vnode type */
+ enum vtagtype v_tag; /* :: type of underlying data */
+ krwlock_t v_lock; /* v: lock for this vnode */
+ void *v_data; /* :: private data for fs */
+ struct klist v_klist; /* i: notes attached to vnode */
+};
+#define v_usecount v_uobj.uo_refs
+#define v_interlock v_uobj.vmobjlock
+#define v_mountedhere v_un.vu_mountedhere
+#define v_socket v_un.vu_socket
+#define v_specnode v_un.vu_specnode
+#define v_fifoinfo v_un.vu_fifoinfo
+#define v_ractx v_un.vu_ractx
+
+typedef struct vnodelst vnodelst_t;
+typedef struct vnode vnode_t;
+
+/*
+ * Vnode flags. The first set are locked by vnode lock or are stable.
+ * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used
+ * when reading dead vnodes.
+ */
+#define VV_ROOT 0x00000001 /* root of its file system */
+#define VV_SYSTEM 0x00000002 /* vnode being used by kernel */
+#define VV_ISTTY 0x00000004 /* vnode represents a tty */
+#define VV_MAPPED 0x00000008 /* vnode might have user mappings */
+#define VV_MPSAFE 0x00000010 /* file system code is MP safe */
+#define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */
+
+/*
+ * The second set are locked by vp->v_interlock.
+ */
+#define VI_TEXT 0x00000100 /* vnode is a pure text prototype */
+#define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */
+#define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */
+#define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */
+#define VI_XLOCK 0x00001000 /* vnode is locked to change type */
+#define VI_ONWORKLST 0x00004000 /* On syncer work-list */
+#define VI_MARKER 0x00008000 /* Dummy marker vnode */
+#define VI_LAYER 0x00020000 /* vnode is on a layer filesystem */
+#define VI_LOCKSHARE 0x00040000 /* v_interlock is shared */
+#define VI_CLEAN 0x00080000 /* has been reclaimed */
+#define VI_INACTPEND 0x00100000 /* inactivation is pending */
+#define VI_INACTREDO 0x00200000 /* need to redo VOP_INACTIVE() */
+#define VI_INACTNOW 0x00800000 /* VOP_INACTIVE() in progress */
+
+/*
+ * The third set are locked by the underlying file system.
+ */
+#define VU_DIROP 0x01000000 /* LFS: involved in a directory op */
+
+#define VNODE_FLAGBITS \
+ "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
+ "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
+ "\22LAYER\24CLEAN\25INACTPEND\26INACTREDO" \
+ "\30INACTNOW\31DIROP"
+
+#define VSIZENOTSET ((voff_t)-1)
+
+/*
+ * v_usecount; see the comment near the top of vfs_vnode.c
+ */
+#define VC_XLOCK 0x80000000
+#define VC_MASK 0x7fffffff
+
+/*
+ * vnode lock flags
+ */
+#define LK_SHARED 0x00000001 /* shared lock */
+#define LK_EXCLUSIVE 0x00000002 /* exclusive lock */
+#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */
+#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
+
+/*
+ * Vnode attributes. A field value of VNOVAL represents a field whose value
+ * is unavailable (getattr) or which is not to be changed (setattr).
+ */
+struct vattr {
+ enum vtype va_type; /* vnode type (for create) */
+ mode_t va_mode; /* files access mode and type */
+ nlink_t va_nlink; /* number of references to file */
+ uid_t va_uid; /* owner user id */
+ gid_t va_gid; /* owner group id */
+ dev_t va_fsid; /* file system id (dev for now) */
+ ino_t va_fileid; /* file id */
+ u_quad_t va_size; /* file size in bytes */
+ long va_blocksize; /* blocksize preferred for i/o */
+ struct timespec va_atime; /* time of last access */
+ struct timespec va_mtime; /* time of last modification */
+ struct timespec va_ctime; /* time file changed */
+ struct timespec va_birthtime; /* time file created */
+ u_long va_gen; /* generation number of file */
+ u_long va_flags; /* flags defined for file */
+ dev_t va_rdev; /* device the special file represents */
+ u_quad_t va_bytes; /* bytes of disk space held by file */
+ u_quad_t va_filerev; /* file modification number */
+ u_int va_vaflags; /* operations flags, see below */
+ long va_spare; /* remain quad aligned */
+};
+
+/*
+ * Flags for va_vaflags.
+ */
+#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */
+#define VA_EXCLUSIVE 0x02 /* exclusive create request */
+
+#ifdef _KERNEL
+
+/*
+ * Flags for ioflag.
+ */
+#define IO_UNIT 0x00010 /* do I/O as atomic unit */
+#define IO_APPEND 0x00020 /* append write to end */
+#define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */
+#define IO_NODELOCKED 0x00080 /* underlying node already locked */
+#define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */
+#define IO_DSYNC 0x00200 /* sync I/O data integrity completion */
+#define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */
+#define IO_NORMAL 0x00800 /* operate on regular data */
+#define IO_EXT 0x01000 /* operate on extended attributes */
+#define IO_DIRECT 0x02000 /* direct I/O hint */
+#define IO_JOURNALLOCKED 0x04000 /* journal is already locked */
+#define IO_ADV_MASK 0x00003 /* access pattern hint */
+
+#define IO_ADV_SHIFT 0
+#define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
+#define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
+
+/*
+ * Modes.
+ */
+#define VREAD 00004 /* read, write, execute permissions */
+#define VWRITE 00002
+#define VEXEC 00001
+
+/*
+ * Token indicating no attribute value yet assigned.
+ */
+#define VNOVAL (-1)
+
+/*
+ * Convert between vnode types and inode formats (since POSIX.1
+ * defines mode word of stat structure in terms of inode formats).
+ */
+extern const enum vtype iftovt_tab[];
+extern const int vttoif_tab[];
+#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
+#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
+#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
+
+/*
+ * Flags to various vnode functions.
+ */
+#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */
+#define FORCECLOSE 0x0002 /* vflush: force file closeure */
+#define WRITECLOSE 0x0004 /* vflush: only close writable files */
+#define DOCLOSE 0x0008 /* vclean: close active files */
+#define V_SAVE 0x0001 /* vinvalbuf: sync file first */
+
+/*
+ * Flags to various vnode operations.
+ */
+#define REVOKEALL 0x0001 /* revoke: revoke all aliases */
+
+#define FSYNC_WAIT 0x0001 /* fsync: wait for completion */
+#define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */
+#define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */
+#define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */
+#define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */
+#define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */
+
+#define UPDATE_WAIT 0x0001 /* update: wait for completion */
+#define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */
+#define UPDATE_CLOSE 0x0004 /* update: clean up on close */
+
+void holdrelel(struct vnode *);
+void vholdl(struct vnode *);
+void vref(struct vnode *);
+
+static __inline void holdrele(struct vnode *) __unused;
+static __inline void vhold(struct vnode *) __unused;
+
+/*
+ * decrease buf or page ref
+ */
+static __inline void
+holdrele(struct vnode *vp)
+{
+
+ mutex_enter(vp->v_interlock);
+ holdrelel(vp);
+ mutex_exit(vp->v_interlock);
+}
+
+/*
+ * increase buf or page ref
+ */
+static __inline void
+vhold(struct vnode *vp)
+{
+
+ mutex_enter(vp->v_interlock);
+ vholdl(vp);
+ mutex_exit(vp->v_interlock);
+}
+
+static __inline bool
+vismarker(struct vnode *vp)
+{
+
+ return (vp->v_iflag & VI_MARKER) != 0;
+}
+
+#define NULLVP ((struct vnode *)NULL)
+
+static __inline void
+VN_KNOTE(struct vnode *vp, long hint)
+{
+
+ mutex_enter(vp->v_interlock);
+ KNOTE(&vp->v_klist, hint);
+ mutex_exit(vp->v_interlock);
+}
+
+/*
+ * Global vnode data.
+ */
+extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
+extern int desiredvnodes; /* number of vnodes desired */
+extern u_int numvnodes; /* current number of vnodes */
+
+/*
+ * Macro/function to check for client cache inconsistency w.r.t. leasing.
+ */
+#define LEASE_READ 0x1 /* Check lease for readers */
+#define LEASE_WRITE 0x2 /* Check lease for modifiers */
+
+#endif /* _KERNEL */
+
+
+/*
+ * Mods for exensibility.
+ */
+
+/*
+ * Flags for vdesc_flags:
+ */
+#define VDESC_MAX_VPS 8
+/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
+#define VDESC_VP0_WILLRELE 0x00000001
+#define VDESC_VP1_WILLRELE 0x00000002
+#define VDESC_VP2_WILLRELE 0x00000004
+#define VDESC_VP3_WILLRELE 0x00000008
+#define VDESC_VP0_WILLUNLOCK 0x00000100
+#define VDESC_VP1_WILLUNLOCK 0x00000200
+#define VDESC_VP2_WILLUNLOCK 0x00000400
+#define VDESC_VP3_WILLUNLOCK 0x00000800
+#define VDESC_VP0_WILLPUT 0x00000101
+#define VDESC_VP1_WILLPUT 0x00000202
+#define VDESC_VP2_WILLPUT 0x00000404
+#define VDESC_VP3_WILLPUT 0x00000808
+
+/*
+ * VDESC_NO_OFFSET is used to identify the end of the offset list
+ * and in places where no such field exists.
+ */
+#define VDESC_NO_OFFSET -1
+
+/*
+ * This structure describes the vnode operation taking place.
+ */
+struct vnodeop_desc {
+ int vdesc_offset; /* offset in vector--first for speed */
+ const char *vdesc_name; /* a readable name for debugging */
+ int vdesc_flags; /* VDESC_* flags */
+
+ /*
+ * These ops are used by bypass routines to map and locate arguments.
+ * Creds and procs are not needed in bypass routines, but sometimes
+ * they are useful to (for example) transport layers.
+ * Nameidata is useful because it has a cred in it.
+ */
+ const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */
+ int vdesc_vpp_offset; /* return vpp location */
+ int vdesc_cred_offset; /* cred location, if any */
+ int vdesc_componentname_offset; /* if any */
+};
+
+#ifdef _KERNEL
+
+/*
+ * Interlock for scanning list of vnodes attached to a mountpoint
+ */
+extern kmutex_t mntvnode_lock;
+
+/*
+ * Union filesystem hook for vn_readdir().
+ */
+extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
+
+/*
+ * Macros for offsets in the vdesc struct.
+ */
+#define VOPARG_OFFSETOF(type, member) offsetof(type, member)
+#define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset)))
+
+/*
+ * This structure is used to configure the new vnodeops vector.
+ */
+struct vnodeopv_entry_desc {
+ const struct vnodeop_desc *opve_op; /* which operation this is */
+ int (*opve_impl)(void *); /* code implementing this operation */
+};
+
+struct vnodeopv_desc {
+ /* ptr to the ptr to the vector where op should go */
+ int (***opv_desc_vector_p)(void *);
+ const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
+};
+
+/*
+ * A default routine which just returns an error.
+ */
+int vn_default_error(void *);
+
+/*
+ * A generic structure.
+ * This can be used by bypass routines to identify generic arguments.
+ */
+struct vop_generic_args {
+ struct vnodeop_desc *a_desc;
+ /* other random data follows, presumably */
+};
+
+/*
+ * VOCALL calls an op given an ops vector. We break it out because BSD's
+ * vclean changes the ops vector and then wants to call ops with the old
+ * vector.
+ */
+/*
+ * actually, vclean doesn't use it anymore, but nfs does,
+ * for device specials and fifos.
+ */
+#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
+
+/*
+ * This call works for vnodes in the kernel.
+ */
+#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
+#define VDESC(OP) (& __CONCAT(OP,_desc))
+#define VOFFSET(OP) (VDESC(OP)->vdesc_offset)
+
+/* XXX This include should go away */
+#include <sys/mount.h>
+
+/*
+ * Finally, include the default set of vnode operations.
+ */
+#include <sys/vnode_if.h>
+
+/*
+ * Public vnode manipulation functions.
+ */
+struct file;
+struct filedesc;
+struct nameidata;
+struct proc;
+struct stat;
+struct uio;
+struct vattr;
+struct vnode;
+
+/* see vnode(9) */
+void vfs_vnode_sysinit(void);
+int bdevvp(dev_t, struct vnode **);
+int cdevvp(dev_t, struct vnode **);
+int getnewvnode(enum vtagtype, struct mount *, int (**)(void *),
+ kmutex_t *, struct vnode **);
+void ungetnewvnode(struct vnode *);
+int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
+void vattr_null(struct vattr *);
+void vdevgone(int, int, int, enum vtype);
+int vfinddev(dev_t, enum vtype, struct vnode **);
+int vflush(struct mount *, struct vnode *, int);
+int vflushbuf(struct vnode *, int);
+int vget(struct vnode *, int);
+bool vtryget(struct vnode *);
+void vgone(struct vnode *);
+int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
+void vprint(const char *, struct vnode *);
+void vput(struct vnode *);
+int vrecycle(struct vnode *, kmutex_t *, struct lwp *);
+void vrele(struct vnode *);
+void vrele_async(struct vnode *);
+void vrele_flush(void);
+int vtruncbuf(struct vnode *, daddr_t, bool, int);
+void vwakeup(struct buf *);
+void vwait(struct vnode *, int);
+void vclean(struct vnode *, int);
+void vrevoke(struct vnode *);
+void vrelel(struct vnode *, int);
+#define VRELEL_ASYNC_RELE 0x03
+struct vnode *
+ vnalloc(struct mount *);
+void vnfree(struct vnode *);
+void vmark(struct vnode *, struct vnode *);
+struct vnode *
+ vunmark(struct vnode *);
+void vremfree(struct vnode *);
+
+/* see vnsubr(9) */
+int vn_bwrite(void *);
+int vn_close(struct vnode *, int, kauth_cred_t);
+int vn_isunder(struct vnode *, struct vnode *, struct lwp *);
+int vn_lock(struct vnode *, int);
+void vn_markexec(struct vnode *);
+int vn_marktext(struct vnode *);
+int vn_open(struct nameidata *, int, int);
+int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
+ int, kauth_cred_t, size_t *, struct lwp *);
+int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
+ off_t **, int *);
+int vn_stat(struct vnode *, struct stat *);
+int vn_kqfilter(struct file *, struct knote *);
+int vn_writechk(struct vnode *);
+int vn_openchk(struct vnode *, kauth_cred_t, int);
+int vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
+ void *, struct lwp *);
+int vn_extattr_set(struct vnode *, int, int, const char *, size_t,
+ const void *, struct lwp *);
+int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
+void vn_ra_allocctx(struct vnode *);
+int vn_fifo_bypass(void *);
+
+/* initialise global vnode management */
+void vntblinit(void);
+
+/* misc stuff */
+void vn_syncer_add_to_worklist(struct vnode *, int);
+void vn_syncer_remove_from_worklist(struct vnode *);
+int speedup_syncer(void);
+int dorevoke(struct vnode *, kauth_cred_t);
+int rawdev_mounted(struct vnode *, struct vnode **);
+uint8_t vtype2dt(enum vtype);
+
+/* see vfssubr(9) */
+void vfs_getnewfsid(struct mount *);
+int vfs_drainvnodes(long);
+void vfs_timestamp(struct timespec *);
+#if defined(DDB) || defined(DEBUGPRINT)
+void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
+ __printflike(1, 2));
+void vfs_mount_print(struct mount *, int, void (*)(const char *, ...)
+ __printflike(1, 2));
+#endif /* DDB */
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_VNODE_H_ */
--- /dev/null
+/* $NetBSD: vnode_if.h,v 1.83 2011/08/08 12:17:27 manu Exp $ */
+
+/*
+ * Warning: DO NOT EDIT! This file is automatically generated!
+ * (Modifications made here may easily be lost!)
+ *
+ * Created from the file:
+ * NetBSD: vnode_if.src,v 1.62 2011/07/11 08:23:00 hannken Exp
+ * by the script:
+ * NetBSD: vnode_if.sh,v 1.58 2011/07/11 08:23:00 hannken Exp
+ */
+
+/*
+ * Copyright (c) 1992, 1993, 1994, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VNODE_IF_H_
+#define _SYS_VNODE_IF_H_
+
+extern const struct vnodeop_desc vop_default_desc;
+
+struct buf;
+
+#ifndef _KERNEL
+#include <stdbool.h>
+#endif
+
+#define VOP_BWRITE_DESCOFFSET 1
+struct vop_bwrite_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct buf *a_bp;
+};
+extern const struct vnodeop_desc vop_bwrite_desc;
+int VOP_BWRITE(struct vnode *, struct buf *);
+
+#define VOP_LOOKUP_DESCOFFSET 2
+struct vop_lookup_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+};
+extern const struct vnodeop_desc vop_lookup_desc;
+int VOP_LOOKUP(struct vnode *, struct vnode **, struct componentname *);
+
+#define VOP_CREATE_DESCOFFSET 3
+struct vop_create_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+};
+extern const struct vnodeop_desc vop_create_desc;
+int VOP_CREATE(struct vnode *, struct vnode **, struct componentname *,
+ struct vattr *);
+
+#define VOP_MKNOD_DESCOFFSET 4
+struct vop_mknod_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+};
+extern const struct vnodeop_desc vop_mknod_desc;
+int VOP_MKNOD(struct vnode *, struct vnode **, struct componentname *,
+ struct vattr *);
+
+#define VOP_OPEN_DESCOFFSET 5
+struct vop_open_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_mode;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_open_desc;
+int VOP_OPEN(struct vnode *, int, kauth_cred_t);
+
+#define VOP_CLOSE_DESCOFFSET 6
+struct vop_close_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_fflag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_close_desc;
+int VOP_CLOSE(struct vnode *, int, kauth_cred_t);
+
+#define VOP_ACCESS_DESCOFFSET 7
+struct vop_access_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_mode;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_access_desc;
+int VOP_ACCESS(struct vnode *, int, kauth_cred_t);
+
+#define VOP_GETATTR_DESCOFFSET 8
+struct vop_getattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct vattr *a_vap;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_getattr_desc;
+int VOP_GETATTR(struct vnode *, struct vattr *, kauth_cred_t);
+
+#define VOP_SETATTR_DESCOFFSET 9
+struct vop_setattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct vattr *a_vap;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_setattr_desc;
+int VOP_SETATTR(struct vnode *, struct vattr *, kauth_cred_t);
+
+#define VOP_READ_DESCOFFSET 10
+struct vop_read_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ int a_ioflag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_read_desc;
+int VOP_READ(struct vnode *, struct uio *, int, kauth_cred_t);
+
+#define VOP_WRITE_DESCOFFSET 11
+struct vop_write_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ int a_ioflag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_write_desc;
+int VOP_WRITE(struct vnode *, struct uio *, int, kauth_cred_t);
+
+#define VOP_IOCTL_DESCOFFSET 12
+struct vop_ioctl_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ u_long a_command;
+ void *a_data;
+ int a_fflag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_ioctl_desc;
+int VOP_IOCTL(struct vnode *, u_long, void *, int, kauth_cred_t);
+
+#define VOP_FCNTL_DESCOFFSET 13
+struct vop_fcntl_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ u_int a_command;
+ void *a_data;
+ int a_fflag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_fcntl_desc;
+int VOP_FCNTL(struct vnode *, u_int, void *, int, kauth_cred_t);
+
+#define VOP_POLL_DESCOFFSET 14
+struct vop_poll_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_events;
+};
+extern const struct vnodeop_desc vop_poll_desc;
+int VOP_POLL(struct vnode *, int);
+
+#define VOP_KQFILTER_DESCOFFSET 15
+struct vop_kqfilter_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct knote *a_kn;
+};
+extern const struct vnodeop_desc vop_kqfilter_desc;
+int VOP_KQFILTER(struct vnode *, struct knote *);
+
+#define VOP_REVOKE_DESCOFFSET 16
+struct vop_revoke_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_revoke_desc;
+int VOP_REVOKE(struct vnode *, int);
+
+#define VOP_MMAP_DESCOFFSET 17
+struct vop_mmap_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ vm_prot_t a_prot;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_mmap_desc;
+int VOP_MMAP(struct vnode *, vm_prot_t, kauth_cred_t);
+
+#define VOP_FSYNC_DESCOFFSET 18
+struct vop_fsync_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ kauth_cred_t a_cred;
+ int a_flags;
+ off_t a_offlo;
+ off_t a_offhi;
+};
+extern const struct vnodeop_desc vop_fsync_desc;
+int VOP_FSYNC(struct vnode *, kauth_cred_t, int, off_t, off_t);
+
+#define VOP_SEEK_DESCOFFSET 19
+struct vop_seek_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ off_t a_oldoff;
+ off_t a_newoff;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_seek_desc;
+int VOP_SEEK(struct vnode *, off_t, off_t, kauth_cred_t);
+
+#define VOP_REMOVE_DESCOFFSET 20
+struct vop_remove_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode *a_vp;
+ struct componentname *a_cnp;
+};
+extern const struct vnodeop_desc vop_remove_desc;
+int VOP_REMOVE(struct vnode *, struct vnode *, struct componentname *);
+
+#define VOP_LINK_DESCOFFSET 21
+struct vop_link_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode *a_vp;
+ struct componentname *a_cnp;
+};
+extern const struct vnodeop_desc vop_link_desc;
+int VOP_LINK(struct vnode *, struct vnode *, struct componentname *);
+
+#define VOP_RENAME_DESCOFFSET 22
+struct vop_rename_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_fdvp;
+ struct vnode *a_fvp;
+ struct componentname *a_fcnp;
+ struct vnode *a_tdvp;
+ struct vnode *a_tvp;
+ struct componentname *a_tcnp;
+};
+extern const struct vnodeop_desc vop_rename_desc;
+int VOP_RENAME(struct vnode *, struct vnode *, struct componentname *,
+ struct vnode *, struct vnode *, struct componentname *);
+
+#define VOP_MKDIR_DESCOFFSET 23
+struct vop_mkdir_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+};
+extern const struct vnodeop_desc vop_mkdir_desc;
+int VOP_MKDIR(struct vnode *, struct vnode **, struct componentname *,
+ struct vattr *);
+
+#define VOP_RMDIR_DESCOFFSET 24
+struct vop_rmdir_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode *a_vp;
+ struct componentname *a_cnp;
+};
+extern const struct vnodeop_desc vop_rmdir_desc;
+int VOP_RMDIR(struct vnode *, struct vnode *, struct componentname *);
+
+#define VOP_SYMLINK_DESCOFFSET 25
+struct vop_symlink_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+ char *a_target;
+};
+extern const struct vnodeop_desc vop_symlink_desc;
+int VOP_SYMLINK(struct vnode *, struct vnode **, struct componentname *,
+ struct vattr *, char *);
+
+#define VOP_READDIR_DESCOFFSET 26
+struct vop_readdir_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ kauth_cred_t a_cred;
+ int *a_eofflag;
+ off_t **a_cookies;
+ int *a_ncookies;
+};
+extern const struct vnodeop_desc vop_readdir_desc;
+int VOP_READDIR(struct vnode *, struct uio *, kauth_cred_t, int *, off_t **,
+ int *);
+
+#define VOP_READLINK_DESCOFFSET 27
+struct vop_readlink_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_readlink_desc;
+int VOP_READLINK(struct vnode *, struct uio *, kauth_cred_t);
+
+#define VOP_ABORTOP_DESCOFFSET 28
+struct vop_abortop_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct componentname *a_cnp;
+};
+extern const struct vnodeop_desc vop_abortop_desc;
+int VOP_ABORTOP(struct vnode *, struct componentname *);
+
+#define VOP_INACTIVE_DESCOFFSET 29
+struct vop_inactive_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ bool *a_recycle;
+};
+extern const struct vnodeop_desc vop_inactive_desc;
+int VOP_INACTIVE(struct vnode *, bool *);
+
+#define VOP_RECLAIM_DESCOFFSET 30
+struct vop_reclaim_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+};
+extern const struct vnodeop_desc vop_reclaim_desc;
+int VOP_RECLAIM(struct vnode *);
+
+#define VOP_LOCK_DESCOFFSET 31
+struct vop_lock_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_lock_desc;
+int VOP_LOCK(struct vnode *, int);
+
+#define VOP_UNLOCK_DESCOFFSET 32
+struct vop_unlock_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+};
+extern const struct vnodeop_desc vop_unlock_desc;
+int VOP_UNLOCK(struct vnode *);
+
+#define VOP_BMAP_DESCOFFSET 33
+struct vop_bmap_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ daddr_t a_bn;
+ struct vnode **a_vpp;
+ daddr_t *a_bnp;
+ int *a_runp;
+};
+extern const struct vnodeop_desc vop_bmap_desc;
+int VOP_BMAP(struct vnode *, daddr_t, struct vnode **, daddr_t *, int *);
+
+#define VOP_STRATEGY_DESCOFFSET 34
+struct vop_strategy_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ struct buf *a_bp;
+};
+extern const struct vnodeop_desc vop_strategy_desc;
+int VOP_STRATEGY(struct vnode *, struct buf *);
+
+#define VOP_PRINT_DESCOFFSET 35
+struct vop_print_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+};
+extern const struct vnodeop_desc vop_print_desc;
+int VOP_PRINT(struct vnode *);
+
+#define VOP_ISLOCKED_DESCOFFSET 36
+struct vop_islocked_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+};
+extern const struct vnodeop_desc vop_islocked_desc;
+int VOP_ISLOCKED(struct vnode *);
+
+#define VOP_PATHCONF_DESCOFFSET 37
+struct vop_pathconf_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_name;
+ register_t *a_retval;
+};
+extern const struct vnodeop_desc vop_pathconf_desc;
+int VOP_PATHCONF(struct vnode *, int, register_t *);
+
+#define VOP_ADVLOCK_DESCOFFSET 38
+struct vop_advlock_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ void *a_id;
+ int a_op;
+ struct flock *a_fl;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_advlock_desc;
+int VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int);
+
+#define VOP_WHITEOUT_DESCOFFSET 39
+struct vop_whiteout_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_dvp;
+ struct componentname *a_cnp;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_whiteout_desc;
+int VOP_WHITEOUT(struct vnode *, struct componentname *, int);
+
+#define VOP_GETPAGES_DESCOFFSET 40
+struct vop_getpages_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ voff_t a_offset;
+ struct vm_page **a_m;
+ int *a_count;
+ int a_centeridx;
+ vm_prot_t a_access_type;
+ int a_advice;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_getpages_desc;
+int VOP_GETPAGES(struct vnode *, voff_t, struct vm_page **, int *, int,
+ vm_prot_t, int, int);
+
+#define VOP_PUTPAGES_DESCOFFSET 41
+struct vop_putpages_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ voff_t a_offlo;
+ voff_t a_offhi;
+ int a_flags;
+};
+extern const struct vnodeop_desc vop_putpages_desc;
+int VOP_PUTPAGES(struct vnode *, voff_t, voff_t, int);
+
+#define VOP_CLOSEEXTATTR_DESCOFFSET 42
+struct vop_closeextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_commit;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_closeextattr_desc;
+int VOP_CLOSEEXTATTR(struct vnode *, int, kauth_cred_t);
+
+#define VOP_GETEXTATTR_DESCOFFSET 43
+struct vop_getextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_attrnamespace;
+ const char *a_name;
+ struct uio *a_uio;
+ size_t *a_size;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_getextattr_desc;
+int VOP_GETEXTATTR(struct vnode *, int, const char *, struct uio *,
+ size_t *, kauth_cred_t);
+
+#define VOP_LISTEXTATTR_DESCOFFSET 44
+struct vop_listextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_attrnamespace;
+ struct uio *a_uio;
+ size_t *a_size;
+ int a_flag;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_listextattr_desc;
+int VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *, int,
+ kauth_cred_t);
+
+#define VOP_OPENEXTATTR_DESCOFFSET 45
+struct vop_openextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_openextattr_desc;
+int VOP_OPENEXTATTR(struct vnode *, kauth_cred_t);
+
+#define VOP_DELETEEXTATTR_DESCOFFSET 46
+struct vop_deleteextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_attrnamespace;
+ const char *a_name;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_deleteextattr_desc;
+int VOP_DELETEEXTATTR(struct vnode *, int, const char *, kauth_cred_t);
+
+#define VOP_SETEXTATTR_DESCOFFSET 47
+struct vop_setextattr_args {
+ const struct vnodeop_desc *a_desc;
+ struct vnode *a_vp;
+ int a_attrnamespace;
+ const char *a_name;
+ struct uio *a_uio;
+ kauth_cred_t a_cred;
+};
+extern const struct vnodeop_desc vop_setextattr_desc;
+int VOP_SETEXTATTR(struct vnode *, int, const char *, struct uio *,
+ kauth_cred_t);
+
+#define VNODE_OPS_COUNT 48
+
+#endif /* !_SYS_VNODE_IF_H_ */
--- /dev/null
+/* $NetBSD: wapbl.h,v 1.13 2011/11/21 04:36:06 christos Exp $ */
+
+/*-
+ * Copyright (c) 2003,2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_WAPBL_H
+#define _SYS_WAPBL_H
+
+#include <sys/mutex.h>
+
+#include <miscfs/specfs/specdev.h>
+
+/* This header file describes the api and data structures for
+ * write ahead physical block logging (WAPBL) support.
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_wapbl.h"
+#endif
+
+#ifdef WAPBL_DEBUG
+#ifndef WAPBL_DEBUG_PRINT
+#define WAPBL_DEBUG_PRINT (WAPBL_PRINT_REPLAY | WAPBL_PRINT_OPEN)
+#endif
+
+#if 0
+#define WAPBL_DEBUG_BUFBYTES
+#endif
+
+#endif
+
+#ifdef WAPBL_DEBUG_PRINT
+
+enum {
+ WAPBL_PRINT_OPEN = 0x1,
+ WAPBL_PRINT_FLUSH = 0x2,
+ WAPBL_PRINT_TRUNCATE = 0x4,
+ WAPBL_PRINT_TRANSACTION = 0x8,
+ WAPBL_PRINT_BUFFER = 0x10,
+ WAPBL_PRINT_BUFFER2 = 0x20,
+ WAPBL_PRINT_ALLOC = 0x40,
+ WAPBL_PRINT_INODE = 0x80,
+ WAPBL_PRINT_WRITE = 0x100,
+ WAPBL_PRINT_IO = 0x200,
+ WAPBL_PRINT_REPLAY = 0x400,
+ WAPBL_PRINT_ERROR = 0x800,
+ WAPBL_PRINT_DISCARD = 0x1000,
+ WAPBL_PRINT_BIODONE = 0x2000,
+};
+
+#define WAPBL_PRINTF(mask, a) if (wapbl_debug_print & (mask)) printf a
+extern int wapbl_debug_print;
+#else
+#define WAPBL_PRINTF(mask, a)
+#endif
+
+/****************************************************************/
+
+#include <sys/queue.h>
+#include <sys/vnode.h>
+#include <sys/buf.h>
+
+#ifdef _KERNEL
+
+struct wapbl_entry;
+struct wapbl_replay;
+struct wapbl;
+
+typedef void (*wapbl_flush_fn_t)(struct mount *, daddr_t *, int *, int);
+
+/*
+ * This structure holds per transaction log information
+ */
+struct wapbl_entry {
+ struct wapbl *we_wapbl;
+ SIMPLEQ_ENTRY(wapbl_entry) we_entries;
+ size_t we_bufcount; /* Count of unsynced buffers */
+ size_t we_reclaimable_bytes; /* Number on disk bytes for this
+ transaction */
+ int we_error;
+#ifdef WAPBL_DEBUG_BUFBYTES
+ size_t we_unsynced_bufbytes; /* Byte count of unsynced buffers */
+#endif
+};
+
+/* Start using a log */
+int wapbl_start(struct wapbl **, struct mount *, struct vnode *, daddr_t,
+ size_t, size_t, struct wapbl_replay *,
+ wapbl_flush_fn_t, wapbl_flush_fn_t);
+
+/* Discard the current transaction, potentially dangerous */
+void wapbl_discard(struct wapbl *);
+
+/* stop using a log */
+int wapbl_stop(struct wapbl *, int);
+
+/*
+ * Begin a new transaction or increment transaction recursion
+ * level if called while a transaction is already in progress
+ * by the current process.
+ */
+int wapbl_begin(struct wapbl *, const char *, int);
+
+
+/* End a transaction or decrement the transaction recursion level */
+void wapbl_end(struct wapbl *);
+
+/*
+ * Add a new buffer to the current transaction. The buffers
+ * data will be copied to the current transaction log and the
+ * buffer will be marked B_LOCKED so that it will not be
+ * flushed to disk by the syncer or reallocated.
+ */
+void wapbl_add_buf(struct wapbl *, struct buf *);
+
+/* Remove a buffer from the current transaction. */
+void wapbl_remove_buf(struct wapbl *, struct buf *);
+
+void wapbl_resize_buf(struct wapbl *, struct buf *, long, long);
+
+/*
+ * This will flush all completed transactions to disk and
+ * start asynchronous writes on the associated buffers
+ */
+int wapbl_flush(struct wapbl *, int);
+
+/*
+ * Inodes that are allocated but have zero link count
+ * must be registered with the current transaction
+ * so they may be recorded in the log and cleaned up later.
+ * registration/unregistration of ino numbers already registered is ok.
+ */
+void wapbl_register_inode(struct wapbl *, ino_t, mode_t);
+void wapbl_unregister_inode(struct wapbl *, ino_t, mode_t);
+
+/*
+ * Metadata block deallocations must be registered so
+ * that revocations records can be written and to prevent
+ * the corresponding blocks from being reused as data
+ * blocks until the log is on disk.
+ */
+void wapbl_register_deallocation(struct wapbl *, daddr_t, int);
+
+void wapbl_jlock_assert(struct wapbl *wl);
+void wapbl_junlock_assert(struct wapbl *wl);
+
+void wapbl_print(struct wapbl *wl, int full, void (*pr)(const char *, ...)
+ __printflike(1, 2));
+
+#if defined(WAPBL_DEBUG) || defined(DDB)
+void wapbl_dump(struct wapbl *);
+#endif
+
+void wapbl_biodone(struct buf *);
+
+extern struct wapbl_ops wapbl_ops;
+
+static __inline struct mount *
+wapbl_vptomp(struct vnode *vp)
+{
+ struct mount *mp;
+
+ mp = NULL;
+ if (vp != NULL) {
+ if (vp->v_type == VBLK)
+ mp = vp->v_specmountpoint;
+ else
+ mp = vp->v_mount;
+ }
+
+ return mp;
+}
+
+static __inline bool
+wapbl_vphaswapbl(struct vnode *vp)
+{
+ struct mount *mp;
+
+ if (vp == NULL)
+ return false;
+
+ mp = wapbl_vptomp(vp);
+ if (mp && mp->mnt_wapbl)
+ return true;
+ else
+ return false;
+}
+
+#endif /* _KERNEL */
+
+/****************************************************************/
+/* Replay support */
+
+#ifdef WAPBL_INTERNAL
+struct wapbl_replay {
+ struct vnode *wr_logvp;
+ struct vnode *wr_devvp;
+ daddr_t wr_logpbn;
+
+ int wr_log_dev_bshift;
+ int wr_fs_dev_bshift;
+ int64_t wr_circ_off;
+ int64_t wr_circ_size;
+ uint32_t wr_generation;
+
+ void *wr_scratch;
+
+ LIST_HEAD(wapbl_blk_head, wapbl_blk) *wr_blkhash;
+ u_long wr_blkhashmask;
+ int wr_blkhashcnt;
+
+ off_t wr_inodeshead;
+ off_t wr_inodestail;
+ int wr_inodescnt;
+ struct {
+ uint32_t wr_inumber;
+ uint32_t wr_imode;
+ } *wr_inodes;
+};
+
+#define wapbl_replay_isopen(wr) ((wr)->wr_scratch != 0)
+
+/* Supply this to provide i/o support */
+int wapbl_write(void *, size_t, struct vnode *, daddr_t);
+int wapbl_read(void *, size_t, struct vnode *, daddr_t);
+
+/****************************************************************/
+#else
+struct wapbl_replay;
+#endif /* WAPBL_INTERNAL */
+
+/****************************************************************/
+
+int wapbl_replay_start(struct wapbl_replay **, struct vnode *,
+ daddr_t, size_t, size_t);
+void wapbl_replay_stop(struct wapbl_replay *);
+void wapbl_replay_free(struct wapbl_replay *);
+int wapbl_replay_write(struct wapbl_replay *, struct vnode *);
+int wapbl_replay_can_read(struct wapbl_replay *, daddr_t, long);
+int wapbl_replay_read(struct wapbl_replay *, void *, daddr_t, long);
+
+/****************************************************************/
+
+#endif /* !_SYS_WAPBL_H */
--- /dev/null
+/* $NetBSD: wapbl_replay.h,v 1.1 2008/11/24 16:05:21 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2003,2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_WAPBL_REPLAY_H
+#define _SYS_WAPBL_REPLAY_H
+
+#include <sys/types.h>
+
+/* The WAPBL journal layout.
+ *
+ * The journal consists of a header followed by a circular buffer
+ * region. The circular data area is described by the header
+ * wc_circ_off, wc_circ_size, wc_head and wc_tail fields as bytes
+ * from the start of the journal header. New records are inserted
+ * at wc_head and the oldest valid record can be found at wc_tail.
+ * When ((wc_head == wc_tail) && (wc_head == 0)), the journal is empty.
+ * The condition of ((wc_head == wc_tail) && (wc_head != 0))
+ * indicates a full journal, although this condition is rare.
+ *
+ * The journal header as well as its records are marked by a 32bit
+ * type tag and length for ease of parsing. Journal records are
+ * padded so as to fall on journal device block boundaries.
+ */
+
+/*
+ * The following are the 4 record types used by the journal:
+ * Each tag indicates journal data organized by one of the
+ * structures used below.
+ */
+enum {
+ WAPBL_WC_HEADER = 0x5741424c, /* "WABL", struct wapbl_wc_header */
+ WAPBL_WC_INODES, /* struct wapbl_wc_inodelist */
+ WAPBL_WC_REVOCATIONS, /* struct wapbl_wc_blocklist */
+ WAPBL_WC_BLOCKS, /* struct wapbl_wc_blocklist */
+};
+
+/* null entry (on disk) */
+/* This structure isn't used directly, but shares its header
+ * layout with all the other log structures for the purpose
+ * of reading a log structure and determining its type
+ */
+struct wapbl_wc_null {
+ uint32_t wc_type; /* WAPBL_WC_* */
+ int32_t wc_len;
+ uint8_t wc_spare[0]; /* actually longer */
+};
+
+/* journal header (on-disk)
+ * This record is found at the start of the
+ * journal, but not within the circular buffer region. As well as
+ * describing the journal parameters and matching filesystem, it
+ * additionally serves as the atomic update record for journal
+ * updates.
+ */
+struct wapbl_wc_header {
+ uint32_t wc_type; /* WAPBL_WC_HEADER log magic number */
+ int32_t wc_len; /* length of this journal entry */
+ uint32_t wc_checksum;
+ uint32_t wc_generation;
+ int32_t wc_fsid[2];
+ uint64_t wc_time;
+ uint32_t wc_timensec;
+ uint32_t wc_version;
+ uint32_t wc_log_dev_bshift;
+ uint32_t wc_fs_dev_bshift;
+ int64_t wc_head;
+ int64_t wc_tail;
+ int64_t wc_circ_off; /* offset of of circ buffer region */
+ int64_t wc_circ_size; /* size of circular buffer region */
+ uint8_t wc_spare[0]; /* actually longer */
+};
+
+/* list of blocks (on disk)
+ * This record is used to describe a set of filesystem blocks,
+ * and is used with two type tags, WAPBL_WC_BLOCKS and
+ * WAPBL_WC_REVOCATIONS.
+ *
+ * For WAPBL_WC_BLOCKS, a copy of each listed block can be found
+ * starting at the next log device blocksize boundary. starting at
+ * one log device block since the start of the record. This contains
+ * the bulk of the filesystem journal data which is written using
+ * these records before being written into the filesystem.
+ *
+ * The WAPBL_WC_REVOCATIONS record is used to indicate that any
+ * previously listed blocks should not be written into the filesystem.
+ * This is important so that deallocated and reallocated data blocks
+ * do not get overwritten with stale data from the journal. The
+ * revocation records do not contain a copy of any actual block data.
+ */
+struct wapbl_wc_blocklist {
+ uint32_t wc_type; /* WAPBL_WC_{REVOCATIONS,BLOCKS} */
+ int32_t wc_len;
+ int32_t wc_blkcount;
+ int32_t wc_unused;
+ struct {
+ int64_t wc_daddr;
+ int32_t wc_unused;
+ int32_t wc_dlen;
+ } wc_blocks[0]; /* actually longer */
+};
+
+/* list of inodes (on disk)
+ * This record is used to describe the set of inodes which
+ * may be allocated but are unlinked. Inodes end up listed here
+ * while they are in the process of being initialized and
+ * deinitialized. Inodes unlinked while in use by a process
+ * will be listed here and the actual deletion must be completed
+ * on journal replay.
+ */
+struct wapbl_wc_inodelist {
+ uint32_t wc_type; /* WAPBL_WC_INODES */
+ int32_t wc_len;
+ int32_t wc_inocnt;
+ int32_t wc_clear; /* set if previously listed inodes
+ hould be ignored */
+ struct {
+ uint32_t wc_inumber;
+ uint32_t wc_imode;
+ } wc_inodes[0]; /* actually longer */
+};
+
+#endif /* _SYS_WAPBL_REPLAY_H */
--- /dev/null
+/* $NetBSD: wdog.h,v 1.3 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000 Zembu Labs, Inc.
+ * All rights reserved.
+ *
+ * Author: Jason R. Thorpe <thorpej@zembu.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Zembu Labs, Inc.
+ * 4. Neither the name of Zembu Labs nor the names of its employees may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
+ * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
+ * CLAIMED. IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_WDOG_H_
+#define _SYS_WDOG_H_
+
+#include <sys/ioccom.h>
+
+/*
+ * Definitions for manipulating watchdog timers.
+ */
+
+/* This must match struct device's "dv_xname" size. */
+#define WDOG_NAMESIZE 16
+
+struct wdog_mode {
+ char wm_name[WDOG_NAMESIZE];
+ int wm_mode; /* timer mode */
+ u_int wm_period; /* timer period (seconds) */
+};
+
+/*
+ * GMODE -- get mode of watchdog specified by wm_name.
+ *
+ * SMODE -- set mode of watchdog specified by wm_mame. If
+ * wm_mode is not DISARMED, the watchdog is armed,
+ * if another watchdog is not already running.
+ */
+#define WDOGIOC_GMODE _IOWR('w', 0, struct wdog_mode)
+#define WDOGIOC_SMODE _IOW('w', 1, struct wdog_mode)
+
+/*
+ * WHICH -- returns the mode information of the currently armed
+ * watchdog timer.
+ */
+#define WDOGIOC_WHICH _IOR('w', 2, struct wdog_mode)
+
+/*
+ * TICKLE -- tickle the currently armed watchdog timer if the
+ * mode of that timer is UTICKLE.
+ */
+#define WDOGIOC_TICKLE _IO('w', 3)
+
+/*
+ * GTICKLER -- get the PID of the last process to tickle the timer.
+ */
+#define WDOGIOC_GTICKLER _IOR('w', 4, pid_t)
+
+/*
+ * GWDOGS -- fill in the character array with the names of all of
+ * the watchdog timers present on the system. The names
+ * will be padded out to WDOG_NAMESIZE. Thus, the argument
+ * should be (count * WDOG_NAMESIZE) bytes long.
+ */
+struct wdog_conf {
+ char *wc_names;
+ int wc_count;
+};
+#define WDOGIOC_GWDOGS _IOWR('w', 5, struct wdog_conf)
+
+#define WDOG_MODE_DISARMED 0 /* watchdog is disarmed */
+#define WDOG_MODE_KTICKLE 1 /* kernel tickles watchdog */
+#define WDOG_MODE_UTICKLE 2 /* user tickles watchdog */
+#define WDOG_MODE_ETICKLE 3 /* external program tickles watchdog */
+
+#define WDOG_MODE_MASK 0x03
+
+#define WDOG_FEATURE_ALARM 0x10 /* enable audible alarm on expire */
+
+#define WDOG_FEATURE_MASK 0x10
+
+#define WDOG_PERIOD_DEFAULT ((u_int)-1)
+
+/* Period is expressed in seconds. */
+#define WDOG_PERIOD_TO_TICKS(period) ((period) * hz)
+
+#endif /* _SYS_WDOG_H_ */
--- /dev/null
+/* $NetBSD: workqueue.h,v 1.9 2007/10/19 12:16:48 ad Exp $ */
+
+/*-
+ * Copyright (c)2002, 2005 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_WORKQUEUE_H_
+#define _SYS_WORKQUEUE_H_
+
+struct cpu_info;
+
+/*
+ * a simple "do it in thread context" framework.
+ *
+ * this framework is designed to make struct work small as
+ * far as possible, so that it can be embedded into other structures
+ * without too much cost.
+ */
+
+struct work {
+ void *wk_dummy;
+};
+
+struct workqueue;
+
+#define WQ_MPSAFE 0x01
+#define WQ_PERCPU 0x02
+
+int workqueue_create(struct workqueue **, const char *,
+ void (*)(struct work *, void *), void *, pri_t, int, int);
+void workqueue_destroy(struct workqueue *);
+
+void workqueue_enqueue(struct workqueue *, struct work *, struct cpu_info *);
+
+#endif /* _SYS_WORKQUEUE_H_ */
--- /dev/null
+/* $NetBSD: xattr.h,v 1.5 2011/09/27 01:40:32 christos Exp $ */
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Support for file system extended attributes.
+ *
+ * This provides an interface that is compatible with Linux's extended
+ * attribute support. These calls operate on the same extended attributes
+ * as <sys/extattr.h>, but access only the "user" namespace.
+ */
+
+#ifndef _SYS_XATTR_H_
+#define _SYS_XATTR_H_
+
+#include <sys/types.h>
+#include <sys/param.h>
+
+/*
+ * This is compatible with EXTATTR_MAXNAMELEN, and also happens to be
+ * the same as Linux (255).
+ */
+#define XATTR_NAME_MAX KERNEL_NAME_MAX
+
+#define XATTR_SIZE_MAX 65536 /* NetBSD does not enforce this */
+
+#define XATTR_CREATE 0x01 /* create, don't replace xattr */
+#define XATTR_REPLACE 0x02 /* replace, don't create xattr */
+
+#ifndef _KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int setxattr(const char *, const char *, const void *, size_t, int);
+int lsetxattr(const char *, const char *, const void *, size_t, int);
+int fsetxattr(int, const char *, const void *, size_t, int);
+
+ssize_t getxattr(const char *, const char *, void *, size_t);
+ssize_t lgetxattr(const char *, const char *, void *, size_t);
+ssize_t fgetxattr(int, const char *, void *, size_t);
+
+ssize_t listxattr(const char *, char *, size_t);
+ssize_t llistxattr(const char *, char *, size_t);
+ssize_t flistxattr(int, char *, size_t);
+
+int removexattr(const char *, const char *);
+int lremovexattr(const char *, const char *);
+int fremovexattr(int, const char *);
+__END_DECLS
+
+#endif /* ! _KERNEL */
+
+#endif /* _SYS_XATTR_H_ */
--- /dev/null
+/* $NetBSD: xcall.h,v 1.4 2010/06/22 18:29:01 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_XCALL_H_
+#define _SYS_XCALL_H_
+
+#ifdef _KERNEL
+#define XC_HIGHPRI 0x01 /* high priority */
+
+typedef void (*xcfunc_t)(void *, void *);
+
+struct cpu_info;
+
+void xc_init_cpu(struct cpu_info *);
+void xc_send_ipi(struct cpu_info *);
+void xc_ipi_handler(void);
+
+uint64_t xc_broadcast(u_int, xcfunc_t, void *, void *);
+uint64_t xc_unicast(u_int, xcfunc_t, void *, void *, struct cpu_info *);
+void xc_wait(uint64_t);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_XCALL_H_ */
--- /dev/null
+# $NetBSD: Makefile,v 1.9 2006/02/11 12:45:07 yamt Exp $
+
+INCSDIR= /usr/include/uvm
+
+INCS= uvm.h uvm_amap.h uvm_anon.h uvm_aobj.h uvm_device.h \
+ uvm_extern.h uvm_fault.h uvm_fault_i.h uvm_glue.h \
+ uvm_km.h uvm_loan.h \
+ uvm_map.h uvm_object.h uvm_page.h \
+ uvm_pager.h uvm_param.h uvm_pdaemon.h uvm_pglist.h \
+ uvm_pmap.h uvm_prot.h uvm_stat.h \
+ uvm_swap.h
+
+.include <bsd.kinc.mk>
--- /dev/null
+# $NetBSD: files.uvm,v 1.20 2011/05/17 05:32:31 mrg Exp $
+
+#
+# UVM options
+#
+defflag opt_uvmhist.h UVMHIST UVMHIST_PRINT: KERNHIST
+defflag opt_uvm.h USE_TOPDOWN_VM UVMMAP_COUNTERS
+defflag opt_vmswap.h VMSWAP
+defflag opt_readahead.h READAHEAD_STATS
+defflag opt_ubc.h UBC_STATS
+defparam opt_pagermap.h PAGER_MAP_SIZE
+defflag PDPOLICY_CLOCKPRO
+defparam USER_VA0_DISABLE_DEFAULT
+defflag opt_uvm_page_trkown.h UVM_PAGE_TRKOWN
+
+file uvm/uvm_amap.c
+file uvm/uvm_anon.c
+file uvm/uvm_aobj.c
+file uvm/uvm_bio.c
+file uvm/uvm_coredump.c coredump
+file uvm/uvm_device.c
+file uvm/uvm_emap.c
+file uvm/uvm_fault.c
+file uvm/uvm_glue.c
+file uvm/uvm_init.c
+file uvm/uvm_io.c
+file uvm/uvm_km.c
+file uvm/uvm_kmguard.c debug
+file uvm/uvm_loan.c
+file uvm/uvm_map.c
+file uvm/uvm_meter.c
+file uvm/uvm_mmap.c
+file uvm/uvm_mremap.c
+file uvm/uvm_object.c
+file uvm/uvm_page.c
+file uvm/uvm_pager.c
+file uvm/uvm_pdaemon.c
+file uvm/uvm_pdpolicy_clock.c !pdpolicy_clockpro
+file uvm/uvm_pdpolicy_clockpro.c pdpolicy_clockpro
+file uvm/uvm_pglist.c
+file uvm/uvm_readahead.c
+file uvm/uvm_stat.c
+file uvm/uvm_swap.c vmswap
+file uvm/uvm_swapstub.c !vmswap
+file uvm/uvm_unix.c
+file uvm/uvm_user.c
+file uvm/uvm_vnode.c
--- /dev/null
+/* $NetBSD: pmap.h,v 1.1 2012/10/03 00:51:46 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pmap.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Copyright (c) 1987 Carnegie-Mellon University
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pmap.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _COMMON_PMAP_H_
+#define _COMMON_PMAP_H_
+
+#include <uvm/uvm_stat.h>
+#ifdef UVMHIST
+UVMHIST_DECL(pmapexechist);
+UVMHIST_DECL(pmaphist);
+#endif
+
+/*
+ * The user address space is mapped using a two level structure where
+ * virtual address bits 31..22 are used to index into a segment table which
+ * points to a page worth of PTEs (4096 page can hold 1024 PTEs).
+ * Bits 21..12 are then used to index a PTE which describes a page within
+ * a segment.
+ */
+
+#define pmap_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET)
+#define pmap_round_seg(x) (((vaddr_t)(x) + SEGOFSET) & ~SEGOFSET)
+
+/*
+ * Each seg_tab point an array of pt_entry [NPTEPG]
+ */
+typedef union pmap_segtab {
+ union pmap_segtab * seg_seg[PMAP_SEGTABSIZE];
+ pt_entry_t * seg_tab[PMAP_SEGTABSIZE];
+} pmap_segtab_t;
+
+#ifdef _KERNEL
+struct pmap;
+typedef bool (*pte_callback_t)(struct pmap *, vaddr_t, vaddr_t,
+ pt_entry_t *, uintptr_t);
+pt_entry_t *pmap_pte_lookup(struct pmap *, vaddr_t);
+pt_entry_t *pmap_pte_reserve(struct pmap *, vaddr_t, int);
+void pmap_pte_process(struct pmap *, vaddr_t, vaddr_t, pte_callback_t,
+ uintptr_t);
+void pmap_segtab_activate(struct pmap *, struct lwp *);
+void pmap_segtab_init(struct pmap *);
+void pmap_segtab_destroy(struct pmap *, pte_callback_t, uintptr_t);
+extern kmutex_t pmap_segtab_lock;
+#endif /* _KERNEL */
+
+/*
+ * Per TLB (normally same as CPU) asid info
+ */
+struct pmap_asid_info {
+ LIST_ENTRY(pmap_asid_info) pai_link;
+ uint32_t pai_asid; /* TLB address space tag */
+};
+
+#define TLBINFO_LOCK(ti) mutex_spin_enter((ti)->ti_lock)
+#define TLBINFO_UNLOCK(ti) mutex_spin_exit((ti)->ti_lock)
+#define PMAP_PAI_ASIDVALID_P(pai, ti) ((pai)->pai_asid != 0)
+#define PMAP_PAI(pmap, ti) (&(pmap)->pm_pai[tlbinfo_index(ti)])
+#define PAI_PMAP(pai, ti) \
+ ((pmap_t)((intptr_t)(pai) \
+ - offsetof(struct pmap, pm_pai[tlbinfo_index(ti)])))
+
+/*
+ * Machine dependent pmap structure.
+ */
+struct pmap {
+#ifdef MULTIPROCESSOR
+ __cpuset_t pm_active; /* pmap was active on ... */
+ __cpuset_t pm_onproc; /* pmap is active on ... */
+ volatile u_int pm_shootdown_pending;
+#endif
+ pmap_segtab_t * pm_segtab; /* pointers to pages of PTEs */
+ u_int pm_count; /* pmap reference count */
+ u_int pm_flags;
+#define PMAP_DEFERRED_ACTIVATE 0x0001
+ struct pmap_statistics pm_stats; /* pmap statistics */
+ vaddr_t pm_minaddr;
+ vaddr_t pm_maxaddr;
+ struct pmap_asid_info pm_pai[1];
+};
+
+enum tlb_invalidate_op {
+ TLBINV_NOBODY=0,
+ TLBINV_ONE=1,
+ TLBINV_ALLUSER=2,
+ TLBINV_ALLKERNEL=3,
+ TLBINV_ALL=4
+};
+
+struct pmap_tlb_info {
+ char ti_name[8];
+ uint32_t ti_asid_hint; /* probable next ASID to use */
+ uint32_t ti_asids_free; /* # of ASIDs free */
+#define tlbinfo_noasids_p(ti) ((ti)->ti_asids_free == 0)
+ kmutex_t *ti_lock;
+ u_int ti_wired; /* # of wired TLB entries */
+ uint32_t ti_asid_max;
+ LIST_HEAD(, pmap_asid_info) ti_pais; /* list of active ASIDs */
+#ifdef MULTIPROCESSOR
+ pmap_t ti_victim;
+ uint32_t ti_synci_page_bitmap; /* page indices needing a syncicache */
+ __cpuset_t ti_cpu_mask; /* bitmask of CPUs sharing this TLB */
+ enum tlb_invalidate_op ti_tlbinvop;
+ u_int ti_index;
+#define tlbinfo_index(ti) ((ti)->ti_index)
+ struct evcnt ti_evcnt_synci_asts;
+ struct evcnt ti_evcnt_synci_all;
+ struct evcnt ti_evcnt_synci_pages;
+ struct evcnt ti_evcnt_synci_deferred;
+ struct evcnt ti_evcnt_synci_desired;
+ struct evcnt ti_evcnt_synci_duplicate;
+#else
+#define tlbinfo_index(ti) (0)
+#endif
+ struct evcnt ti_evcnt_asid_reinits;
+ u_long ti_asid_bitmap[256 / (sizeof(u_long) * 8)];
+};
+
+#ifdef _KERNEL
+
+struct pmap_kernel {
+ struct pmap kernel_pmap;
+#ifdef MULTIPROCESSOR
+ struct pmap_asid_info kernel_pai[MAXCPUS-1];
+#endif
+};
+
+struct pmap_limits {
+ paddr_t avail_start;
+ paddr_t avail_end;
+ vaddr_t virtual_end;
+};
+
+/*
+ * The pools from which pmap structures and sub-structures are allocated.
+ */
+extern struct pool pmap_pmap_pool;
+extern struct pool pmap_pv_pool;
+extern struct pool_allocator pmap_pv_page_allocator;
+
+extern struct pmap_kernel kernel_pmap_store;
+extern struct pmap_tlb_info pmap_tlb0_info;
+#ifdef MULTIPROCESSOR
+extern struct pmap_tlb_info *pmap_tlbs[MAXCPUS];
+extern u_int pmap_ntlbs;
+#endif
+extern struct pmap_limits pmap_limits;
+
+#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
+#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
+
+/*
+ * Bootstrap the system enough to run with virtual memory.
+ */
+void pmap_remove_all(pmap_t);
+void pmap_set_modified(paddr_t);
+bool pmap_page_clear_attributes(struct vm_page_md *, u_int);
+void pmap_page_set_attributes(struct vm_page_md *, u_int);
+void pmap_pvlist_lock_init(size_t);
+
+#define PMAP_WB 0
+#define PMAP_WBINV 1
+#define PMAP_INV 2
+
+#ifdef MULTIPROCESSOR
+void pmap_tlb_shootdown_process(void);
+bool pmap_tlb_shootdown_bystanders(pmap_t pmap);
+void pmap_tlb_info_attach(struct pmap_tlb_info *, struct cpu_info *);
+void pmap_md_tlb_info_attach(struct pmap_tlb_info *, struct cpu_info *);
+void pmap_syncicache_ast(struct cpu_info *);
+void pmap_syncicache_wanted(struct cpu_info *);
+void pmap_syncicache(vaddr_t, uint32_t);
+#endif
+void pmap_tlb_info_init(struct pmap_tlb_info *);
+void pmap_tlb_info_evcnt_attach(struct pmap_tlb_info *);
+void pmap_tlb_asid_acquire(pmap_t, struct lwp *l);
+void pmap_tlb_asid_deactivate(pmap_t);
+void pmap_tlb_asid_release_all(pmap_t);
+int pmap_tlb_update_addr(pmap_t, vaddr_t, uint32_t, u_int);
+#define PMAP_TLB_NEED_IPI 0x01
+#define PMAP_TLB_INSERT 0x02
+void pmap_tlb_invalidate_addr(pmap_t, vaddr_t);
+void pmap_tlb_check(pmap_t, bool (*)(void *, vaddr_t, tlb_asid_t, pt_entry_t));
+void pmap_tlb_asid_check(void);
+
+uint16_t pmap_pvlist_lock(struct vm_page_md *, bool);
+
+#define PMAP_STEAL_MEMORY /* enable pmap_steal_memory() */
+#define PMAP_GROWKERNEL /* enable pmap_growkernel() */
+
+/*
+ * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
+ */
+vaddr_t pmap_map_poolpage(paddr_t);
+paddr_t pmap_unmap_poolpage(vaddr_t);
+struct vm_page *pmap_md_alloc_poolpage(int);
+#define PMAP_ALLOC_POOLPAGE(flags) pmap_md_alloc_poolpage(flags)
+#define PMAP_MAP_POOLPAGE(pa) pmap_map_poolpage(pa)
+#define PMAP_UNMAP_POOLPAGE(va) pmap_unmap_poolpage(va)
+
+#endif /* _KERNEL */
+#endif /* _COMMON_PMAP_H_ */
--- /dev/null
+/* $NetBSD: tlb.h,v 1.1 2012/10/03 00:51:47 christos Exp $ */
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _COMMON_PMAP_TLB_TLB_H_
+#define _COMMON_PMAP_TLB_TLB_H_
+
+#if defined(_KERNEL) || defined(_KMEMUSER)
+
+struct tlbmask;
+
+struct tlb_md_ops {
+ void (*md_tlb_set_asid)(tlb_asid_t);
+ tlb_asid_t
+ (*md_tlb_get_asid)(void);
+ void (*md_tlb_invalidate_all)(void);
+ void (*md_tlb_invalidate_globals)(void);
+ void (*md_tlb_invalidate_asids)(tlb_asid_t, tlb_asid_t);
+ void (*md_tlb_invalidate_addr)(vaddr_t, tlb_asid_t);
+ bool (*md_tlb_update_addr)(vaddr_t, tlb_asid_t, pt_entry_t, bool);
+ void (*md_tlb_read_entry)(size_t, struct tlbmask *);
+ void (*md_tlb_write_entry)(size_t, const struct tlbmask *);
+ u_int (*md_tlb_record_asids)(u_long *);
+ void (*md_tlb_dump)(void (*)(const char *, ...));
+ void (*md_tlb_walk)(void *, bool (*)(void *, vaddr_t, tlb_asid_t,
+ pt_entry_t));
+};
+
+tlb_asid_t
+ tlb_get_asid(void);
+void tlb_set_asid(tlb_asid_t);
+void tlb_invalidate_all(void);
+void tlb_invalidate_globals(void);
+void tlb_invalidate_asids(tlb_asid_t, tlb_asid_t);
+void tlb_invalidate_addr(vaddr_t, tlb_asid_t);
+bool tlb_update_addr(vaddr_t, tlb_asid_t, pt_entry_t, bool);
+u_int tlb_record_asids(u_long *);
+void tlb_enter_addr(size_t, const struct tlbmask *);
+void tlb_read_entry(size_t, struct tlbmask *);
+void tlb_write_entry(size_t, const struct tlbmask *);
+void tlb_walk(void *, bool (*)(void *, vaddr_t, tlb_asid_t, pt_entry_t));
+void tlb_dump(void (*)(const char *, ...));
+
+#endif /* _KERNEL || _KMEMUSER */
+
+#endif /* !_COMMON_PMAP_TLB_TLB_H_ */
--- /dev/null
+/* $NetBSD: vmpagemd.h,v 1.1 2012/10/03 00:51:47 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
+ * Agency and which was developed by Matt Thomas of 3am Software Foundry.
+ *
+ * This material is based upon work supported by the Defense Advanced Research
+ * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
+ * Contract No. N66001-09-C-2073.
+ * Approved for Public Release, Distribution Unlimited
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _COMMON_PMAP_TLB_VMPAGEMD_H_
+#define _COMMON_PMAP_TLB_VMPAGEMD_H_
+
+#ifdef _LOCORE
+#error use assym.h instead
+#endif
+
+#ifdef _MODULE
+#error this file should not be included by loadable kernel modules
+#endif
+
+#include "opt_modular.h"
+#include "opt_multiprocessor.h"
+
+#include <sys/mutex.h>
+
+#define __HAVE_VM_PAGE_MD
+
+typedef struct pv_entry {
+ struct pv_entry *pv_next;
+ struct pmap *pv_pmap;
+ vaddr_t pv_va;
+} *pv_entry_t;
+
+#define VM_PAGEMD_REFERENCED 0x0001 /* page has been recently referenced */
+#define VM_PAGEMD_MODIFIED 0x0002 /* page has been modified */
+#define VM_PAGEMD_POOLPAGE 0x0004 /* page is used as a poolpage */
+#define VM_PAGEMD_EXECPAGE 0x0008 /* page is exec mapped */
+#ifdef __PMAP_VIRTUAL_CACHE_ALIASES
+#define VM_PAGEMD_UNCACHED 0x0010 /* page is mapped uncached */
+#endif
+
+#ifdef __PMAP_VIRTUAL_CACHE_ALIASES
+#define VM_PAGEMD_CACHED_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_UNCACHED) == 0)
+#define VM_PAGEMD_UNCACHED_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_UNCACHED) != 0)
+#endif
+#define VM_PAGEMD_MODIFIED_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_MODIFIED) != 0)
+#define VM_PAGEMD_REFERENCED_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_REFERENCED) != 0)
+#define VM_PAGEMD_POOLPAGE_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_POOLPAGE) != 0)
+#define VM_PAGEMD_EXECPAGE_P(mdpg) (((mdpg)->mdpg_attrs & VM_PAGEMD_EXECPAGE) != 0)
+
+struct vm_page_md {
+ volatile u_int mdpg_attrs; /* page attributes */
+ struct pv_entry mdpg_first; /* pv_entry first */
+#if defined(MULTIPROCESSOR) || defined(MODULAR)
+ kmutex_t *mdpg_lock; /* pv list lock */
+#define VM_PAGEMD_PVLIST_LOCK_INIT(mdpg) \
+ (mdpg)->mdpg_lock = NULL
+#define VM_PAGEMD_PVLIST_LOCK(pg, list_change) \
+ pmap_pvlist_lock(mdpg, list_change)
+#define VM_PAGEMD_PVLIST_UNLOCK(mdpg) \
+ mutex_spin_exit((mdpg)->mdpg_lock)
+#define VM_PAGEMD_PVLIST_LOCKED_P(mdpg) \
+ mutex_owner((mdpg)->mdpg_lock)
+#define VM_PAGEMD_PVLIST_GEN(mdpg) \
+ ((uint16_t)((mdpg)->mdpg_attrs >> 16))
+#else
+#define VM_PAGEMD_PVLIST_LOCK_INIT(mdpg) do { } while (/*CONSTCOND*/ 0)
+#define VM_PAGEMD_PVLIST_LOCK(mdpg, lc) (mutex_spin_enter(&pmap_pvlist_mutex), 0)
+#define VM_PAGEMD_PVLIST_UNLOCK(mdpg) mutex_spin_exit(&pmap_pvlist_mutex)
+#define VM_PAGEMD_PVLIST_LOCKED_P(mdpg) true
+#define VM_PAGEMD_PVLIST_GEN(mdpg) (0)
+#endif /* MULTIPROCESSOR || MODULAR */
+};
+
+#define VM_MDPAGE_INIT(pg) \
+do { \
+ (pg)->mdpage.mdpg_first.pv_next = NULL; \
+ (pg)->mdpage.mdpg_first.pv_pmap = NULL; \
+ (pg)->mdpage.mdpg_first.pv_va = (pg)->phys_addr; \
+ (pg)->mdpage.mdpg_attrs = 0; \
+ VM_PAGEMD_PVLIST_LOCK_INIT(&(pg)->mdpage); \
+} while (/* CONSTCOND */ 0)
+
+#endif /* __COMMON_PMAP_TLB_VMPAGEMD_H_ */
--- /dev/null
+/* $NetBSD: uvm.h,v 1.63 2012/02/02 19:43:08 tls Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp
+ */
+
+#ifndef _UVM_UVM_H_
+#define _UVM_UVM_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_lockdebug.h"
+#include "opt_multiprocessor.h"
+#include "opt_uvmhist.h"
+#include "opt_uvm_page_trkown.h"
+#endif
+
+#include <uvm/uvm_extern.h>
+
+#ifdef _KERNEL
+#include <uvm/uvm_stat.h>
+#endif
+
+/*
+ * pull in prototypes
+ */
+
+#include <uvm/uvm_amap.h>
+#include <uvm/uvm_aobj.h>
+#include <uvm/uvm_fault.h>
+#include <uvm/uvm_glue.h>
+#include <uvm/uvm_km.h>
+#include <uvm/uvm_loan.h>
+#include <uvm/uvm_map.h>
+#include <uvm/uvm_object.h>
+#include <uvm/uvm_page.h>
+#include <uvm/uvm_pager.h>
+#include <uvm/uvm_pdaemon.h>
+#include <uvm/uvm_swap.h>
+#include <sys/rnd.h>
+
+#ifdef _KERNEL
+
+/*
+ * pull in VM_NFREELIST
+ */
+#include <machine/vmparam.h>
+
+struct workqueue;
+
+/*
+ * per-cpu data
+ */
+
+struct uvm_cpu {
+ struct pgfreelist page_free[VM_NFREELIST]; /* unallocated pages */
+ int page_free_nextcolor; /* next color to allocate from */
+ int page_idlezero_next; /* which color to zero next */
+ bool page_idle_zero; /* TRUE if we should try to zero
+ pages in the idle loop */
+ int pages[PGFL_NQUEUES]; /* total of pages in page_free */
+ u_int emap_gen; /* emap generation number */
+
+ uintptr_t last_fltaddr; /* last faulted address */
+ uintptr_t last_delta; /* difference of last two flt addrs */
+ uintptr_t last_delta2; /* difference of differences */
+ krndsource_t rs; /* entropy source */
+};
+
+/*
+ * uvm structure (vm global state: collected in one structure for ease
+ * of reference...)
+ */
+
+struct uvm {
+ /* vm_page related parameters */
+
+ /* vm_page queues */
+ struct pgfreelist page_free[VM_NFREELIST]; /* unallocated pages */
+ bool page_init_done; /* TRUE if uvm_page_init() finished */
+
+ /* page daemon trigger */
+ int pagedaemon; /* daemon sleeps on this */
+ struct lwp *pagedaemon_lwp; /* daemon's lid */
+
+ /* aiodone daemon */
+ struct workqueue *aiodone_queue;
+
+ /* aio_done is locked by uvm.pagedaemon_lock and splbio! */
+ TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */
+
+ /* per-cpu data */
+ struct uvm_cpu *cpus[MAXCPUS];
+};
+
+/*
+ * kernel object: to support anonymous pageable kernel memory
+ */
+extern struct uvm_object *uvm_kernel_object;
+
+/*
+ * locks (made globals for lockstat).
+ */
+
+extern kmutex_t uvm_pageqlock; /* lock for active/inactive page q */
+extern kmutex_t uvm_fpageqlock; /* lock for free page q */
+extern kmutex_t uvm_kentry_lock;
+extern kmutex_t uvm_swap_data_lock;
+
+#endif /* _KERNEL */
+
+/*
+ * vm_map_entry etype bits:
+ */
+
+#define UVM_ET_OBJ 0x01 /* it is a uvm_object */
+#define UVM_ET_SUBMAP 0x02 /* it is a vm_map submap */
+#define UVM_ET_COPYONWRITE 0x04 /* copy_on_write */
+#define UVM_ET_NEEDSCOPY 0x08 /* needs_copy */
+
+#define UVM_ET_ISOBJ(E) (((E)->etype & UVM_ET_OBJ) != 0)
+#define UVM_ET_ISSUBMAP(E) (((E)->etype & UVM_ET_SUBMAP) != 0)
+#define UVM_ET_ISCOPYONWRITE(E) (((E)->etype & UVM_ET_COPYONWRITE) != 0)
+#define UVM_ET_ISNEEDSCOPY(E) (((E)->etype & UVM_ET_NEEDSCOPY) != 0)
+
+#ifdef _KERNEL
+
+/*
+ * holds all the internal UVM data
+ */
+extern struct uvm uvm;
+
+/*
+ * historys
+ */
+
+#ifdef UVMHIST
+UVMHIST_DECL(maphist);
+UVMHIST_DECL(pdhist);
+UVMHIST_DECL(ubchist);
+UVMHIST_DECL(loanhist);
+#endif
+
+extern struct evcnt uvm_ra_total;
+extern struct evcnt uvm_ra_hit;
+extern struct evcnt uvm_ra_miss;
+
+/*
+ * UVM_UNLOCK_AND_WAIT: atomic unlock+wait... wrapper around the
+ * interlocked tsleep() function.
+ */
+
+#define UVM_UNLOCK_AND_WAIT(event, slock, intr, msg, timo) \
+do { \
+ (void) mtsleep(event, PVM | PNORELOCK | (intr ? PCATCH : 0), \
+ msg, timo, slock); \
+} while (/*CONSTCOND*/ 0)
+
+void uvm_kick_pdaemon(void);
+
+/*
+ * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN)
+ */
+
+#if defined(UVM_PAGE_TRKOWN)
+#define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG)
+#else
+#define UVM_PAGE_OWN(PG, TAG) /* nothing */
+#endif /* UVM_PAGE_TRKOWN */
+
+#include <uvm/uvm_fault_i.h>
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_H_ */
--- /dev/null
+/* $NetBSD: uvm_amap.h,v 1.37 2011/06/12 03:36:02 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _UVM_UVM_AMAP_H_
+#define _UVM_UVM_AMAP_H_
+
+/*
+ * uvm_amap.h: general amap interface and amap implementation-specific info
+ */
+
+/*
+ * an amap structure contains pointers to a set of anons that are
+ * mapped together in virtual memory (an anon is a single page of
+ * anonymous virtual memory -- see uvm_anon.h). in uvm we hide the
+ * details of the implementation of amaps behind a general amap
+ * interface. this allows us to change the amap implementation
+ * without having to touch the rest of the code. this file is divided
+ * into two parts: the definition of the uvm amap interface and the
+ * amap implementation-specific definitions.
+ */
+
+#ifdef _KERNEL
+
+/*
+ * part 1: amap interface
+ */
+
+void uvm_amap_init(void);
+
+/*
+ * forward definition of vm_amap structure. only amap
+ * implementation-specific code should directly access the fields of
+ * this structure.
+ */
+
+struct vm_amap;
+
+
+/*
+ * prototypes for the amap interface
+ */
+
+void amap_add /* add an anon to an amap */
+ (struct vm_aref *, vaddr_t,
+ struct vm_anon *, bool);
+struct vm_amap *amap_alloc /* allocate a new amap */
+ (vaddr_t, vaddr_t, int);
+void amap_copy /* clear amap needs-copy flag */
+ (struct vm_map *, struct vm_map_entry *, int,
+ vaddr_t, vaddr_t);
+void amap_cow_now /* resolve all COW faults now */
+ (struct vm_map *, struct vm_map_entry *);
+int amap_extend /* make amap larger */
+ (struct vm_map_entry *, vsize_t, int);
+int amap_flags /* get amap's flags */
+ (struct vm_amap *);
+void amap_free /* free amap */
+ (struct vm_amap *);
+void amap_lock /* lock amap */
+ (struct vm_amap *);
+struct vm_anon *amap_lookup /* lookup an anon @ offset in amap */
+ (struct vm_aref *, vaddr_t);
+void amap_lookups /* lookup multiple anons */
+ (struct vm_aref *, vaddr_t,
+ struct vm_anon **, int);
+void amap_ref /* add a reference to an amap */
+ (struct vm_amap *, vaddr_t, vsize_t, int);
+int amap_refs /* get number of references of amap */
+ (struct vm_amap *);
+void amap_share_protect /* protect pages in a shared amap */
+ (struct vm_map_entry *, vm_prot_t);
+void amap_splitref /* split reference to amap into two */
+ (struct vm_aref *, struct vm_aref *, vaddr_t);
+void amap_unadd /* remove an anon from an amap */
+ (struct vm_aref *, vaddr_t);
+void amap_unlock /* unlock amap */
+ (struct vm_amap *);
+void amap_unref /* drop reference to an amap */
+ (struct vm_amap *, vaddr_t, vsize_t, bool);
+void amap_wipeout /* remove all anons from amap */
+ (struct vm_amap *);
+bool amap_swap_off
+ (int, int);
+
+/*
+ * amap flag values
+ */
+
+#define AMAP_SHARED 0x1 /* amap is shared */
+#define AMAP_REFALL 0x2 /* amap_ref: reference entire amap */
+#define AMAP_SWAPOFF 0x4 /* amap_swap_off() is in progress */
+
+/*
+ * amap_copy flags
+ */
+
+#define AMAP_COPY_NOWAIT 0x02 /* not allowed to sleep */
+#define AMAP_COPY_NOCHUNK 0x04 /* not allowed to chunk */
+#define AMAP_COPY_NOMERGE 0x08 /* not allowed to merge */
+
+/*
+ * amap_extend flags
+ */
+#define AMAP_EXTEND_BACKWARDS 0x00 /* add "size" to start of map */
+#define AMAP_EXTEND_FORWARDS 0x01 /* add "size" to end of map */
+#define AMAP_EXTEND_NOWAIT 0x02 /* not allowed to sleep */
+
+#endif /* _KERNEL */
+
+/**********************************************************************/
+
+/*
+ * part 2: amap implementation-specific info
+ */
+
+/*
+ * we currently provide an array-based amap implementation. in this
+ * implementation we provide the option of tracking split references
+ * so that we don't lose track of references during partial unmaps
+ * ... this is enabled with the "UVM_AMAP_PPREF" define.
+ */
+
+#define UVM_AMAP_PPREF /* track partial references */
+
+/*
+ * here is the definition of the vm_amap structure for this implementation.
+ */
+
+struct vm_amap {
+ kmutex_t *am_lock; /* lock [locks all vm_amap fields] */
+ int am_ref; /* reference count */
+ int am_flags; /* flags */
+ int am_maxslot; /* max # of slots allocated */
+ int am_nslot; /* # of slots currently in map ( <= maxslot) */
+ int am_nused; /* # of slots currently in use */
+ int *am_slots; /* contig array of active slots */
+ int *am_bckptr; /* back pointer array to am_slots */
+ struct vm_anon **am_anon; /* array of anonymous pages */
+#ifdef UVM_AMAP_PPREF
+ int *am_ppref; /* per page reference count (if !NULL) */
+#endif
+ LIST_ENTRY(vm_amap) am_list;
+};
+
+/*
+ * note that am_slots, am_bckptr, and am_anon are arrays. this allows
+ * fast lookup of pages based on their virual address at the expense of
+ * some extra memory. in the future we should be smarter about memory
+ * usage and fall back to a non-array based implementation on systems
+ * that are short of memory (XXXCDC).
+ *
+ * the entries in the array are called slots... for example an amap that
+ * covers four pages of virtual memory is said to have four slots. here
+ * is an example of the array usage for a four slot amap. note that only
+ * slots one and three have anons assigned to them. "D/C" means that we
+ * "don't care" about the value.
+ *
+ * 0 1 2 3
+ * am_anon: NULL, anon0, NULL, anon1 (actual pointers to anons)
+ * am_bckptr: D/C, 1, D/C, 0 (points to am_slots entry)
+ *
+ * am_slots: 3, 1, D/C, D/C (says slots 3 and 1 are in use)
+ *
+ * note that am_bckptr is D/C if the slot in am_anon is set to NULL.
+ * to find the entry in am_slots for an anon, look at am_bckptr[slot],
+ * thus the entry for slot 3 in am_slots[] is at am_slots[am_bckptr[3]].
+ * in general, if am_anon[X] is non-NULL, then the following must be
+ * true: am_slots[am_bckptr[X]] == X
+ *
+ * note that am_slots is always contig-packed.
+ */
+
+/*
+ * defines for handling of large, sparse amaps:
+ *
+ * one of the problems of array-based amaps is that if you allocate a
+ * large, sparsely-used area of virtual memory you end up allocating
+ * large arrays that, for the most part, don't get used. this is a
+ * problem for BSD in that the kernel likes to make these types of
+ * allocations to "reserve" memory for possible future use.
+ *
+ * for example, the kernel allocates (reserves) a large chunk of user
+ * VM for possible stack growth. most of the time only a page or two
+ * of this VM is actually used. since the stack is anonymous memory
+ * it makes sense for it to live in an amap, but if we allocated an
+ * amap for the entire stack range we could end up wasting a large
+ * amount of allocated KVM.
+ *
+ * for example, on the i386 at boot time we allocate two amaps for the stack
+ * of /sbin/init:
+ * 1. a 7680 slot amap at protection 0 (reserve space for stack)
+ * 2. a 512 slot amap at protection 7 (top of stack)
+ *
+ * most of the array allocated for the amaps for this is never used.
+ * the amap interface provides a way for us to avoid this problem by
+ * allowing amap_copy() to break larger amaps up into smaller sized
+ * chunks (controlled by the "canchunk" option). we use this feature
+ * to reduce our memory usage with the BSD stack management. if we
+ * are asked to create an amap with more than UVM_AMAP_LARGE slots in it,
+ * we attempt to break it up into a UVM_AMAP_CHUNK sized amap if the
+ * "canchunk" flag is set.
+ *
+ * so, in the i386 example, the 7680 slot area is never referenced so
+ * nothing gets allocated (amap_copy is never called because the protection
+ * is zero). the 512 slot area for the top of the stack is referenced.
+ * the chunking code breaks it up into 16 slot chunks (hopefully a single
+ * 16 slot chunk is enough to handle the whole stack).
+ */
+
+#define UVM_AMAP_LARGE 256 /* # of slots in "large" amap */
+#define UVM_AMAP_CHUNK 16 /* # of slots to chunk large amaps in */
+
+#ifdef _KERNEL
+
+/*
+ * macros
+ */
+
+/* AMAP_B2SLOT: convert byte offset to slot */
+#define AMAP_B2SLOT(S,B) { \
+ KASSERT(((B) & (PAGE_SIZE - 1)) == 0); \
+ (S) = (B) >> PAGE_SHIFT; \
+}
+
+/*
+ * lock/unlock/refs/flags macros
+ */
+
+#define amap_flags(AMAP) ((AMAP)->am_flags)
+#define amap_lock(AMAP) mutex_enter((AMAP)->am_lock)
+#define amap_lock_try(AMAP) mutex_tryenter((AMAP)->am_lock)
+#define amap_refs(AMAP) ((AMAP)->am_ref)
+#define amap_unlock(AMAP) mutex_exit((AMAP)->am_lock)
+
+/*
+ * if we enable PPREF, then we have a couple of extra functions that
+ * we need to prototype here...
+ */
+
+#ifdef UVM_AMAP_PPREF
+
+#define PPREF_NONE ((int *) -1) /* not using ppref */
+
+void amap_pp_adjref /* adjust references */
+ (struct vm_amap *, int, vsize_t, int,
+ struct vm_anon **);
+void amap_pp_establish /* establish ppref */
+ (struct vm_amap *, vaddr_t);
+void amap_wiperange /* wipe part of an amap */
+ (struct vm_amap *, int, int, struct vm_anon **);
+#endif /* UVM_AMAP_PPREF */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_AMAP_H_ */
--- /dev/null
+/* $NetBSD: uvm_anon.h,v 1.30 2011/08/06 17:25:03 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _UVM_UVM_ANON_H_
+#define _UVM_UVM_ANON_H_
+
+/*
+ * uvm_anon.h
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_vmswap.h"
+#endif
+
+/*
+ * anonymous memory management
+ *
+ * anonymous virtual memory is short term virtual memory that goes away
+ * when the processes referencing it go away. an anonymous page of
+ * virtual memory is described by the following data structure:
+ */
+
+struct vm_anon {
+ kmutex_t *an_lock; /* Lock for an_ref */
+ union {
+ uintptr_t au_ref; /* Reference count [an_lock] */
+ struct vm_anon *au_link; /* Link for deferred free */
+ } an_u;
+#define an_ref an_u.au_ref
+#define an_link an_u.au_link
+ struct vm_page *an_page; /* If in RAM [an_lock] */
+#if defined(VMSWAP) || 1 /* XXX libkvm */
+ /*
+ * Drum swap slot # (if != 0) [an_lock. also, it is ok to read
+ * an_swslot if we hold an_page PG_BUSY].
+ */
+ int an_swslot;
+#endif
+};
+
+/*
+ * for active vm_anon's the data can be in one of the following state:
+ * [1] in a vm_page with no backing store allocated yet, [2] in a vm_page
+ * with backing store allocated, or [3] paged out to backing store
+ * (no vm_page).
+ *
+ * for pageout in case [2]: if the page has been modified then we must
+ * flush it out to backing store, otherwise we can just dump the
+ * vm_page.
+ */
+
+/*
+ * anons are grouped together in anonymous memory maps, or amaps.
+ * amaps are defined in uvm_amap.h.
+ */
+
+/*
+ * processes reference anonymous virtual memory maps with an anonymous
+ * reference structure:
+ */
+
+struct vm_aref {
+ int ar_pageoff; /* page offset into amap we start */
+ struct vm_amap *ar_amap; /* pointer to amap */
+};
+
+/*
+ * the offset field indicates which part of the amap we are referencing.
+ * locked by vm_map lock.
+ */
+
+#ifdef _KERNEL
+
+/*
+ * prototypes
+ */
+
+struct vm_anon *uvm_analloc(void);
+void uvm_anon_free(struct vm_anon *);
+void uvm_anon_freelst(struct vm_amap *, struct vm_anon *);
+void uvm_anon_init(void);
+struct vm_page *uvm_anon_lockloanpg(struct vm_anon *);
+#if defined(VMSWAP)
+void uvm_anon_dropswap(struct vm_anon *);
+#else /* defined(VMSWAP) */
+#define uvm_anon_dropswap(a) /* nothing */
+#endif /* defined(VMSWAP) */
+void uvm_anon_release(struct vm_anon *);
+bool uvm_anon_pagein(struct vm_amap *, struct vm_anon *);
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_ANON_H_ */
--- /dev/null
+/* $NetBSD: uvm_aobj.h,v 1.22 2012/09/14 18:56:15 rmind Exp $ */
+
+/*
+ * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
+ * Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_aobj.h,v 1.1.2.4 1998/02/06 05:19:28 chs Exp
+ */
+/*
+ * uvm_aobj.h: anonymous memory uvm_object pager
+ *
+ * author: Chuck Silvers <chuq@chuq.com>
+ * started: Jan-1998
+ *
+ * - design mostly from Chuck Cranor
+ */
+
+#ifndef _UVM_UVM_AOBJ_H_
+#define _UVM_UVM_AOBJ_H_
+
+/*
+ * Flags for uao_create: UAO_FLAG_KERNOBJ and UAO_FLAG_KERNSWAP are
+ * used only once, to initialise UVM.
+ */
+#define UAO_FLAG_KERNOBJ 0x1 /* create kernel object */
+#define UAO_FLAG_KERNSWAP 0x2 /* enable kernel swap */
+#define UAO_FLAG_NOSWAP 0x8 /* aobj may not swap */
+
+#ifdef _KERNEL
+#if defined(_KERNEL_OPT)
+#include "opt_vmswap.h"
+#endif
+
+void uao_init(void);
+int uao_set_swslot(struct uvm_object *, int, int);
+
+#if defined(VMSWAP)
+int uao_find_swslot(struct uvm_object *, int);
+void uao_dropswap(struct uvm_object *, int);
+bool uao_swap_off(int, int);
+void uao_dropswap_range(struct uvm_object *, voff_t, voff_t);
+#else
+#define uao_find_swslot(obj, off) 0
+#define uao_dropswap(obj, off) /* nothing */
+#define uao_dropswap_range(obj, lo, hi) /* nothing */
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_AOBJ_H_ */
--- /dev/null
+/* $NetBSD: uvm_ddb.h,v 1.15 2011/05/17 04:18:07 mrg Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp
+ */
+
+#ifndef _UVM_UVM_DDB_H_
+#define _UVM_UVM_DDB_H_
+
+#ifdef _KERNEL
+
+#if defined(DDB) || defined(DEBUGPRINT)
+void uvm_map_printit(struct vm_map *, bool,
+ void (*)(const char *, ...));
+void uvm_object_printit(struct uvm_object *, bool,
+ void (*)(const char *, ...));
+void uvm_page_printit(struct vm_page *, bool,
+ void (*)(const char *, ...));
+void uvm_page_printall(void (*)(const char *, ...));
+void uvmexp_print(void (*)(const char *, ...));
+#endif /* DDB || DEBUGPRINT */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_DDB_H_ */
--- /dev/null
+/* $NetBSD: uvm_device.h,v 1.12 2011/02/02 15:13:34 chuck Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_device.h,v 1.1.2.2 1997/10/03 17:39:44 chuck Exp
+ */
+
+#ifndef _UVM_UVM_DEVICE_H_
+#define _UVM_UVM_DEVICE_H_
+
+/*
+ * uvm_device.h
+ *
+ * device handle into the VM system.
+ */
+
+/*
+ * the uvm_device structure. object is put at the top of the data structure.
+ * this allows:
+ * (struct uvm_device *) == (struct uvm_object *)
+ */
+
+struct uvm_device {
+ struct uvm_object u_obj; /* the actual VM object */
+ int u_flags; /* flags [LOCKED BY UDV_LOCK!] */
+ dev_t u_device; /* our device */
+ LIST_ENTRY(uvm_device) u_list; /* list of device objects */
+};
+
+/*
+ * u_flags values
+ */
+
+#define UVM_DEVICE_HOLD 0x1 /* someone has a "hold" on it */
+#define UVM_DEVICE_WANTED 0x2 /* someone wants to put a "hold" on */
+
+#ifdef _KERNEL
+
+/*
+ * prototypes
+ */
+
+struct uvm_object *udv_attach(void *, vm_prot_t, voff_t, vsize_t);
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_DEVICE_H_ */
--- /dev/null
+/* $NetBSD: uvm_extern.h,v 1.184 2012/09/01 00:26:37 matt Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp
+ */
+
+/*-
+ * Copyright (c) 1991, 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_extern.h 8.5 (Berkeley) 5/3/95
+ */
+
+#ifndef _UVM_UVM_EXTERN_H_
+#define _UVM_UVM_EXTERN_H_
+
+/*
+ * uvm_extern.h: this file defines the external interface to the VM system.
+ *
+ * this should be the only file included by non-VM parts of the kernel
+ * which need access to VM services. if you want to know the interface
+ * to the MI VM layer without knowing the details, this is the file to
+ * learn.
+ *
+ * NOTE: vm system calls are prototyped in syscallargs.h
+ */
+
+/*
+ * defines
+ */
+
+/*
+ * the following defines are for uvm_map and functions which call it.
+ */
+
+/* protections bits */
+#define UVM_PROT_MASK 0x07 /* protection mask */
+#define UVM_PROT_NONE 0x00 /* protection none */
+#define UVM_PROT_ALL 0x07 /* everything */
+#define UVM_PROT_READ 0x01 /* read */
+#define UVM_PROT_WRITE 0x02 /* write */
+#define UVM_PROT_EXEC 0x04 /* exec */
+
+/* protection short codes */
+#define UVM_PROT_R 0x01 /* read */
+#define UVM_PROT_W 0x02 /* write */
+#define UVM_PROT_RW 0x03 /* read-write */
+#define UVM_PROT_X 0x04 /* exec */
+#define UVM_PROT_RX 0x05 /* read-exec */
+#define UVM_PROT_WX 0x06 /* write-exec */
+#define UVM_PROT_RWX 0x07 /* read-write-exec */
+
+/* 0x08: not used */
+
+/* inherit codes */
+#define UVM_INH_MASK 0x30 /* inherit mask */
+#define UVM_INH_SHARE 0x00 /* "share" */
+#define UVM_INH_COPY 0x10 /* "copy" */
+#define UVM_INH_NONE 0x20 /* "none" */
+#define UVM_INH_DONATE 0x30 /* "donate" << not used */
+
+/* 0x40, 0x80: not used */
+
+/* bits 0x700: max protection, 0x800: not used */
+
+/* bits 0x7000: advice, 0x8000: not used */
+/* advice: matches MADV_* from sys/mman.h and POSIX_FADV_* from sys/fcntl.h */
+#define UVM_ADV_NORMAL 0x0 /* 'normal' */
+#define UVM_ADV_RANDOM 0x1 /* 'random' */
+#define UVM_ADV_SEQUENTIAL 0x2 /* 'sequential' */
+#define UVM_ADV_WILLNEED 0x3 /* pages will be needed */
+#define UVM_ADV_DONTNEED 0x4 /* pages won't be needed */
+#define UVM_ADV_NOREUSE 0x5 /* pages will be used only once */
+#define UVM_ADV_MASK 0x7 /* mask */
+
+/* bits 0xffff0000: mapping flags */
+#define UVM_FLAG_FIXED 0x010000 /* find space */
+#define UVM_FLAG_OVERLAY 0x020000 /* establish overlay */
+#define UVM_FLAG_NOMERGE 0x040000 /* don't merge map entries */
+#define UVM_FLAG_COPYONW 0x080000 /* set copy_on_write flag */
+#define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce allocations */
+#define UVM_FLAG_TRYLOCK 0x200000 /* fail if we can not lock map */
+#define UVM_FLAG_NOWAIT 0x400000 /* not allowed to sleep */
+#define UVM_FLAG_WAITVA 0x800000 /* wait for va */
+#define UVM_FLAG_VAONLY 0x2000000 /* unmap: no pages are mapped */
+#define UVM_FLAG_COLORMATCH 0x4000000 /* match color given in off */
+
+/* macros to extract info */
+#define UVM_PROTECTION(X) ((X) & UVM_PROT_MASK)
+#define UVM_INHERIT(X) (((X) & UVM_INH_MASK) >> 4)
+#define UVM_MAXPROTECTION(X) (((X) >> 8) & UVM_PROT_MASK)
+#define UVM_ADVICE(X) (((X) >> 12) & UVM_ADV_MASK)
+
+#define UVM_MAPFLAG(PROT,MAXPROT,INH,ADVICE,FLAGS) \
+ (((MAXPROT) << 8)|(PROT)|(INH)|((ADVICE) << 12)|(FLAGS))
+
+/* magic offset value: offset not known(obj) or don't care(!obj) */
+#define UVM_UNKNOWN_OFFSET ((voff_t) -1)
+
+/*
+ * the following defines are for uvm_km_alloc/free's flags
+ */
+#define UVM_KMF_WIRED 0x1 /* allocation type: wired */
+#define UVM_KMF_PAGEABLE 0x2 /* allocation type: pageable */
+#define UVM_KMF_VAONLY 0x4 /* allocation type: VA only */
+#define UVM_KMF_TYPEMASK (UVM_KMF_VAONLY | UVM_KMF_PAGEABLE | UVM_KMF_WIRED)
+#define UVM_KMF_CANFAIL 0x8 /* caller handles failure */
+#define UVM_KMF_ZERO 0x10 /* want zero filled memory */
+#define UVM_KMF_EXEC 0x20 /* need executable mapping */
+#define UVM_KMF_TRYLOCK UVM_FLAG_TRYLOCK /* try locking only */
+#define UVM_KMF_NOWAIT UVM_FLAG_NOWAIT /* not allowed to sleep */
+#define UVM_KMF_WAITVA UVM_FLAG_WAITVA /* sleep for va */
+#define UVM_KMF_COLORMATCH UVM_FLAG_COLORMATCH /* start at color in align */
+
+/*
+ * the following defines the strategies for uvm_pagealloc_strat()
+ */
+#define UVM_PGA_STRAT_NORMAL 0 /* priority (low id to high) walk */
+#define UVM_PGA_STRAT_ONLY 1 /* only specified free list */
+#define UVM_PGA_STRAT_FALLBACK 2 /* ONLY falls back on NORMAL */
+
+/*
+ * flags for uvm_pagealloc_strat()
+ */
+#define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */
+#define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */
+
+/*
+ * flags for ubc_alloc()
+ */
+#define UBC_READ 0x001
+#define UBC_WRITE 0x002
+#define UBC_FAULTBUSY 0x004
+
+/*
+ * flags for ubc_release()
+ */
+#define UBC_UNMAP 0x010
+
+/*
+ * flags for ubc_uiomve()
+ */
+#define UBC_PARTIALOK 0x100
+
+/*
+ * flags for uvn_findpages().
+ */
+#define UFP_ALL 0x00
+#define UFP_NOWAIT 0x01
+#define UFP_NOALLOC 0x02
+#define UFP_NOCACHE 0x04
+#define UFP_NORDONLY 0x08
+#define UFP_DIRTYONLY 0x10
+#define UFP_BACKWARD 0x20
+
+/*
+ * lockflags that control the locking behavior of various functions.
+ */
+#define UVM_LK_ENTER 0x00000001 /* map locked on entry */
+#define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */
+
+/*
+ * Default number of pages to allocate on the stack
+ */
+#define UBC_MAX_PAGES 8
+
+/*
+ * Value representing inactive emap.
+ */
+#define UVM_EMAP_INACTIVE (0)
+
+/*
+ * structures
+ */
+
+struct buf;
+struct core;
+struct loadavg;
+struct mount;
+struct pglist;
+struct proc;
+struct uio;
+struct uvm_object;
+struct vm_anon;
+struct vmspace;
+struct pmap;
+struct vnode;
+struct simplelock;
+struct vm_map_entry;
+struct vm_map;
+struct vm_page;
+struct vmtotal;
+
+/*
+ * uvm_pctparam: parameter to be shown as percentage to user.
+ */
+
+#define UVM_PCTPARAM_SHIFT 8
+#define UVM_PCTPARAM_SCALE (1 << UVM_PCTPARAM_SHIFT)
+#define UVM_PCTPARAM_APPLY(pct, x) \
+ (((x) * (pct)->pct_scaled) >> UVM_PCTPARAM_SHIFT)
+struct uvm_pctparam {
+ int pct_pct; /* percent [0, 100] */ /* should be the first member */
+ int pct_scaled;
+ int (*pct_check)(struct uvm_pctparam *, int);
+};
+
+/*
+ * uvmexp: global data structures that are exported to parts of the kernel
+ * other than the vm system.
+ */
+
+struct uvmexp {
+ /* vm_page constants */
+ int pagesize; /* size of a page (PAGE_SIZE): must be power of 2 */
+ int pagemask; /* page mask */
+ int pageshift; /* page shift */
+
+ /* vm_page counters */
+ int npages; /* number of pages we manage */
+ int free; /* number of free pages */
+ int paging; /* number of pages in the process of being paged out */
+ int wired; /* number of wired pages */
+
+ /*
+ * Adding anything before this line will break binary compatibility
+ * with top(1) on NetBSD 1.5.
+ */
+
+ int ncolors; /* number of page color buckets: must be p-o-2 */
+ int colormask; /* color bucket mask */
+
+ int zeropages; /* number of zero'd pages */
+ int reserve_pagedaemon; /* number of pages reserved for pagedaemon */
+ int reserve_kernel; /* number of pages reserved for kernel */
+ unsigned anonpages; /* number of pages used by anon mappings */
+ unsigned filepages; /* number of pages used by cached file data */
+ unsigned execpages; /* number of pages used by cached exec data */
+
+ /* pageout params */
+ int freemin; /* min number of free pages */
+ int freetarg; /* target number of free pages */
+ int wiredmax; /* max number of wired pages */
+
+ /* swap */
+ int nswapdev; /* number of configured swap devices in system */
+ int swpages; /* number of PAGE_SIZE'ed swap pages */
+ int swpgavail; /* number of swap pages currently available */
+ int swpginuse; /* number of swap pages in use */
+ int swpgonly; /* number of swap pages in use, not also in RAM */
+ int nswget; /* number of times fault calls uvm_swap_get() */
+
+ /* stat counters. XXX: should be 64-bit counters */
+ int _unused_faults; /* page fault count */
+ int _unused_traps; /* trap count */
+ int _unused_intrs; /* interrupt count */
+ int _unused_swtch; /* context switch count */
+ int _unused_softs; /* software interrupt count */
+ int _unused_syscalls; /* system calls */
+ int pageins; /* pagein operation count */
+ /* pageouts are in pdpageouts below */
+ int _unused1;
+ int _unused2;
+ int pgswapin; /* pages swapped in */
+ int pgswapout; /* pages swapped out */
+ int forks; /* forks */
+ int forks_ppwait; /* forks where parent waits */
+ int forks_sharevm; /* forks where vmspace is shared */
+ int pga_zerohit; /* pagealloc where zero wanted and zero
+ was available */
+ int pga_zeromiss; /* pagealloc where zero wanted and zero
+ not available */
+ int zeroaborts; /* number of times page zeroing was
+ aborted */
+ int colorhit; /* pagealloc where we got optimal color */
+ int colormiss; /* pagealloc where we didn't */
+ int cpuhit; /* pagealloc where we allocated locally */
+ int cpumiss; /* pagealloc where we didn't */
+
+ /* fault subcounters. XXX: should be 64-bit counters */
+ int fltnoram; /* number of times fault was out of ram */
+ int fltnoanon; /* number of times fault was out of anons */
+ int fltpgwait; /* number of times fault had to wait on a page */
+ int fltpgrele; /* number of times fault found a released page */
+ int fltrelck; /* number of times fault relock called */
+ int fltrelckok; /* number of times fault relock is a success */
+ int fltanget; /* number of times fault gets anon page */
+ int fltanretry; /* number of times fault retrys an anon get */
+ int fltamcopy; /* number of times fault clears "needs copy" */
+ int fltnamap; /* number of times fault maps a neighbor anon page */
+ int fltnomap; /* number of times fault maps a neighbor obj page */
+ int fltlget; /* number of times fault does a locked pgo_get */
+ int fltget; /* number of times fault does an unlocked get */
+ int flt_anon; /* number of times fault anon (case 1a) */
+ int flt_acow; /* number of times fault anon cow (case 1b) */
+ int flt_obj; /* number of times fault is on object page (2a) */
+ int flt_prcopy; /* number of times fault promotes with copy (2b) */
+ int flt_przero; /* number of times fault promotes with zerofill (2b) */
+
+ /* daemon counters. XXX: should be 64-bit counters */
+ int pdwoke; /* number of times daemon woke up */
+ int pdrevs; /* number of times daemon rev'd clock hand */
+ int _unused3;
+ int pdfreed; /* number of pages daemon freed since boot */
+ int pdscans; /* number of pages daemon scanned since boot */
+ int pdanscan; /* number of anonymous pages scanned by daemon */
+ int pdobscan; /* number of object pages scanned by daemon */
+ int pdreact; /* number of pages daemon reactivated since boot */
+ int pdbusy; /* number of times daemon found a busy page */
+ int pdpageouts; /* number of times daemon started a pageout */
+ int pdpending; /* number of times daemon got a pending pagout */
+ int pddeact; /* number of pages daemon deactivates */
+ int pdreanon; /* anon pages reactivated due to thresholds */
+ int pdrefile; /* file pages reactivated due to thresholds */
+ int pdreexec; /* executable pages reactivated due to thresholds */
+};
+
+/*
+ * The following structure is 64-bit alignment safe. New elements
+ * should only be added to the end of this structure so binary
+ * compatibility can be preserved.
+ */
+struct uvmexp_sysctl {
+ int64_t pagesize;
+ int64_t pagemask;
+ int64_t pageshift;
+ int64_t npages;
+ int64_t free;
+ int64_t active;
+ int64_t inactive;
+ int64_t paging;
+ int64_t wired;
+ int64_t zeropages;
+ int64_t reserve_pagedaemon;
+ int64_t reserve_kernel;
+ int64_t freemin;
+ int64_t freetarg;
+ int64_t inactarg; /* unused */
+ int64_t wiredmax;
+ int64_t nswapdev;
+ int64_t swpages;
+ int64_t swpginuse;
+ int64_t swpgonly;
+ int64_t nswget;
+ int64_t unused1; /* unused; was nanon */
+ int64_t cpuhit;
+ int64_t cpumiss;
+ int64_t faults;
+ int64_t traps;
+ int64_t intrs;
+ int64_t swtch;
+ int64_t softs;
+ int64_t syscalls;
+ int64_t pageins;
+ int64_t swapins; /* unused */
+ int64_t swapouts; /* unused */
+ int64_t pgswapin;
+ int64_t pgswapout;
+ int64_t forks;
+ int64_t forks_ppwait;
+ int64_t forks_sharevm;
+ int64_t pga_zerohit;
+ int64_t pga_zeromiss;
+ int64_t zeroaborts;
+ int64_t fltnoram;
+ int64_t fltnoanon;
+ int64_t fltpgwait;
+ int64_t fltpgrele;
+ int64_t fltrelck;
+ int64_t fltrelckok;
+ int64_t fltanget;
+ int64_t fltanretry;
+ int64_t fltamcopy;
+ int64_t fltnamap;
+ int64_t fltnomap;
+ int64_t fltlget;
+ int64_t fltget;
+ int64_t flt_anon;
+ int64_t flt_acow;
+ int64_t flt_obj;
+ int64_t flt_prcopy;
+ int64_t flt_przero;
+ int64_t pdwoke;
+ int64_t pdrevs;
+ int64_t unused4;
+ int64_t pdfreed;
+ int64_t pdscans;
+ int64_t pdanscan;
+ int64_t pdobscan;
+ int64_t pdreact;
+ int64_t pdbusy;
+ int64_t pdpageouts;
+ int64_t pdpending;
+ int64_t pddeact;
+ int64_t anonpages;
+ int64_t filepages;
+ int64_t execpages;
+ int64_t colorhit;
+ int64_t colormiss;
+ int64_t ncolors;
+};
+
+#ifdef _KERNEL
+/* we need this before including uvm_page.h on some platforms */
+extern struct uvmexp uvmexp;
+/* MD code needs this without including <uvm/uvm.h> */
+extern bool vm_page_zero_enable;
+#endif
+
+/*
+ * Finally, bring in standard UVM headers.
+ */
+#include <sys/vmmeter.h>
+#include <sys/queue.h>
+#include <sys/lock.h>
+#ifdef _KERNEL
+#include <sys/vmem.h>
+#endif
+#include <uvm/uvm_param.h>
+#include <uvm/uvm_prot.h>
+#include <uvm/uvm_pmap.h>
+#include <uvm/uvm_map.h>
+#include <uvm/uvm_pager.h>
+
+/*
+ * helpers for calling ubc_release()
+ */
+#ifdef PMAP_CACHE_VIVT
+#define UBC_WANT_UNMAP(vp) (((vp)->v_iflag & VI_TEXT) != 0)
+#else
+#define UBC_WANT_UNMAP(vp) false
+#endif
+#define UBC_UNMAP_FLAG(vp) (UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0)
+
+/*
+ * Shareable process virtual address space.
+ * May eventually be merged with vm_map.
+ * Several fields are temporary (text, data stuff).
+ */
+struct vmspace {
+ struct vm_map vm_map; /* VM address map */
+ int vm_refcnt; /* number of references *
+ * note: protected by vm_map.ref_lock */
+ void * vm_shm; /* SYS5 shared memory private data XXX */
+/* we copy from vm_startcopy to the end of the structure on fork */
+#define vm_startcopy vm_rssize
+ segsz_t vm_rssize; /* current resident set size in pages */
+ segsz_t vm_swrss; /* resident set size before last swap */
+ segsz_t vm_tsize; /* text size (pages) XXX */
+ segsz_t vm_dsize; /* data size (pages) XXX */
+ segsz_t vm_ssize; /* stack size (pages) */
+ segsz_t vm_issize; /* initial unmapped stack size (pages) */
+ void * vm_taddr; /* user virtual address of text XXX */
+ void * vm_daddr; /* user virtual address of data XXX */
+ void *vm_maxsaddr; /* user VA at max stack growth */
+ void *vm_minsaddr; /* user VA at top of stack */
+ size_t vm_aslr_delta_mmap; /* mmap() random delta for ASLR */
+};
+#define VMSPACE_IS_KERNEL_P(vm) VM_MAP_IS_KERNEL(&(vm)->vm_map)
+
+#ifdef _KERNEL
+
+/*
+ * used to keep state while iterating over the map for a core dump.
+ */
+struct uvm_coredump_state {
+ void *cookie; /* opaque for the caller */
+ vaddr_t start; /* start of region */
+ vaddr_t realend; /* real end of region */
+ vaddr_t end; /* virtual end of region */
+ vm_prot_t prot; /* protection of region */
+ int flags; /* flags; see below */
+};
+
+#define UVM_COREDUMP_STACK 0x01 /* region is user stack */
+
+/*
+ * the various kernel maps, owned by MD code
+ */
+extern struct vm_map *kernel_map;
+extern struct vm_map *phys_map;
+
+/*
+ * macros
+ */
+
+#define vm_resident_count(vm) (pmap_resident_count((vm)->vm_map.pmap))
+
+
+/* vm_machdep.c */
+int vmapbuf(struct buf *, vsize_t);
+void vunmapbuf(struct buf *, vsize_t);
+
+/* uvm_aobj.c */
+struct uvm_object *uao_create(vsize_t, int);
+void uao_detach(struct uvm_object *);
+void uao_reference(struct uvm_object *);
+
+/* uvm_bio.c */
+void ubc_init(void);
+void * ubc_alloc(struct uvm_object *, voff_t, vsize_t *, int,
+ int);
+void ubc_release(void *, int);
+int ubc_uiomove(struct uvm_object *, struct uio *, vsize_t,
+ int, int);
+void ubc_zerorange(struct uvm_object *, off_t, size_t, int);
+void ubc_purge(struct uvm_object *);
+
+/* uvm_emap.c */
+void uvm_emap_sysinit(void);
+#ifdef __HAVE_PMAP_EMAP
+void uvm_emap_switch(lwp_t *);
+#else
+#define uvm_emap_switch(l)
+#endif
+
+u_int uvm_emap_gen_return(void);
+void uvm_emap_update(u_int);
+
+vaddr_t uvm_emap_alloc(vsize_t, bool);
+void uvm_emap_free(vaddr_t, size_t);
+
+void uvm_emap_enter(vaddr_t, struct vm_page **, u_int);
+void uvm_emap_remove(vaddr_t, vsize_t);
+
+#ifdef __HAVE_PMAP_EMAP
+void uvm_emap_consume(u_int);
+u_int uvm_emap_produce(void);
+#else
+#define uvm_emap_consume(x)
+#define uvm_emap_produce() UVM_EMAP_INACTIVE
+#endif
+
+/* uvm_fault.c */
+#define uvm_fault(m, a, p) uvm_fault_internal(m, a, p, 0)
+int uvm_fault_internal(struct vm_map *, vaddr_t, vm_prot_t, int);
+ /* handle a page fault */
+
+/* uvm_glue.c */
+#if defined(KGDB)
+void uvm_chgkprot(void *, size_t, int);
+#endif
+void uvm_proc_fork(struct proc *, struct proc *, bool);
+void uvm_lwp_fork(struct lwp *, struct lwp *,
+ void *, size_t, void (*)(void *), void *);
+int uvm_coredump_walkmap(struct proc *,
+ void *,
+ int (*)(struct proc *, void *,
+ struct uvm_coredump_state *), void *);
+void uvm_proc_exit(struct proc *);
+void uvm_lwp_exit(struct lwp *);
+void uvm_init_limits(struct proc *);
+bool uvm_kernacc(void *, size_t, vm_prot_t);
+__dead void uvm_scheduler(void);
+vaddr_t uvm_uarea_alloc(void);
+void uvm_uarea_free(vaddr_t);
+vaddr_t uvm_uarea_system_alloc(struct cpu_info *);
+void uvm_uarea_system_free(vaddr_t);
+vaddr_t uvm_lwp_getuarea(lwp_t *);
+void uvm_lwp_setuarea(lwp_t *, vaddr_t);
+int uvm_vslock(struct vmspace *, void *, size_t, vm_prot_t);
+void uvm_vsunlock(struct vmspace *, void *, size_t);
+void uvm_cpu_attach(struct cpu_info *);
+
+
+/* uvm_init.c */
+void uvm_init(void);
+
+/* uvm_io.c */
+int uvm_io(struct vm_map *, struct uio *);
+
+/* uvm_km.c */
+vaddr_t uvm_km_alloc(struct vm_map *, vsize_t, vsize_t,
+ uvm_flag_t);
+void uvm_km_free(struct vm_map *, vaddr_t, vsize_t,
+ uvm_flag_t);
+
+struct vm_map *uvm_km_suballoc(struct vm_map *, vaddr_t *,
+ vaddr_t *, vsize_t, int, bool,
+ struct vm_map *);
+#ifdef _KERNEL
+int uvm_km_kmem_alloc(vmem_t *, vmem_size_t, vm_flag_t,
+ vmem_addr_t *);
+void uvm_km_kmem_free(vmem_t *, vmem_addr_t, vmem_size_t);
+bool uvm_km_va_starved_p(void);
+#endif
+
+/* uvm_map.c */
+int uvm_map(struct vm_map *, vaddr_t *, vsize_t,
+ struct uvm_object *, voff_t, vsize_t,
+ uvm_flag_t);
+int uvm_map_pageable(struct vm_map *, vaddr_t,
+ vaddr_t, bool, int);
+int uvm_map_pageable_all(struct vm_map *, int, vsize_t);
+bool uvm_map_checkprot(struct vm_map *, vaddr_t,
+ vaddr_t, vm_prot_t);
+int uvm_map_protect(struct vm_map *, vaddr_t,
+ vaddr_t, vm_prot_t, bool);
+struct vmspace *uvmspace_alloc(vaddr_t, vaddr_t);
+void uvmspace_init(struct vmspace *, struct pmap *,
+ vaddr_t, vaddr_t);
+void uvmspace_exec(struct lwp *, vaddr_t, vaddr_t);
+void uvmspace_spawn(struct lwp *, vaddr_t, vaddr_t);
+struct vmspace *uvmspace_fork(struct vmspace *);
+void uvmspace_addref(struct vmspace *);
+void uvmspace_free(struct vmspace *);
+void uvmspace_share(struct proc *, struct proc *);
+void uvmspace_unshare(struct lwp *);
+
+void uvm_whatis(uintptr_t, void (*)(const char *, ...));
+
+/* uvm_meter.c */
+int uvm_sysctl(int *, u_int, void *, size_t *,
+ void *, size_t, struct proc *);
+int uvm_pctparam_check(struct uvm_pctparam *, int);
+void uvm_pctparam_set(struct uvm_pctparam *, int);
+int uvm_pctparam_get(struct uvm_pctparam *);
+void uvm_pctparam_init(struct uvm_pctparam *, int,
+ int (*)(struct uvm_pctparam *, int));
+int uvm_pctparam_createsysctlnode(struct uvm_pctparam *,
+ const char *, const char *);
+
+/* uvm_mmap.c */
+int uvm_mmap(struct vm_map *, vaddr_t *, vsize_t,
+ vm_prot_t, vm_prot_t, int,
+ void *, voff_t, vsize_t);
+vaddr_t uvm_default_mapaddr(struct proc *, vaddr_t, vsize_t);
+
+/* uvm_mremap.c */
+int uvm_mremap(struct vm_map *, vaddr_t, vsize_t,
+ struct vm_map *, vaddr_t *, vsize_t,
+ struct proc *, int);
+
+/* uvm_object.c */
+void uvm_obj_init(struct uvm_object *,
+ const struct uvm_pagerops *, bool, u_int);
+void uvm_obj_setlock(struct uvm_object *, kmutex_t *);
+void uvm_obj_destroy(struct uvm_object *, bool);
+int uvm_obj_wirepages(struct uvm_object *, off_t, off_t,
+ struct pglist *);
+void uvm_obj_unwirepages(struct uvm_object *, off_t, off_t);
+
+/* uvm_page.c */
+struct vm_page *uvm_pagealloc_strat(struct uvm_object *,
+ voff_t, struct vm_anon *, int, int, int);
+#define uvm_pagealloc(obj, off, anon, flags) \
+ uvm_pagealloc_strat((obj), (off), (anon), (flags), \
+ UVM_PGA_STRAT_NORMAL, 0)
+void uvm_pagereplace(struct vm_page *,
+ struct vm_page *);
+void uvm_pagerealloc(struct vm_page *,
+ struct uvm_object *, voff_t);
+/* Actually, uvm_page_physload takes PF#s which need their own type */
+void uvm_page_physload(paddr_t, paddr_t, paddr_t,
+ paddr_t, int);
+void uvm_setpagesize(void);
+
+/* uvm_pager.c */
+void uvm_aio_biodone(struct buf *);
+void uvm_aio_aiodone(struct buf *);
+void uvm_aio_aiodone_pages(struct vm_page **, int, bool,
+ int);
+
+/* uvm_pdaemon.c */
+void uvm_pageout(void *);
+struct work;
+void uvm_aiodone_worker(struct work *, void *);
+void uvm_pageout_start(int);
+void uvm_pageout_done(int);
+void uvm_estimatepageable(int *, int *);
+
+/* uvm_pglist.c */
+int uvm_pglistalloc(psize_t, paddr_t, paddr_t,
+ paddr_t, paddr_t, struct pglist *, int, int);
+void uvm_pglistfree(struct pglist *);
+
+/* uvm_swap.c */
+void uvm_swap_init(void);
+
+/* uvm_unix.c */
+int uvm_grow(struct proc *, vaddr_t);
+
+/* uvm_user.c */
+void uvm_deallocate(struct vm_map *, vaddr_t, vsize_t);
+
+/* uvm_vnode.c */
+void uvm_vnp_setsize(struct vnode *, voff_t);
+void uvm_vnp_setwritesize(struct vnode *, voff_t);
+int uvn_findpages(struct uvm_object *, voff_t,
+ int *, struct vm_page **, int);
+bool uvn_text_p(struct uvm_object *);
+bool uvn_clean_p(struct uvm_object *);
+bool uvn_needs_writefault_p(struct uvm_object *);
+
+/* kern_malloc.c */
+void kmeminit_nkmempages(void);
+void kmeminit(void);
+extern int nkmempages;
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_EXTERN_H_ */
--- /dev/null
+/* $NetBSD: uvm_fault.h,v 1.20 2011/02/02 15:13:34 chuck Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_fault.h,v 1.1.2.2 1997/12/08 16:07:12 chuck Exp
+ */
+
+#ifndef _UVM_UVM_FAULT_H_
+#define _UVM_UVM_FAULT_H_
+
+/*
+ * fault data structures
+ */
+
+/*
+ * uvm_faultinfo: to load one of these fill in all orig_* fields and
+ * then call uvmfault_lookup on it.
+ */
+
+
+struct uvm_faultinfo {
+ struct vm_map *orig_map; /* IN: original map */
+ vaddr_t orig_rvaddr; /* IN: original rounded VA */
+ vsize_t orig_size; /* IN: original size of interest */
+ struct vm_map *map; /* map (could be a submap) */
+ unsigned int mapv; /* map's version number */
+ struct vm_map_entry *entry; /* map entry (from 'map') */
+ vsize_t size; /* size of interest */
+};
+
+#ifdef _KERNEL
+
+/*
+ * fault prototypes
+ */
+
+int uvmfault_anonget(struct uvm_faultinfo *, struct vm_amap *,
+ struct vm_anon *);
+
+int uvm_fault_wire(struct vm_map *, vaddr_t, vaddr_t, vm_prot_t, int);
+void uvm_fault_unwire(struct vm_map *, vaddr_t, vaddr_t);
+void uvm_fault_unwire_locked(struct vm_map *, vaddr_t, vaddr_t);
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_FAULT_H_ */
--- /dev/null
+/* $NetBSD: uvm_fault_i.h,v 1.28 2012/02/19 00:05:56 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_fault_i.h,v 1.1.6.1 1997/12/08 16:07:12 chuck Exp
+ */
+
+#ifndef _UVM_UVM_FAULT_I_H_
+#define _UVM_UVM_FAULT_I_H_
+
+/*
+ * uvm_fault_i.h: fault inline functions
+ */
+
+/*
+ * uvmfault_unlockmaps: unlock the maps
+ */
+
+static inline void
+uvmfault_unlockmaps(struct uvm_faultinfo *ufi, bool write_locked)
+{
+ /*
+ * ufi can be NULL when this isn't really a fault,
+ * but merely paging in anon data.
+ */
+
+ if (ufi == NULL) {
+ return;
+ }
+
+ if (write_locked) {
+ vm_map_unlock(ufi->map);
+ } else {
+ vm_map_unlock_read(ufi->map);
+ }
+}
+
+/*
+ * uvmfault_unlockall: unlock everything passed in.
+ *
+ * => maps must be read-locked (not write-locked).
+ */
+
+static inline void
+uvmfault_unlockall(struct uvm_faultinfo *ufi, struct vm_amap *amap,
+ struct uvm_object *uobj)
+{
+
+ if (uobj)
+ mutex_exit(uobj->vmobjlock);
+ if (amap)
+ amap_unlock(amap);
+ uvmfault_unlockmaps(ufi, false);
+}
+
+/*
+ * uvmfault_lookup: lookup a virtual address in a map
+ *
+ * => caller must provide a uvm_faultinfo structure with the IN
+ * params properly filled in
+ * => we will lookup the map entry (handling submaps) as we go
+ * => if the lookup is a success we will return with the maps locked
+ * => if "write_lock" is true, we write_lock the map, otherwise we only
+ * get a read lock.
+ * => note that submaps can only appear in the kernel and they are
+ * required to use the same virtual addresses as the map they
+ * are referenced by (thus address translation between the main
+ * map and the submap is unnecessary).
+ */
+
+static inline bool
+uvmfault_lookup(struct uvm_faultinfo *ufi, bool write_lock)
+{
+ struct vm_map *tmpmap;
+
+ /*
+ * init ufi values for lookup.
+ */
+
+ ufi->map = ufi->orig_map;
+ ufi->size = ufi->orig_size;
+
+ /*
+ * keep going down levels until we are done. note that there can
+ * only be two levels so we won't loop very long.
+ */
+
+ for (;;) {
+ /*
+ * lock map
+ */
+ if (write_lock) {
+ vm_map_lock(ufi->map);
+ } else {
+ vm_map_lock_read(ufi->map);
+ }
+
+ /*
+ * lookup
+ */
+ if (!uvm_map_lookup_entry(ufi->map, ufi->orig_rvaddr,
+ &ufi->entry)) {
+ uvmfault_unlockmaps(ufi, write_lock);
+ return(false);
+ }
+
+ /*
+ * reduce size if necessary
+ */
+ if (ufi->entry->end - ufi->orig_rvaddr < ufi->size)
+ ufi->size = ufi->entry->end - ufi->orig_rvaddr;
+
+ /*
+ * submap? replace map with the submap and lookup again.
+ * note: VAs in submaps must match VAs in main map.
+ */
+ if (UVM_ET_ISSUBMAP(ufi->entry)) {
+ tmpmap = ufi->entry->object.sub_map;
+ if (write_lock) {
+ vm_map_unlock(ufi->map);
+ } else {
+ vm_map_unlock_read(ufi->map);
+ }
+ ufi->map = tmpmap;
+ continue;
+ }
+
+ /*
+ * got it!
+ */
+
+ ufi->mapv = ufi->map->timestamp;
+ return(true);
+
+ } /* while loop */
+
+ /*NOTREACHED*/
+}
+
+/*
+ * uvmfault_relock: attempt to relock the same version of the map
+ *
+ * => fault data structures should be unlocked before calling.
+ * => if a success (true) maps will be locked after call.
+ */
+
+static inline bool
+uvmfault_relock(struct uvm_faultinfo *ufi)
+{
+ /*
+ * ufi can be NULL when this isn't really a fault,
+ * but merely paging in anon data.
+ */
+
+ if (ufi == NULL) {
+ return true;
+ }
+
+ uvmexp.fltrelck++;
+
+ /*
+ * relock map. fail if version mismatch (in which case nothing
+ * gets locked).
+ */
+
+ vm_map_lock_read(ufi->map);
+ if (ufi->mapv != ufi->map->timestamp) {
+ vm_map_unlock_read(ufi->map);
+ return(false);
+ }
+
+ uvmexp.fltrelckok++;
+ return(true);
+}
+
+#endif /* _UVM_UVM_FAULT_I_H_ */
--- /dev/null
+/* $NetBSD: uvm_glue.h,v 1.10 2011/02/02 15:13:34 chuck Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_glue.h,v 1.1.2.1 1997/08/14 19:10:48 chuck Exp
+ */
+
+#ifndef _UVM_UVM_GLUE_H_
+#define _UVM_UVM_GLUE_H_
+
+#ifdef _KERNEL
+
+/*
+ * uvm_glue.h
+ */
+
+void uvm_swapout_threads(void);
+
+void uvm_uarea_init(void);
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_GLUE_H_ */
--- /dev/null
+/* $NetBSD: uvm_km.h,v 1.20 2012/01/27 19:48:41 para Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_km.h,v 1.1.2.2 1997/12/30 12:03:15 mrg Exp
+ */
+
+#ifndef _UVM_UVM_KM_H_
+#define _UVM_UVM_KM_H_
+
+/*
+ * uvm_km.h
+ */
+
+#ifdef _KERNEL
+
+/*
+ * prototypes
+ */
+
+void uvm_km_bootstrap(vaddr_t, vaddr_t);
+void uvm_km_init(void);
+void uvm_km_pgremove(vaddr_t, vaddr_t);
+void uvm_km_pgremove_intrsafe(struct vm_map *, vaddr_t, vaddr_t);
+#if defined(DEBUG)
+void uvm_km_check_empty(struct vm_map *, vaddr_t, vaddr_t);
+#else
+#define uvm_km_check_empty(a, b, c) /* nothing */
+#endif /* defined(DEBUG) */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_KM_H_ */
--- /dev/null
+/* $NetBSD: uvm_kmguard.h,v 1.2 2012/02/05 03:40:07 rmind Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _UVM_KMGUARD_H_
+#define _UVM_KMGUARD_H_
+
+struct uvm_kmguard {
+ u_int kg_depth;
+ intptr_t * kg_fifo;
+ u_int kg_rotor;
+ vmem_t * kg_vmem;
+};
+
+void uvm_kmguard_init(struct uvm_kmguard *, u_int *, size_t *, vmem_t *);
+void * uvm_kmguard_alloc(struct uvm_kmguard *, size_t, bool);
+bool uvm_kmguard_free(struct uvm_kmguard *, size_t, void *);
+
+#endif /* _UVM_KMGUARD_H_ */
--- /dev/null
+/* $NetBSD: uvm_loan.h,v 1.17 2011/02/02 15:13:34 chuck Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_loan.h,v 1.1.4.1 1997/12/08 16:07:14 chuck Exp
+ */
+
+#ifndef _UVM_UVM_LOAN_H_
+#define _UVM_UVM_LOAN_H_
+
+#ifdef _KERNEL
+
+/*
+ * flags for uvm_loan()
+ */
+
+#define UVM_LOAN_TOANON 0x1 /* loan to anon */
+#define UVM_LOAN_TOPAGE 0x2 /* loan to page */
+
+/*
+ * loan prototypes
+ */
+
+void uvm_loan_init(void);
+int uvm_loan(struct vm_map *, vaddr_t, vsize_t, void *, int);
+void uvm_unloan(void *, int, int);
+int uvm_loanuobjpages(struct uvm_object *, voff_t, int,
+ struct vm_page **);
+struct vm_page *uvm_loanbreak(struct vm_page *);
+int uvm_loanbreak_anon(struct vm_anon *, struct uvm_object *);
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_LOAN_H_ */
--- /dev/null
+/* $NetBSD: uvm_map.h,v 1.71 2012/02/19 00:05:56 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * Copyright (c) 1991, 1993, The Regents of the University of California.
+ *
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_map.h 8.3 (Berkeley) 3/15/94
+ * from: Id: uvm_map.h,v 1.1.2.3 1998/02/07 01:16:55 chs Exp
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#ifndef _UVM_UVM_MAP_H_
+#define _UVM_UVM_MAP_H_
+
+/*
+ * uvm_map.h
+ */
+
+#ifdef _KERNEL
+
+/*
+ * macros
+ */
+
+/*
+ * UVM_MAP_CLIP_START: ensure that the entry begins at or after
+ * the starting address, if it doesn't we split the entry.
+ *
+ * => map must be locked by caller
+ */
+
+#define UVM_MAP_CLIP_START(MAP,ENTRY,VA) { \
+ if ((VA) > (ENTRY)->start && (VA) < (ENTRY)->end) { \
+ uvm_map_clip_start(MAP,ENTRY,VA); \
+ } \
+}
+
+/*
+ * UVM_MAP_CLIP_END: ensure that the entry ends at or before
+ * the ending address, if it does't we split the entry.
+ *
+ * => map must be locked by caller
+ */
+
+#define UVM_MAP_CLIP_END(MAP,ENTRY,VA) { \
+ if ((VA) > (ENTRY)->start && (VA) < (ENTRY)->end) { \
+ uvm_map_clip_end(MAP,ENTRY,VA); \
+ } \
+}
+
+/*
+ * extract flags
+ */
+#define UVM_EXTRACT_REMOVE 0x01 /* remove mapping from old map */
+#define UVM_EXTRACT_CONTIG 0x02 /* try to keep it contig */
+#define UVM_EXTRACT_QREF 0x04 /* use quick refs */
+#define UVM_EXTRACT_FIXPROT 0x08 /* set prot to maxprot as we go */
+#define UVM_EXTRACT_RESERVED 0x10 /* caller did uvm_map_reserve() */
+
+#endif /* _KERNEL */
+
+#include <sys/rbtree.h>
+#include <sys/pool.h>
+#include <sys/rwlock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+
+#include <uvm/uvm_anon.h>
+
+/*
+ * Address map entries consist of start and end addresses,
+ * a VM object (or sharing map) and offset into that object,
+ * and user-exported inheritance and protection information.
+ * Also included is control information for virtual copy operations.
+ */
+struct vm_map_entry {
+ struct rb_node rb_node; /* tree information */
+ vsize_t gap; /* free space after */
+ vsize_t maxgap; /* space in subtree */
+ struct vm_map_entry *prev; /* previous entry */
+ struct vm_map_entry *next; /* next entry */
+ vaddr_t start; /* start address */
+ vaddr_t end; /* end address */
+ union {
+ struct uvm_object *uvm_obj; /* uvm object */
+ struct vm_map *sub_map; /* belongs to another map */
+ } object; /* object I point to */
+ voff_t offset; /* offset into object */
+ int etype; /* entry type */
+ vm_prot_t protection; /* protection code */
+ vm_prot_t max_protection; /* maximum protection */
+ vm_inherit_t inheritance; /* inheritance */
+ int wired_count; /* can be paged if == 0 */
+ struct vm_aref aref; /* anonymous overlay */
+ int advice; /* madvise advice */
+ uint32_t map_attrib; /* uvm-external map attributes */
+#define uvm_map_entry_stop_copy flags
+ u_int8_t flags; /* flags */
+
+#define UVM_MAP_KERNEL 0x01 /* kernel map entry */
+#define UVM_MAP_KMAPENT 0x02 /* contains map entries */
+#define UVM_MAP_STATIC 0x04 /* special static entries */
+#define UVM_MAP_NOMERGE 0x08 /* this entry is not mergable */
+
+};
+
+#define VM_MAPENT_ISWIRED(entry) ((entry)->wired_count != 0)
+
+/*
+ * Maps are doubly-linked lists of map entries, kept sorted
+ * by address. A single hint is provided to start
+ * searches again from the last successful search,
+ * insertion, or removal.
+ *
+ * LOCKING PROTOCOL NOTES:
+ * -----------------------
+ *
+ * VM map locking is a little complicated. There are both shared
+ * and exclusive locks on maps. However, it is sometimes required
+ * to downgrade an exclusive lock to a shared lock, and upgrade to
+ * an exclusive lock again (to perform error recovery). However,
+ * another thread *must not* queue itself to receive an exclusive
+ * lock while before we upgrade back to exclusive, otherwise the
+ * error recovery becomes extremely difficult, if not impossible.
+ *
+ * In order to prevent this scenario, we introduce the notion of
+ * a `busy' map. A `busy' map is read-locked, but other threads
+ * attempting to write-lock wait for this flag to clear before
+ * entering the lock manager. A map may only be marked busy
+ * when the map is write-locked (and then the map must be downgraded
+ * to read-locked), and may only be marked unbusy by the thread
+ * which marked it busy (holding *either* a read-lock or a
+ * write-lock, the latter being gained by an upgrade).
+ *
+ * Access to the map `flags' member is controlled by the `flags_lock'
+ * simple lock. Note that some flags are static (set once at map
+ * creation time, and never changed), and thus require no locking
+ * to check those flags. All flags which are r/w must be set or
+ * cleared while the `flags_lock' is asserted. Additional locking
+ * requirements are:
+ *
+ * VM_MAP_PAGEABLE r/o static flag; no locking required
+ *
+ * VM_MAP_WIREFUTURE r/w; may only be set or cleared when
+ * map is write-locked. may be tested
+ * without asserting `flags_lock'.
+ *
+ * VM_MAP_DYING r/o; set when a vmspace is being
+ * destroyed to indicate that updates
+ * to the pmap can be skipped.
+ *
+ * VM_MAP_TOPDOWN r/o; set when the vmspace is
+ * created if the unspecified map
+ * allocations are to be arranged in
+ * a "top down" manner.
+ */
+struct vm_map {
+ struct pmap * pmap; /* Physical map */
+ krwlock_t lock; /* Non-intrsafe lock */
+ struct lwp * busy; /* LWP holding map busy */
+ kmutex_t misc_lock; /* Lock for ref_count, cv */
+ kcondvar_t cv; /* For signalling */
+ int flags; /* flags */
+ struct rb_tree rb_tree; /* Tree for entries */
+ struct vm_map_entry header; /* List of entries */
+ int nentries; /* Number of entries */
+ vsize_t size; /* virtual size */
+ int ref_count; /* Reference count */
+ struct vm_map_entry * hint; /* hint for quick lookups */
+ struct vm_map_entry * first_free; /* First free space hint */
+ unsigned int timestamp; /* Version number */
+};
+
+#if defined(_KERNEL)
+
+#include <sys/callback.h>
+
+#endif /* defined(_KERNEL) */
+
+#define VM_MAP_IS_KERNEL(map) (vm_map_pmap(map) == pmap_kernel())
+
+/* vm_map flags */
+#define VM_MAP_PAGEABLE 0x01 /* ro: entries are pageable */
+#define VM_MAP_WIREFUTURE 0x04 /* rw: wire future mappings */
+#define VM_MAP_DYING 0x20 /* rw: map is being destroyed */
+#define VM_MAP_TOPDOWN 0x40 /* ro: arrange map top-down */
+#define VM_MAP_WANTVA 0x100 /* rw: want va */
+
+#ifdef _KERNEL
+struct uvm_map_args {
+ struct vm_map_entry *uma_prev;
+
+ vaddr_t uma_start;
+ vsize_t uma_size;
+
+ struct uvm_object *uma_uobj;
+ voff_t uma_uoffset;
+
+ uvm_flag_t uma_flags;
+};
+#endif /* _KERNEL */
+
+/*
+ * globals:
+ */
+
+#ifdef _KERNEL
+
+#include <sys/proc.h>
+
+#ifdef PMAP_GROWKERNEL
+extern vaddr_t uvm_maxkaddr;
+#endif
+
+/*
+ * protos: the following prototypes define the interface to vm_map
+ */
+
+void uvm_map_deallocate(struct vm_map *);
+
+int uvm_map_willneed(struct vm_map *, vaddr_t, vaddr_t);
+int uvm_map_clean(struct vm_map *, vaddr_t, vaddr_t, int);
+void uvm_map_clip_start(struct vm_map *, struct vm_map_entry *,
+ vaddr_t);
+void uvm_map_clip_end(struct vm_map *, struct vm_map_entry *,
+ vaddr_t);
+int uvm_map_extract(struct vm_map *, vaddr_t, vsize_t,
+ struct vm_map *, vaddr_t *, int);
+struct vm_map_entry *
+ uvm_map_findspace(struct vm_map *, vaddr_t, vsize_t,
+ vaddr_t *, struct uvm_object *, voff_t, vsize_t, int);
+int uvm_map_inherit(struct vm_map *, vaddr_t, vaddr_t,
+ vm_inherit_t);
+int uvm_map_advice(struct vm_map *, vaddr_t, vaddr_t, int);
+void uvm_map_init(void);
+void uvm_map_init_caches(void);
+bool uvm_map_lookup_entry(struct vm_map *, vaddr_t,
+ struct vm_map_entry **);
+void uvm_map_reference(struct vm_map *);
+int uvm_map_reserve(struct vm_map *, vsize_t, vaddr_t, vsize_t,
+ vaddr_t *, uvm_flag_t);
+void uvm_map_setup(struct vm_map *, vaddr_t, vaddr_t, int);
+int uvm_map_submap(struct vm_map *, vaddr_t, vaddr_t,
+ struct vm_map *);
+void uvm_unmap1(struct vm_map *, vaddr_t, vaddr_t, int);
+#define uvm_unmap(map, s, e) uvm_unmap1((map), (s), (e), 0)
+void uvm_unmap_detach(struct vm_map_entry *,int);
+void uvm_unmap_remove(struct vm_map *, vaddr_t, vaddr_t,
+ struct vm_map_entry **, int);
+
+int uvm_map_prepare(struct vm_map *, vaddr_t, vsize_t,
+ struct uvm_object *, voff_t, vsize_t, uvm_flag_t,
+ struct uvm_map_args *);
+int uvm_map_enter(struct vm_map *, const struct uvm_map_args *,
+ struct vm_map_entry *);
+
+int uvm_mapent_trymerge(struct vm_map *,
+ struct vm_map_entry *, int);
+#define UVM_MERGE_COPYING 1
+
+bool vm_map_starved_p(struct vm_map *);
+
+/*
+ * VM map locking operations.
+ */
+
+bool vm_map_lock_try(struct vm_map *);
+void vm_map_lock(struct vm_map *);
+void vm_map_unlock(struct vm_map *);
+void vm_map_unbusy(struct vm_map *);
+void vm_map_lock_read(struct vm_map *);
+void vm_map_unlock_read(struct vm_map *);
+void vm_map_busy(struct vm_map *);
+bool vm_map_locked_p(struct vm_map *);
+
+void uvm_map_lock_entry(struct vm_map_entry *);
+void uvm_map_unlock_entry(struct vm_map_entry *);
+
+#endif /* _KERNEL */
+
+/*
+ * Functions implemented as macros
+ */
+#define vm_map_min(map) ((map)->header.end)
+#define vm_map_max(map) ((map)->header.start)
+#define vm_map_setmin(map, v) ((map)->header.end = (v))
+#define vm_map_setmax(map, v) ((map)->header.start = (v))
+
+#define vm_map_pmap(map) ((map)->pmap)
+
+#endif /* _UVM_UVM_MAP_H_ */
--- /dev/null
+/* $NetBSD: uvm_object.h,v 1.33 2012/09/14 22:20:50 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_object.h,v 1.1.2.2 1998/01/04 22:44:51 chuck Exp
+ */
+
+#ifndef _UVM_UVM_OBJECT_H_
+#define _UVM_UVM_OBJECT_H_
+
+#include <sys/queue.h>
+#include <sys/rbtree.h>
+#include <uvm/uvm_pglist.h>
+
+/*
+ * The UVM memory object interface. Notes:
+ *
+ * A UVM memory object represents a list of pages, which are managed by
+ * the object's pager operations (uvm_object::pgops). All pages belonging
+ * to an object are owned by it and thus protected by the object lock.
+ *
+ * The lock (uvm_object::vmobjlock) may be shared amongst the UVM objects.
+ * By default, the lock is allocated dynamically using mutex_obj(9) cache.
+ * Lock sharing is normally used when there is an underlying object. For
+ * example, vnode representing a file may have an underlying node, which
+ * is the case for tmpfs and layered file systems. In such case, vnode's
+ * UVM object and the underlying UVM object shares the lock (note that the
+ * vnode_t::v_interlock points to uvm_object::vmobjlock).
+ *
+ * The reference count is managed atomically for the anonymous UVM objects.
+ * For other objects, it is arbitrary (may use the lock or atomics).
+ */
+
+struct uvm_object {
+ kmutex_t * vmobjlock; /* lock on memq */
+ const struct uvm_pagerops *pgops; /* pager ops */
+ struct pglist memq; /* pages in this object */
+ int uo_npages; /* # of pages in memq */
+ unsigned uo_refs; /* reference count */
+ struct rb_tree rb_tree; /* tree of pages */
+ LIST_HEAD(,ubc_map) uo_ubc; /* ubc mappings */
+};
+
+/*
+ * UVM_OBJ_KERN is a 'special' uo_refs value which indicates that the
+ * object is a kernel memory object rather than a normal one (kernel
+ * memory objects don't have reference counts -- they never die).
+ *
+ * this value is used to detected kernel object mappings at uvm_unmap()
+ * time. normally when an object is unmapped its pages eventaully become
+ * deactivated and then paged out and/or freed. this is not useful
+ * for kernel objects... when a kernel object is unmapped we always want
+ * to free the resources associated with the mapping. UVM_OBJ_KERN
+ * allows us to decide which type of unmapping we want to do.
+ */
+#define UVM_OBJ_KERN (-2)
+
+#define UVM_OBJ_IS_KERN_OBJECT(uobj) \
+ ((uobj)->uo_refs == UVM_OBJ_KERN)
+
+#ifdef _KERNEL
+
+extern const struct uvm_pagerops uvm_vnodeops;
+extern const struct uvm_pagerops uvm_deviceops;
+extern const struct uvm_pagerops ubc_pager;
+extern const struct uvm_pagerops aobj_pager;
+
+#define UVM_OBJ_IS_VNODE(uobj) \
+ ((uobj)->pgops == &uvm_vnodeops)
+
+#define UVM_OBJ_IS_DEVICE(uobj) \
+ ((uobj)->pgops == &uvm_deviceops)
+
+#define UVM_OBJ_IS_VTEXT(uobj) \
+ (UVM_OBJ_IS_VNODE(uobj) && uvn_text_p(uobj))
+
+#define UVM_OBJ_IS_CLEAN(uobj) \
+ (UVM_OBJ_IS_VNODE(uobj) && uvn_clean_p(uobj))
+
+/*
+ * UVM_OBJ_NEEDS_WRITEFAULT: true if the uobj needs to detect modification.
+ * (ie. wants to avoid writable user mappings.)
+ *
+ * XXX bad name
+ */
+
+#define UVM_OBJ_NEEDS_WRITEFAULT(uobj) \
+ (UVM_OBJ_IS_VNODE(uobj) && uvn_needs_writefault_p(uobj))
+
+#define UVM_OBJ_IS_AOBJ(uobj) \
+ ((uobj)->pgops == &aobj_pager)
+
+extern const rb_tree_ops_t uvm_page_tree_ops;
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_OBJECT_H_ */
--- /dev/null
+/* $NetBSD: uvm_page.h,v 1.75 2012/05/05 20:45:35 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * Copyright (c) 1991, 1993, The Regents of the University of California.
+ *
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_page.h 7.3 (Berkeley) 4/21/91
+ * from: Id: uvm_page.h,v 1.1.2.6 1998/02/04 02:31:42 chuck Exp
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#ifndef _UVM_UVM_PAGE_H_
+#define _UVM_UVM_PAGE_H_
+
+#include <uvm/uvm_extern.h>
+#include <uvm/uvm_pglist.h>
+
+#include <sys/rbtree.h>
+
+/*
+ * Management of resident (logical) pages.
+ *
+ * Each resident page has a vm_page structure, indexed by page number.
+ * There are several lists in the structure:
+ *
+ * - A red-black tree rooted with the containing object is used to
+ * quickly perform object+offset lookups.
+ * - A list of all pages for a given object, for a quick deactivation
+ * at a time of deallocation.
+ * - An ordered list of pages due for pageout.
+ *
+ * In addition, the structure contains the object and offset to which
+ * this page belongs (for pageout) and sundry status bits.
+ *
+ * Note that the page structure has no lock of its own. The page is
+ * generally protected by its owner's lock (UVM object or amap/anon).
+ * It should be noted that UVM has to serialize pmap(9) operations on
+ * the managed pages, e.g. for pmap_enter() calls. Hence, the lock
+ * order is as follows:
+ *
+ * [vmpage-owner-lock] ->
+ * any pmap locks (e.g. PV hash lock)
+ *
+ * Since the kernel is always self-consistent, no serialization is
+ * required for unmanaged mappings, e.g. for pmap_kenter_pa() calls.
+ *
+ * Field markings and the corresponding locks:
+ *
+ * o: page owner's lock (UVM object or amap/anon)
+ * p: lock on the page queues
+ * o|p: either lock can be acquired
+ * o&p: both locks are required
+ * ?: locked by pmap or assumed page owner's lock
+ *
+ * UVM and pmap(9) may use uvm_page_locked_p() to assert whether the
+ * page owner's lock is acquired.
+ */
+
+struct vm_page {
+ struct rb_node rb_node; /* o: tree of pages in obj */
+
+ union {
+ TAILQ_ENTRY(vm_page) queue;
+ LIST_ENTRY(vm_page) list;
+ } pageq; /* p: queue info for FIFO
+ * queue or free list */
+ union {
+ TAILQ_ENTRY(vm_page) queue;
+ LIST_ENTRY(vm_page) list;
+ } listq; /* o: pages in same object */
+
+ struct vm_anon *uanon; /* o,p: anon */
+ struct uvm_object *uobject; /* o,p: object */
+ voff_t offset; /* o,p: offset into object */
+ uint16_t flags; /* o: object flags */
+ uint16_t loan_count; /* number of active loans
+ * o|p: for reading
+ * o&p: for modification */
+ uint16_t wire_count; /* p: wired down map refs */
+ uint16_t pqflags; /* p: page queue flags */
+ paddr_t phys_addr; /* physical address of page */
+
+#ifdef __HAVE_VM_PAGE_MD
+ struct vm_page_md mdpage; /* ?: pmap-specific data */
+#endif
+
+#if defined(UVM_PAGE_TRKOWN)
+ /* debugging fields to track page ownership */
+ pid_t owner; /* proc that set PG_BUSY */
+ lwpid_t lowner; /* lwp that set PG_BUSY */
+ const char *owner_tag; /* why it was set busy */
+#endif
+};
+
+/*
+ * Overview of UVM page flags.
+ *
+ * Locking notes:
+ *
+ * PG_, struct vm_page::flags => locked by the owner
+ * PQ_, struct vm_page::pqflags => locked by the page-queue lock
+ * PQ_FREE => additionally locked by free-queue lock
+ *
+ * Flag descriptions:
+ *
+ * PG_BUSY:
+ * Page is long-term locked, usually because of I/O (transfer from the
+ * page memory to the backing store) is in progress. LWP attempting
+ * to access the page shall set PG_WANTED and wait.
+ *
+ * PG_WANTED:
+ * Indicates that the page, which is currently PG_BUSY, is wanted by
+ * some other LWP. The page owner (i.e. LWP which set PG_BUSY) is
+ * responsible to clear both flags and wake up any waiters once it has
+ * released the long-term lock (PG_BUSY).
+ *
+ * PG_RELEASED:
+ * Indicates that the page, which is currently PG_BUSY, should be freed
+ * after the release of long-term lock. It is responsibility of the
+ * owning LWP (i.e. which set PG_BUSY) to do it.
+ *
+ * PG_CLEAN:
+ * Page has not been modified since it was loaded from the backing
+ * store. If this flag is not set, page is considered "dirty".
+ * XXX: Currently it means that the page *might* be clean; will be
+ * fixed with yamt-pagecache merge.
+ *
+ * PG_FAKE:
+ * Page has been allocated, but not yet initialised. The flag is used
+ * to avoid overwriting of valid data, e.g. to prevent read from the
+ * backing store when in-core data is newer.
+ *
+ * PG_TABLED:
+ * Indicates that the page is currently in the object's offset queue,
+ * and that it should be removed from it once the page is freed. Used
+ * diagnostic purposes.
+ *
+ * PG_PAGEOUT:
+ * Indicates that the page is being paged-out in preparation for
+ * being freed.
+ *
+ * PG_RDONLY:
+ * Indicates that the page must be mapped read-only.
+ *
+ * PG_ZERO:
+ * Indicates that the page has been pre-zeroed. This flag is only
+ * set when the page is not in the queues and is cleared when the
+ * page is placed on the free list.
+ *
+ * PG_MARKER:
+ * Dummy marker page.
+ */
+
+#define PG_BUSY 0x0001
+#define PG_WANTED 0x0002
+#define PG_TABLED 0x0004
+#define PG_CLEAN 0x0008
+#define PG_PAGEOUT 0x0010
+#define PG_RELEASED 0x0020
+#define PG_FAKE 0x0040
+#define PG_RDONLY 0x0080
+#define PG_ZERO 0x0100
+#define PG_MARKER 0x0200
+
+#define PG_PAGER1 0x1000 /* pager-specific flag */
+
+#define UVM_PGFLAGBITS \
+ "\20\1BUSY\2WANTED\3TABLED\4CLEAN\5PAGEOUT\6RELEASED\7FAKE\10RDONLY" \
+ "\11ZERO\12MARKER\15PAGER1"
+
+#define PQ_FREE 0x0001 /* page is on free list */
+#define PQ_ANON 0x0002 /* page is part of an anon, rather
+ than an uvm_object */
+#define PQ_AOBJ 0x0004 /* page is part of an anonymous
+ uvm_object */
+#define PQ_SWAPBACKED (PQ_ANON|PQ_AOBJ)
+#define PQ_READAHEAD 0x0008 /* read-ahead but has not been "hit" yet */
+
+#define PQ_PRIVATE1 0x0100
+#define PQ_PRIVATE2 0x0200
+#define PQ_PRIVATE3 0x0400
+#define PQ_PRIVATE4 0x0800
+#define PQ_PRIVATE5 0x1000
+#define PQ_PRIVATE6 0x2000
+#define PQ_PRIVATE7 0x4000
+#define PQ_PRIVATE8 0x8000
+
+#define UVM_PQFLAGBITS \
+ "\20\1FREE\2ANON\3AOBJ\4READAHEAD" \
+ "\11PRIVATE1\12PRIVATE2\13PRIVATE3\14PRIVATE4" \
+ "\15PRIVATE5\16PRIVATE6\17PRIVATE7\20PRIVATE8"
+
+/*
+ * physical memory layout structure
+ *
+ * MD vmparam.h must #define:
+ * VM_PHYSEG_MAX = max number of physical memory segments we support
+ * (if this is "1" then we revert to a "contig" case)
+ * VM_PHYSSEG_STRAT: memory sort/search options (for VM_PHYSEG_MAX > 1)
+ * - VM_PSTRAT_RANDOM: linear search (random order)
+ * - VM_PSTRAT_BSEARCH: binary search (sorted by address)
+ * - VM_PSTRAT_BIGFIRST: linear search (sorted by largest segment first)
+ * - others?
+ * XXXCDC: eventually we should purge all left-over global variables...
+ */
+#define VM_PSTRAT_RANDOM 1
+#define VM_PSTRAT_BSEARCH 2
+#define VM_PSTRAT_BIGFIRST 3
+
+/*
+ * vm_physseg: describes one segment of physical memory
+ */
+struct vm_physseg {
+ paddr_t start; /* PF# of first page in segment */
+ paddr_t end; /* (PF# of last page in segment) + 1 */
+ paddr_t avail_start; /* PF# of first free page in segment */
+ paddr_t avail_end; /* (PF# of last free page in segment) +1 */
+ struct vm_page *pgs; /* vm_page structures (from start) */
+ struct vm_page *lastpg; /* vm_page structure for end */
+ int free_list; /* which free list they belong on */
+ u_int start_hint; /* start looking for free pages here */
+ /* protected by uvm_fpageqlock */
+#ifdef __HAVE_PMAP_PHYSSEG
+ struct pmap_physseg pmseg; /* pmap specific (MD) data */
+#endif
+};
+
+#ifdef _KERNEL
+
+/*
+ * globals
+ */
+
+extern bool vm_page_zero_enable;
+
+/*
+ * physical memory config is stored in vm_physmem.
+ */
+
+#define VM_PHYSMEM_PTR(i) (&vm_physmem[i])
+#define VM_PHYSMEM_PTR_SWAP(i, j) \
+ do { vm_physmem[(i)] = vm_physmem[(j)]; } while (0)
+
+extern struct vm_physseg vm_physmem[VM_PHYSSEG_MAX];
+extern int vm_nphysseg;
+
+/*
+ * prototypes: the following prototypes define the interface to pages
+ */
+
+void uvm_page_init(vaddr_t *, vaddr_t *);
+#if defined(UVM_PAGE_TRKOWN)
+void uvm_page_own(struct vm_page *, const char *);
+#endif
+#if !defined(PMAP_STEAL_MEMORY)
+bool uvm_page_physget(paddr_t *);
+#endif
+void uvm_page_recolor(int);
+void uvm_pageidlezero(void);
+
+void uvm_pageactivate(struct vm_page *);
+vaddr_t uvm_pageboot_alloc(vsize_t);
+void uvm_pagecopy(struct vm_page *, struct vm_page *);
+void uvm_pagedeactivate(struct vm_page *);
+void uvm_pagedequeue(struct vm_page *);
+void uvm_pageenqueue(struct vm_page *);
+void uvm_pagefree(struct vm_page *);
+void uvm_page_unbusy(struct vm_page **, int);
+struct vm_page *uvm_pagelookup(struct uvm_object *, voff_t);
+void uvm_pageunwire(struct vm_page *);
+void uvm_pagewire(struct vm_page *);
+void uvm_pagezero(struct vm_page *);
+bool uvm_pageismanaged(paddr_t);
+bool uvm_page_locked_p(struct vm_page *);
+
+int uvm_page_lookup_freelist(struct vm_page *);
+
+int vm_physseg_find(paddr_t, int *);
+struct vm_page *uvm_phys_to_vm_page(paddr_t);
+paddr_t uvm_vm_page_to_phys(const struct vm_page *);
+
+/*
+ * macros
+ */
+
+#define UVM_PAGE_TREE_PENALTY 4 /* XXX: a guess */
+
+#define VM_PAGE_TO_PHYS(entry) uvm_vm_page_to_phys(entry)
+
+#ifdef __HAVE_VM_PAGE_MD
+#define VM_PAGE_TO_MD(pg) (&(pg)->mdpage)
+#endif
+
+/*
+ * Compute the page color bucket for a given page.
+ */
+#define VM_PGCOLOR_BUCKET(pg) \
+ (atop(VM_PAGE_TO_PHYS((pg))) & uvmexp.colormask)
+
+#define PHYS_TO_VM_PAGE(pa) uvm_phys_to_vm_page(pa)
+
+#define VM_PAGE_IS_FREE(entry) ((entry)->pqflags & PQ_FREE)
+#define VM_FREE_PAGE_TO_CPU(pg) ((struct uvm_cpu *)((uintptr_t)pg->offset))
+
+#ifdef DEBUG
+void uvm_pagezerocheck(struct vm_page *);
+#endif /* DEBUG */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_PAGE_H_ */
--- /dev/null
+/* $NetBSD: uvm_pager.h,v 1.43 2012/04/29 22:54:01 chs Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp
+ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94
+ */
+
+/*
+ * Copyright (c) 1990 University of Utah.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94
+ */
+
+#ifndef _UVM_UVM_PAGER_H_
+#define _UVM_UVM_PAGER_H_
+
+/*
+ * uvm_pager.h
+ */
+
+/*
+ * forward structure declarations
+ */
+
+struct uvm_faultinfo;
+
+/*
+ * pager ops
+ */
+
+struct uvm_pagerops {
+
+ /* init pager */
+ void (*pgo_init)(void);
+
+ /* add reference to obj */
+ void (*pgo_reference)(struct uvm_object *);
+
+ /* drop reference to obj */
+ void (*pgo_detach)(struct uvm_object *);
+
+ /* special non-standard fault processing */
+ int (*pgo_fault)(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
+ int, int, vm_prot_t, int);
+
+ /* get/read pages */
+ int (*pgo_get)(struct uvm_object *, voff_t, struct vm_page **,
+ int *, int, vm_prot_t, int, int);
+
+ /* put/write pages */
+ int (*pgo_put)(struct uvm_object *, voff_t, voff_t, int);
+};
+
+/* pager flags [mostly for flush] */
+
+#define PGO_CLEANIT 0x001 /* write dirty pages to backing store */
+#define PGO_SYNCIO 0x002 /* use sync I/O */
+#define PGO_DEACTIVATE 0x004 /* deactivate flushed pages */
+#define PGO_FREE 0x008 /* free flushed pages */
+/* if PGO_FREE is not set then the pages stay where they are. */
+
+#define PGO_ALLPAGES 0x010 /* flush whole object/get all pages */
+#define PGO_JOURNALLOCKED 0x020 /* journal is already locked [put] */
+#define PGO_LOCKED 0x040 /* fault data structures are locked [get] */
+#define PGO_BUSYFAIL 0x080 /* fail if a page is busy [put] */
+#define PGO_OVERWRITE 0x200 /* pages will be overwritten before unlocked */
+#define PGO_PASTEOF 0x400 /* allow allocation of pages past EOF */
+#define PGO_NOBLOCKALLOC 0x800 /* backing block allocation is not needed */
+#define PGO_NOTIMESTAMP 0x1000 /* don't mark object accessed/modified */
+#define PGO_RECLAIM 0x2000 /* object is being reclaimed */
+#define PGO_GLOCKHELD 0x4000 /* genfs_node's lock is already held */
+#define PGO_LAZY 0x8000 /* equivalent of MNT_LAZY / FSYNC_LAZY */
+
+/* page we are not interested in getting */
+#define PGO_DONTCARE ((struct vm_page *) -1L) /* [get only] */
+
+#ifdef _KERNEL
+
+/*
+ * prototypes
+ */
+
+void uvm_pager_init(void);
+void uvm_pager_realloc_emerg(void);
+struct vm_page *uvm_pageratop(vaddr_t);
+vaddr_t uvm_pagermapin(struct vm_page **, int, int);
+void uvm_pagermapout(vaddr_t, int);
+
+extern size_t pager_map_size;
+
+/* Flags to uvm_pagermapin() */
+#define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */
+#define UVMPAGER_MAPIN_READ 0x02 /* device -> host */
+#define UVMPAGER_MAPIN_WRITE 0x00 /* host -> device (pseudo flag) */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_PAGER_H_ */
--- /dev/null
+/* $NetBSD: uvm_param.h,v 1.31 2012/03/19 00:17:08 uebayasi Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_param.h 8.2 (Berkeley) 1/9/95
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+/*
+ * Machine independent virtual memory parameters.
+ */
+
+#ifndef _VM_PARAM_
+#define _VM_PARAM_
+
+#ifdef _KERNEL_OPT
+#include "opt_modular.h"
+#include "opt_uvm.h"
+#endif
+#ifdef _KERNEL
+#include <sys/types.h>
+#include <machine/vmparam.h>
+#include <sys/resourcevar.h>
+#endif
+
+#if defined(_KERNEL)
+
+#if defined(PAGE_SIZE)
+
+/*
+ * If PAGE_SIZE is defined at this stage, it must be a constant.
+ */
+
+#if PAGE_SIZE == 0
+#error Invalid PAGE_SIZE definition
+#endif
+
+/*
+ * If the platform does not need to support a variable PAGE_SIZE,
+ * then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE.
+ */
+
+#if !defined(MIN_PAGE_SIZE)
+#define MIN_PAGE_SIZE PAGE_SIZE
+#endif /* ! MIN_PAGE_SIZE */
+
+#if !defined(MAX_PAGE_SIZE)
+#define MAX_PAGE_SIZE PAGE_SIZE
+#endif /* ! MAX_PAGE_SIZE */
+
+#else /* ! PAGE_SIZE */
+
+/*
+ * PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must
+ * be defined.
+ */
+
+#if !defined(MIN_PAGE_SIZE)
+#error MIN_PAGE_SIZE not defined
+#endif
+
+#if !defined(MAX_PAGE_SIZE)
+#error MAX_PAGE_SIZE not defined
+#endif
+
+#endif /* PAGE_SIZE */
+
+/*
+ * MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants.
+ */
+
+#if MIN_PAGE_SIZE == 0
+#error Invalid MIN_PAGE_SIZE definition
+#endif
+
+#if MAX_PAGE_SIZE == 0
+#error Invalid MAX_PAGE_SIZE definition
+#endif
+
+/*
+ * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
+ * non-constant PAGE_SIZE, et al for LKMs.
+ */
+#if (MIN_PAGE_SIZE != MAX_PAGE_SIZE)
+#define __uvmexp_pagesize
+#if defined(_LKM) || defined(_MODULE)
+#undef PAGE_SIZE
+#undef PAGE_MASK
+#undef PAGE_SHIFT
+#endif
+#endif
+
+/*
+ * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
+ * have ones that are compile-time constants.
+ */
+#if !defined(PAGE_SIZE)
+extern const int *const uvmexp_pagesize;
+extern const int *const uvmexp_pagemask;
+extern const int *const uvmexp_pageshift;
+#define PAGE_SIZE (*uvmexp_pagesize) /* size of page */
+#define PAGE_MASK (*uvmexp_pagemask) /* size of page - 1 */
+#define PAGE_SHIFT (*uvmexp_pageshift) /* bits to shift for pages */
+#endif /* PAGE_SIZE */
+
+#endif /* _KERNEL */
+
+/*
+ * CTL_VM identifiers
+ */
+#define VM_METER 1 /* struct vmmeter */
+#define VM_LOADAVG 2 /* struct loadavg */
+#define VM_UVMEXP 3 /* struct uvmexp */
+#define VM_NKMEMPAGES 4 /* kmem_map pages */
+#define VM_UVMEXP2 5 /* struct uvmexp_sysctl */
+#define VM_ANONMIN 6
+#define VM_EXECMIN 7
+#define VM_FILEMIN 8
+#define VM_MAXSLP 9
+#define VM_USPACE 10
+#define VM_ANONMAX 11
+#define VM_EXECMAX 12
+#define VM_FILEMAX 13
+
+#define VM_MAXID 14 /* number of valid vm ids */
+
+#define CTL_VM_NAMES { \
+ { 0, 0 }, \
+ { "vmmeter", CTLTYPE_STRUCT }, \
+ { "loadavg", CTLTYPE_STRUCT }, \
+ { "uvmexp", CTLTYPE_STRUCT }, \
+ { "nkmempages", CTLTYPE_INT }, \
+ { "uvmexp2", CTLTYPE_STRUCT }, \
+ { "anonmin", CTLTYPE_INT }, \
+ { "execmin", CTLTYPE_INT }, \
+ { "filemin", CTLTYPE_INT }, \
+ { "maxslp", CTLTYPE_INT }, \
+ { "uspace", CTLTYPE_INT }, \
+ { "anonmax", CTLTYPE_INT }, \
+ { "execmax", CTLTYPE_INT }, \
+ { "filemax", CTLTYPE_INT }, \
+}
+
+#ifndef ASSEMBLER
+/*
+ * Convert addresses to pages and vice versa.
+ * No rounding is used.
+ */
+#ifdef _KERNEL
+#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT)
+#define ptoa(x) (((paddr_t)(x)) << PAGE_SHIFT)
+
+/*
+ * Round off or truncate to the nearest page. These will work
+ * for either addresses or counts (i.e., 1 byte rounds to 1 page).
+ */
+#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
+#define trunc_page(x) ((x) & ~PAGE_MASK)
+
+/*
+ * Set up the default mapping address (VM_DEFAULT_ADDRESS) according to:
+ *
+ * USE_TOPDOWN_VM: a kernel option to enable on a per-kernel basis
+ * which only be used on ports that define...
+ * __HAVE_TOPDOWN_VM: a per-port option to offer the topdown option
+ *
+ * __USE_TOPDOWN_VM: a per-port option to unconditionally use it
+ *
+ * if __USE_TOPDOWN_VM is defined, the port can specify a default vm
+ * address, or we will use the topdown default from below. If it is
+ * NOT defined, then the port can offer topdown as an option, but it
+ * MUST define the VM_DEFAULT_ADDRESS macro itself.
+ */
+#if defined(USE_TOPDOWN_VM) || defined(__USE_TOPDOWN_VM)
+# if !defined(__HAVE_TOPDOWN_VM) && !defined(__USE_TOPDOWN_VM)
+# error "Top down memory allocation not enabled for this system"
+# else /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
+# define __USING_TOPDOWN_VM
+# if !defined(VM_DEFAULT_ADDRESS)
+# if !defined(__USE_TOPDOWN_VM)
+# error "Top down memory allocation not configured for this system"
+# else /* !__USE_TOPDOWN_VM */
+# define VM_DEFAULT_ADDRESS(da, sz) \
+ trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz))
+# endif /* !__USE_TOPDOWN_VM */
+# endif /* !VM_DEFAULT_ADDRESS */
+# endif /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
+#endif /* USE_TOPDOWN_VM || __USE_TOPDOWN_VM */
+
+#if !defined(__USING_TOPDOWN_VM)
+# if defined(VM_DEFAULT_ADDRESS)
+# error "Default vm address should not be defined here"
+# else /* VM_DEFAULT_ADDRESS */
+# define VM_DEFAULT_ADDRESS(da, sz) round_page((vaddr_t)(da) + (vsize_t)maxdmap)
+# endif /* VM_DEFAULT_ADDRESS */
+#endif /* !__USING_TOPDOWN_VM */
+
+extern int ubc_nwins; /* number of UBC mapping windows */
+extern int ubc_winshift; /* shift for a UBC mapping window */
+extern u_int uvm_emap_size; /* size of emap */
+
+#else
+/* out-of-kernel versions of round_page and trunc_page */
+#define round_page(x) \
+ ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
+ vm_page_size)
+#define trunc_page(x) \
+ ((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
+
+#endif /* _KERNEL */
+
+/*
+ * typedefs, necessary for standard UVM headers.
+ */
+
+typedef unsigned int uvm_flag_t;
+
+typedef int vm_inherit_t; /* XXX: inheritance codes */
+typedef off_t voff_t; /* XXX: offset within a uvm_object */
+typedef voff_t pgoff_t; /* XXX: number of pages within a uvm object */
+
+#endif /* ASSEMBLER */
+#endif /* _VM_PARAM_ */
--- /dev/null
+/* $NetBSD: uvm_pdaemon.h,v 1.17 2011/02/02 15:25:27 chuck Exp $ */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * Copyright (c) 1991, 1993, The Regents of the University of California.
+ *
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94
+ * from: Id: uvm_pdaemon.h,v 1.1.2.4 1998/02/02 20:07:20 chuck Exp
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#ifndef _UVM_UVM_PDAEMON_H_
+#define _UVM_UVM_PDAEMON_H_
+
+/*
+ * uvm_pdaemon.h: page daemon hooks
+ */
+
+#ifdef _KERNEL
+
+/*
+ * prototypes
+ */
+
+void uvm_wait(const char *);
+bool uvm_reclaimable(void);
+
+kmutex_t *uvmpd_trylockowner(struct vm_page *);
+#ifdef VMSWAP
+bool uvmpd_trydropswap(struct vm_page *);
+#else
+#define uvmpd_trydropswap(_a_) (/*CONSTCOND*/false)
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_PDAEMON_H_ */
--- /dev/null
+/* $NetBSD: uvm_pdpolicy.h,v 1.3 2007/02/21 23:00:14 thorpej Exp $ */
+
+/*-
+ * Copyright (c)2005, 2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _UVM_PDPOLICY_H_
+#define _UVM_PDPOLICY_H_
+
+struct vm_page;
+struct vm_anon;
+
+/*
+ * these API is for uvm internal use only.
+ * don't use them directly from outside of /sys/uvm.
+ */
+
+void uvmpdpol_init(void);
+void uvmpdpol_reinit(void);
+void uvmpdpol_estimatepageable(int *, int *);
+bool uvmpdpol_needsscan_p(void);
+
+void uvmpdpol_pageactivate(struct vm_page *);
+void uvmpdpol_pagedeactivate(struct vm_page *);
+void uvmpdpol_pagedequeue(struct vm_page *);
+void uvmpdpol_pageenqueue(struct vm_page *);
+bool uvmpdpol_pageisqueued_p(struct vm_page *);
+void uvmpdpol_anfree(struct vm_anon *);
+
+void uvmpdpol_tune(void);
+void uvmpdpol_scaninit(void);
+struct vm_page *uvmpdpol_selectvictim(void);
+void uvmpdpol_balancequeue(int);
+
+void uvmpdpol_sysctlsetup(void);
+
+#endif /* !_UVM_PDPOLICY_H_ */
--- /dev/null
+/* $NetBSD: uvm_pdpolicy_impl.h,v 1.2 2006/09/15 15:51:13 yamt Exp $ */
+
+/*-
+ * Copyright (c)2006 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _UVM_PDPOLICY_IMPL_H_
+#define _UVM_PDPOLICY_IMPL_H_
+
+/*
+ * definitions for page replacement policy implementations.
+ */
+
+#include <sys/evcnt.h>
+
+#define PDPOL_EVCNT_DEFINE(name) \
+struct evcnt pdpol_evcnt_##name = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, \
+ "pdpolicy", #name); \
+EVCNT_ATTACH_STATIC(pdpol_evcnt_##name);
+#define PDPOL_EVCNT_INCR(ev) pdpol_evcnt_##ev.ev_count++
+
+#endif /* !_UVM_PDPOLICY_IMPL_H_ */
--- /dev/null
+/* $NetBSD: uvm_pglist.h,v 1.8 2010/11/06 15:48:00 uebayasi Exp $ */
+
+/*-
+ * Copyright (c) 2000, 2001, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _UVM_UVM_PGLIST_H_
+#define _UVM_UVM_PGLIST_H_
+
+/*
+ * This defines the type of a page queue, e.g. active list, inactive
+ * list, etc.
+ */
+struct vm_page;
+TAILQ_HEAD(pglist, vm_page);
+LIST_HEAD(pgflist, vm_page);
+
+/*
+ * A page free list consists of free pages of unknown contents and free
+ * pages of all zeros.
+ */
+#define PGFL_UNKNOWN 0
+#define PGFL_ZEROS 1
+#define PGFL_NQUEUES 2
+
+struct pgflbucket {
+ struct pgflist pgfl_queues[PGFL_NQUEUES];
+};
+
+struct pgfreelist {
+ struct pgflbucket *pgfl_buckets;
+};
+
+#endif /* _UVM_UVM_PGLIST_H_ */
--- /dev/null
+/* $NetBSD: uvm_pmap.h,v 1.37 2011/06/30 00:49:14 matt Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pmap.h 8.1 (Berkeley) 6/11/93
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Avadis Tevanian, Jr.
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+/*
+ * Machine address mapping definitions -- machine-independent
+ * section. [For machine-dependent section, see "machine/pmap.h".]
+ */
+
+#ifndef _PMAP_VM_
+#define _PMAP_VM_
+
+struct lwp; /* for pmap_activate()/pmap_deactivate() proto */
+
+struct pmap;
+typedef struct pmap *pmap_t;
+
+/*
+ * Each machine dependent implementation is expected to
+ * keep certain statistics. They may do this anyway they
+ * so choose, but are expected to return the statistics
+ * in the following structure.
+ */
+struct pmap_statistics {
+ long resident_count; /* # of pages mapped (total)*/
+ long wired_count; /* # of pages wired */
+};
+typedef struct pmap_statistics *pmap_statistics_t;
+
+#ifdef _KERNEL
+
+extern struct pmap *const kernel_pmap_ptr;
+#define pmap_kernel() kernel_pmap_ptr
+
+#endif
+
+/*
+ * Cache Type Encodings
+ */
+#define PMAP_CACHE_MASK 0x00000f00
+
+/* All accesses are uncacheable. No speculative accesses. */
+#define PMAP_NOCACHE 0x00000100 /* [BOTH] */
+
+/* All accesses are uncacheable. No speculative accesses.
+ * Writes are combined. */
+#define PMAP_WRITE_COMBINE 0x00000200 /* [BOTH] */
+
+/* On reads, cachelines become shared or exclusive if allocated on cache miss.
+ * On writes, cachelines become modified on a cache miss. */
+#define PMAP_WRITE_BACK 0x00000300 /* [BOTH] */
+
+/* = PMAP_NOCACHE but overrideable (e.g. on x86 by MTRRs) */
+#define PMAP_NOCACHE_OVR 0x00000400 /* [BOTH] */
+
+#ifdef _KERNEL
+#include <machine/pmap.h>
+#endif
+
+/*
+ * Flags passed to pmap_enter(). Note the bottom 3 bits are VM_PROT_*
+ * bits, used to indicate the access type that was made (to seed modified
+ * and referenced information).
+ *
+ * Flags marked [PA] are for pmap_kenter_pa() only. Flags marked [BOTH]
+ * apply to pmap_kenter_pa() and pmap_enter(). All other flags are valid
+ * for pmap_enter() only.
+ */
+#define PMAP_WIRED 0x00000010 /* wired mapping */
+#define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */
+#if defined(PMAP_ENABLE_PMAP_KMPAGE)
+#define PMAP_KMPAGE 0x00000040 /* [PA] page used for kernel memory */
+#else
+#define PMAP_KMPAGE 0x00000000
+#endif /* PMAP_ENABLE_PMAP_KMPAGE */
+
+#define PMAP_MD_MASK 0xff000000 /* [BOTH] Machine-dependent bits */
+#define PMAP_PROT_MASK 0x0000000f /* [BOTH] VM_PROT_* bit mask */
+
+#ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */
+#ifdef _KERNEL
+__BEGIN_DECLS
+void pmap_activate(struct lwp *);
+void pmap_deactivate(struct lwp *);
+void pmap_unwire(pmap_t, vaddr_t);
+
+#if !defined(pmap_clear_modify)
+bool pmap_clear_modify(struct vm_page *);
+#endif
+#if !defined(pmap_clear_reference)
+bool pmap_clear_reference(struct vm_page *);
+#endif
+
+#if !defined(pmap_copy)
+void pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
+#endif
+#if !defined(pmap_copy_page)
+void pmap_copy_page(paddr_t, paddr_t);
+#endif
+struct pmap *pmap_create(void);
+void pmap_destroy(pmap_t);
+int pmap_enter(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
+bool pmap_extract(pmap_t, vaddr_t, paddr_t *);
+#if defined(PMAP_GROWKERNEL)
+vaddr_t pmap_growkernel(vaddr_t);
+#endif
+
+void pmap_init(void);
+
+void pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t, u_int);
+void pmap_kremove(vaddr_t, vsize_t);
+#if !defined(pmap_is_modified)
+bool pmap_is_modified(struct vm_page *);
+#endif
+#if !defined(pmap_is_referenced)
+bool pmap_is_referenced(struct vm_page *);
+#endif
+
+void pmap_page_protect(struct vm_page *, vm_prot_t);
+
+#if !defined(pmap_phys_address)
+paddr_t pmap_phys_address(paddr_t);
+#endif
+#if !defined(pmap_mmap_flags)
+#define pmap_mmap_flags(x) 0
+#endif
+void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
+#if !defined(pmap_reference)
+void pmap_reference(pmap_t);
+#endif
+#if !defined(pmap_remove)
+void pmap_remove(pmap_t, vaddr_t, vaddr_t);
+#endif
+void pmap_remove_all(struct pmap *);
+#if !defined(pmap_update)
+void pmap_update(pmap_t);
+#endif
+#if !defined(pmap_resident_count)
+long pmap_resident_count(pmap_t);
+#endif
+#if !defined(pmap_wired_count)
+long pmap_wired_count(pmap_t);
+#endif
+#if !defined(pmap_zero_page)
+void pmap_zero_page(paddr_t);
+#endif
+
+void pmap_virtual_space(vaddr_t *, vaddr_t *);
+#if defined(PMAP_STEAL_MEMORY)
+vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *);
+#endif
+
+#if defined(PMAP_FORK)
+void pmap_fork(pmap_t, pmap_t);
+#endif
+__END_DECLS
+#endif /* kernel*/
+#endif /* PMAP_EXCLUDE_DECLS */
+
+#endif /* _PMAP_VM_ */
--- /dev/null
+/* $NetBSD: uvm_prot.h,v 1.4 2005/12/11 12:25:29 christos Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vm_prot.h 8.1 (Berkeley) 6/11/93
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+/*
+ * Virtual memory protection definitions.
+ */
+
+#ifndef _UVM_PROT_
+#define _UVM_PROT_
+
+/*
+ * Types defined:
+ *
+ * vm_prot_t VM protection values.
+ */
+
+typedef int vm_prot_t;
+
+/*
+ * Protection values, defined as bits within the vm_prot_t type
+ */
+
+#define VM_PROT_NONE ((vm_prot_t) 0x00)
+
+#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */
+#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */
+#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */
+
+/*
+ * The default protection for newly-created virtual memory
+ */
+
+#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
+
+/*
+ * The maximum privileges possible, for parameter checking.
+ */
+
+#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
+
+#endif /* _UVM_PROT_ */
--- /dev/null
+/* $NetBSD: uvm_readahead.h,v 1.4 2009/06/10 01:54:08 yamt Exp $ */
+
+/*-
+ * Copyright (c)2003, 2005, 2009 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if !defined(_UVM_UVM_READAHEAD_H_)
+#define _UVM_UVM_READAHEAD_H_
+
+struct uvm_object;
+struct uvm_ractx;
+
+void uvm_ra_init(void);
+struct uvm_ractx *uvm_ra_allocctx(void);
+void uvm_ra_freectx(struct uvm_ractx *);
+void uvm_ra_request(struct uvm_ractx *, int, struct uvm_object *, off_t,
+ size_t);
+int uvm_readahead(struct uvm_object *, off_t, off_t);
+
+#endif /* defined(_UVM_UVM_READAHEAD_H_) */
--- /dev/null
+/* $NetBSD: uvm_stat.h,v 1.51 2012/07/30 23:56:48 matt Exp $ */
+
+/*
+ * Copyright (c) 2011 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Backwards compat for UVMHIST, in the new KERNHIST form.
+ */
+
+#ifndef _UVM_UVM_STAT_H_
+#define _UVM_UVM_STAT_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_uvmhist.h"
+#include "opt_kernhist.h"
+#endif
+
+/*
+ * Make UVMHIST_PRINT force on KERNHIST_PRINT for at least UVMHIST_* usage.
+ */
+#if defined(UVMHIST_PRINT) && !defined(KERNHIST_PRINT)
+#define KERNHIST_PRINT 1
+#endif
+
+#include <sys/kernhist.h>
+
+#ifdef UVMHIST
+
+#define UVMHIST_DECL(NAME) KERNHIST_DECL(NAME)
+#define UVMHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME)
+#define UVMHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N)
+#define UVMHIST_INIT_STATIC(NAME,BUF) KERNHIST_INIT_STATIC(NAME,BUF)
+#define UVMHIST_LOG(NAME,FMT,A,B,C,D) KERNHIST_LOG(NAME,FMT,A,B,C,D)
+#define UVMHIST_CALLED(NAME) KERNHIST_CALLED(NAME)
+#define UVMHIST_FUNC(FNAME) KERNHIST_FUNC(FNAME)
+
+#else
+
+#define UVMHIST_DECL(NAME)
+#define UVMHIST_DEFINE(NAME)
+#define UVMHIST_INIT(NAME,N)
+#define UVMHIST_INIT_STATIC(NAME,BUF)
+#define UVMHIST_LOG(NAME,FMT,A,B,C,D)
+#define UVMHIST_CALLED(NAME)
+#define UVMHIST_FUNC(FNAME)
+
+#endif
+
+#endif /* _UVM_UVM_STAT_H_ */
--- /dev/null
+/* $NetBSD: uvm_swap.h,v 1.18 2011/04/27 00:35:52 rmind Exp $ */
+
+/*
+ * Copyright (c) 1997 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Id: uvm_swap.h,v 1.1.2.6 1997/12/15 05:39:31 mrg Exp
+ */
+
+#ifndef _UVM_UVM_SWAP_H_
+#define _UVM_UVM_SWAP_H_
+
+#define SWSLOT_BAD (-1)
+
+#ifdef _KERNEL
+#if defined(_KERNEL_OPT)
+#include "opt_vmswap.h"
+#endif
+
+struct swapent;
+
+#if defined(VMSWAP)
+int uvm_swap_get(struct vm_page *, int, int);
+int uvm_swap_put(int, struct vm_page **, int, int);
+int uvm_swap_alloc(int *, bool);
+void uvm_swap_free(int, int);
+void uvm_swap_markbad(int, int);
+bool uvm_swapisfull(void);
+#else /* defined(VMSWAP) */
+#define uvm_swapisfull() true
+#endif /* defined(VMSWAP) */
+
+#endif /* _KERNEL */
+
+#endif /* _UVM_UVM_SWAP_H_ */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
41 42 43 44 45 46 48 49 50 52 53 54 55 56 58 59 60 \
-61 64 65 66 67 68 69 70 71 72 73 74 75 76 77
+61 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
.if ${MACHINE_ARCH} == "i386"
MINIX_TESTS+= \
# Programs that require setuid
setuids="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
- test69 test76 test77" # test73"
+ test69 test76 test77 test78" # test73"
# Scripts that require to be run as root
rootscripts="testisofs testvnd"
alltests="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
- 61 62 63 64 65 66 67 68 69 70 71 72 75 76 77 \
+ 61 62 63 64 65 66 67 68 69 70 71 72 75 76 77 78 \
sh1 sh2 interp mfs isofs vnd"
tests_no=`expr 0`
--- /dev/null
+/* Test for getdents().
+ * Just tests whatever FS the test is executed from.
+ *
+ * This test creates lots of nodes of various types, verifies that readdir()
+ * (and so getdents()) returns all of them exactly once, and nothing else
+ * (except for "." and ".."), and verifies the struct dirents are correct.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "common.h"
+
+#define FILETYPES 6
+
+#define LOOPS 30
+
+struct filetype {
+ char *fnbase; /* type-unique base name */
+ int dt; /* dirent type that getdents() should return */
+ mode_t modebit; /* mode bit unique to this type */
+} filetypes[FILETYPES] = {
+ { "fifo", DT_FIFO, S_IFIFO },
+ { "chr", DT_CHR, S_IFCHR },
+ { "dir", DT_DIR, S_IFDIR },
+ { "blk", DT_BLK, S_IFBLK },
+ { "reg", DT_REG, S_IFREG },
+ { "lnk", DT_LNK, S_IFLNK },
+};
+
+int seen[FILETYPES][LOOPS];
+
+/* create a node named 'f' using code 'call'. check it doesn't exist
+ * before hand, and does exist afterwards, and has the expected modebit.
+ */
+
+#define CR(f, call, modebit) do { \
+ struct stat sb; \
+ if(lstat(f, &sb) >= 0) { e(1); } \
+ if((call) < 0) { e(2); } \
+ if(lstat(f, &sb) < 0) { e(3); } \
+ if(!(sb.st_mode & (modebit))) { e(4); } \
+} while(0)
+
+int
+main(int argc, char **argv)
+{
+ int i, t;
+ DIR *dir;
+ struct dirent *de;
+
+ start(78);
+
+ /* create contents */
+
+ for(i = 0; i < LOOPS; i++) {
+ for(t = 0; t < FILETYPES; t++) {
+ int c;
+ char fn[2000];
+ mode_t m = filetypes[t].modebit;
+
+ /* think of a filename; do varying lengths to check
+ * dirent record length alignment issues
+ */
+
+ snprintf(fn, sizeof(fn), "%d.%d.%d.", t, filetypes[t].dt, i);
+ for(c = 0; c < i; c++) strcat(fn, "x");
+
+ /* create the right type */
+
+ switch(filetypes[t].dt) {
+ case DT_FIFO: CR(fn, mknod(fn, 0600|S_IFIFO, 0), m); break;
+ case DT_CHR: CR(fn, mknod(fn, 0600|S_IFCHR, 0), m); break;
+ case DT_BLK: CR(fn, mknod(fn, 0600|S_IFBLK, 0), m); break;
+ case DT_REG: CR(fn, mknod(fn, 0600|S_IFREG, 0), m); break;
+ case DT_DIR: CR(fn, mkdir(fn, 0600), m); break;
+ case DT_LNK: CR(fn, symlink("dest", fn), m); break;
+ default: e(10); break;
+ }
+ }
+ }
+
+ /* Verify that readdir() returns dirent structs with reasonable contents */
+
+ if(!(dir = opendir("."))) { e(20); return 1; }
+
+ while((de = readdir(dir))) {
+ int dt;
+ struct stat sb;
+
+ if(!strcmp(de->d_name, ".")) continue;
+ if(!strcmp(de->d_name, "..")) continue;
+
+ if(sscanf(de->d_name, "%d.%d.%d", &t, &dt, &i) != 3) {
+ e(30);
+ continue;
+ }
+
+ /* sanity check on filename numbers */
+
+ if(t < 0 || dt < 0 || i < 0) { e(31); continue; }
+ if(t >= FILETYPES || i >= LOOPS) { e(32); continue; }
+ if(seen[t][i]) { e(33); continue; }
+ seen[t][i] = 1;
+ if(filetypes[t].dt != dt) { e(34); continue; }
+ if(lstat(de->d_name, &sb) < 0) { e(35); continue; }
+ if(!(sb.st_mode & filetypes[t].modebit)) { e(36); continue; }
+
+ /* Now we know this file is ours and has the expected type;
+ * now we can verify the contents of the dirent struct. d_name
+ * is OK because sscanf and stat worked on it.
+ */
+
+ if(de->d_type != dt) { e(37); }
+ if(de->d_fileno != sb.st_ino) { e(38); }
+ if(de->d_namlen != strlen(de->d_name)) { e(39); }
+ if(de->d_reclen != _DIRENT_RECLEN(de, de->d_namlen)) { e(40); }
+ }
+
+ if(closedir(dir) < 0) e(50);
+
+ /* Verify that we have seen all files we expected to see. */
+
+ for(i = 0; i < LOOPS; i++) {
+ for(t = 0; t < FILETYPES; t++) {
+ if(!seen[t][i]) { e(60); break; }
+ }
+ }
+
+ quit();
+}
{
FILE *masf;
unsigned long size;
- static char buf[_MAX_BLOCK_SIZE];
+ static char buf[BOOT_BLOCK_SIZE];
/* Open device. */
if ((rawfd= open(rawdev= device, O_RDWR)) < 0) fatal(device);