netbsd dirent.h, import sys/sys *.h, mfs cleanup
. add all sys/sys headers not already present to help compiling . take netbsd dirent.h and struct dirent; main result is introducing d_type and d_namlen that have to be set by getdents() in all FS code implementing it . d_off is gone . alignment of the struct has become 8 bytes instead of 4 . remove _MAX_BLOCK_SIZE, _MIN_BLOCK_SIZE, _STATIC_BLOCK_SIZE . libminlib: cleanup unused yet duplicate code . mfs: throw out the long-broken v1, v2 support . new test for dirent contents filled by getdents() Change-Id: I1459755c7ba5e5d1c9396d3a587ce6e63ddc283e
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
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
|
||||
|
||||
@@ -9,7 +9,7 @@ INCS= aeabi.h ansi.h asm.h \
|
||||
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 \
|
||||
|
||||
61
sys/arch/arm/include/proc.h
Normal file
61
sys/arch/arm/include/proc.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $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_ */
|
||||
@@ -13,7 +13,7 @@ INCS= ansi.h asm.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 \
|
||||
|
||||
3
sys/arch/evbarm/include/proc.h
Normal file
3
sys/arch/evbarm/include/proc.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: proc.h,v 1.1 2001/11/25 15:56:05 thorpej Exp $ */
|
||||
|
||||
#include <arm/proc.h>
|
||||
@@ -7,8 +7,8 @@ INCS= ansi.h asm.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 \
|
||||
\
|
||||
|
||||
178
sys/arch/i386/include/frame.h
Normal file
178
sys/arch/i386/include/frame.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/* $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_ */
|
||||
3
sys/arch/i386/include/lock.h
Normal file
3
sys/arch/i386/include/lock.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: lock.h,v 1.9 2003/02/27 00:12:22 fvdl Exp $ */
|
||||
|
||||
#include <x86/lock.h>
|
||||
@@ -42,7 +42,6 @@
|
||||
#ifndef _I386_NPX_H_
|
||||
#define _I386_NPX_H_
|
||||
|
||||
#ifndef __minix
|
||||
/* Environment information of floating point unit */
|
||||
struct env87 {
|
||||
long en_cw; /* control word (16bits) */
|
||||
@@ -121,7 +120,6 @@ union savefpu {
|
||||
struct save87 sv_87;
|
||||
struct savexmm sv_xmm;
|
||||
};
|
||||
#endif /* !__minix */
|
||||
|
||||
/*
|
||||
* The i387 defaults to Intel extended precision mode and round to nearest,
|
||||
|
||||
115
sys/arch/i386/include/pcb.h
Normal file
115
sys/arch/i386/include/pcb.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $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_ */
|
||||
73
sys/arch/i386/include/proc.h
Normal file
73
sys/arch/i386/include/proc.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $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_ */
|
||||
340
sys/arch/i386/include/segments.h
Normal file
340
sys/arch/i386/include/segments.h
Normal file
@@ -0,0 +1,340 @@
|
||||
/* $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_ */
|
||||
3
sys/arch/i386/include/sysarch.h
Normal file
3
sys/arch/i386/include/sysarch.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: sysarch.h,v 1.18 2007/04/16 19:12:19 ad Exp $ */
|
||||
|
||||
#include <x86/sysarch.h>
|
||||
79
sys/arch/i386/include/tss.h
Normal file
79
sys/arch/i386/include/tss.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* $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_ */
|
||||
@@ -4,43 +4,43 @@
|
||||
|
||||
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 \
|
||||
@@ -56,7 +56,7 @@ INCSYMLINKS=\
|
||||
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
|
||||
|
||||
80
sys/sys/acct.h
Normal file
80
sys/sys/acct.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* $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_ */
|
||||
144
sys/sys/agpio.h
Normal file
144
sys/sys/agpio.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/* $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_ */
|
||||
126
sys/sys/aio.h
Normal file
126
sys/sys/aio.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/* $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_ */
|
||||
68
sys/sys/aout_mids.h
Normal file
68
sys/sys/aout_mids.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* $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_ */
|
||||
56
sys/sys/ataio.h
Normal file
56
sys/sys/ataio.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* $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_ */
|
||||
338
sys/sys/audioio.h
Normal file
338
sys/sys/audioio.h
Normal file
@@ -0,0 +1,338 @@
|
||||
/* $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_ */
|
||||
90
sys/sys/blist.h
Normal file
90
sys/sys/blist.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* $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_ */
|
||||
|
||||
310
sys/sys/buf.h
Normal file
310
sys/sys/buf.h
Normal file
@@ -0,0 +1,310 @@
|
||||
/* $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_ */
|
||||
105
sys/sys/bufq.h
Normal file
105
sys/sys/bufq.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/* $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 *);
|
||||
139
sys/sys/bufq_impl.h
Normal file
139
sys/sys/bufq_impl.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $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)
|
||||
248
sys/sys/bus.h
Normal file
248
sys/sys/bus.h
Normal file
@@ -0,0 +1,248 @@
|
||||
/* $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_ */
|
||||
358
sys/sys/bus_proto.h
Normal file
358
sys/sys/bus_proto.h
Normal file
@@ -0,0 +1,358 @@
|
||||
/* $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_ */
|
||||
63
sys/sys/callback.h
Normal file
63
sys/sys/callback.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* $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_ */
|
||||
119
sys/sys/callout.h
Normal file
119
sys/sys/callout.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/* $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_ */
|
||||
53
sys/sys/cctr.h
Normal file
53
sys/sys/cctr.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* $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_ */
|
||||
425
sys/sys/cdio.h
Normal file
425
sys/sys/cdio.h
Normal file
@@ -0,0 +1,425 @@
|
||||
/* $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_ */
|
||||
280
sys/sys/chio.h
Normal file
280
sys/sys/chio.h
Normal file
@@ -0,0 +1,280 @@
|
||||
/* $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_ */
|
||||
76
sys/sys/clockctl.h
Normal file
76
sys/sys/clockctl.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $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_ */
|
||||
273
sys/sys/conf.h
Normal file
273
sys/sys/conf.h
Normal file
@@ -0,0 +1,273 @@
|
||||
/* $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_ */
|
||||
116
sys/sys/core.h
Normal file
116
sys/sys/core.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* $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_ */
|
||||
151
sys/sys/cprng.h
Normal file
151
sys/sys/cprng.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* $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
|
||||
140
sys/sys/cpu.h
Normal file
140
sys/sys/cpu.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/* $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_ */
|
||||
135
sys/sys/cpu_data.h
Normal file
135
sys/sys/cpu_data.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* $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_ */
|
||||
93
sys/sys/cpufreq.h
Normal file
93
sys/sys/cpufreq.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* $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_ */
|
||||
83
sys/sys/cpuio.h
Normal file
83
sys/sys/cpuio.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $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_ */
|
||||
52
sys/sys/debug.h
Normal file
52
sys/sys/debug.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* $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__ */
|
||||
585
sys/sys/device.h
Normal file
585
sys/sys/device.h
Normal file
@@ -0,0 +1,585 @@
|
||||
/* $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_ */
|
||||
27
sys/sys/device_if.h
Normal file
27
sys/sys/device_if.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* $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 */
|
||||
36
sys/sys/devmon.h
Normal file
36
sys/sys/devmon.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* $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_*/
|
||||
64
sys/sys/dir.h
Normal file
64
sys/sys/dir.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* $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_ */
|
||||
116
sys/sys/dirent.h
116
sys/sys/dirent.h
@@ -1,58 +1,115 @@
|
||||
/* $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
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
@@ -62,4 +119,11 @@ struct dirent { /* Largest entry (8 slots) */
|
||||
*/
|
||||
#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_ */
|
||||
|
||||
83
sys/sys/dirhash.h
Normal file
83
sys/sys/dirhash.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $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_ */
|
||||
231
sys/sys/disklabel_rdb.h
Normal file
231
sys/sys/disklabel_rdb.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/* $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_ */
|
||||
49
sys/sys/dkstat.h
Normal file
49
sys/sys/dkstat.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* $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_ */
|
||||
103
sys/sys/domain.h
Normal file
103
sys/sys/domain.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* $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_ */
|
||||
130
sys/sys/drvctlio.h
Normal file
130
sys/sys/drvctlio.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/* $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_ */
|
||||
245
sys/sys/dtrace_bsd.h
Normal file
245
sys/sys/dtrace_bsd.h
Normal file
@@ -0,0 +1,245 @@
|
||||
/* $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 */
|
||||
206
sys/sys/dvdio.h
Normal file
206
sys/sys/dvdio.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/* $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_ */
|
||||
197
sys/sys/envsys.h
Normal file
197
sys/sys/envsys.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/* $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_ */
|
||||
140
sys/sys/evcnt.h
Normal file
140
sys/sys/evcnt.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/* $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_ */
|
||||
259
sys/sys/event.h
Normal file
259
sys/sys/event.h
Normal file
@@ -0,0 +1,259 @@
|
||||
/* $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_ */
|
||||
57
sys/sys/eventvar.h
Normal file
57
sys/sys/eventvar.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* $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_ */
|
||||
182
sys/sys/exec_aout.h
Normal file
182
sys/sys/exec_aout.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/* $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_ */
|
||||
156
sys/sys/exec_coff.h
Normal file
156
sys/sys/exec_coff.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/* $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_ */
|
||||
118
sys/sys/exec_ecoff.h
Normal file
118
sys/sys/exec_ecoff.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $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_ */
|
||||
49
sys/sys/exec_script.h
Normal file
49
sys/sys/exec_script.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* $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_ */
|
||||
115
sys/sys/extent.h
Normal file
115
sys/sys/extent.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $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_ */
|
||||
84
sys/sys/fdio.h
Normal file
84
sys/sys/fdio.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* $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_ */
|
||||
50
sys/sys/fileassoc.h
Normal file
50
sys/sys/fileassoc.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* $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_ */
|
||||
243
sys/sys/filedesc.h
Normal file
243
sys/sys/filedesc.h
Normal file
@@ -0,0 +1,243 @@
|
||||
/* $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_ */
|
||||
62
sys/sys/filio.h
Normal file
62
sys/sys/filio.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $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_ */
|
||||
118
sys/sys/flashio.h
Normal file
118
sys/sys/flashio.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $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
|
||||
|
||||
80
sys/sys/fstrans.h
Normal file
80
sys/sys/fstrans.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* $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_ */
|
||||
116
sys/sys/gpio.h
Normal file
116
sys/sys/gpio.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* $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_ */
|
||||
37
sys/sys/idle.h
Normal file
37
sys/sys/idle.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* $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_ */
|
||||
93
sys/sys/intr.h
Normal file
93
sys/sys/intr.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* $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_ */
|
||||
165
sys/sys/ioctl_compat.h
Normal file
165
sys/sys/ioctl_compat.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* $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_ */
|
||||
23
sys/sys/joystick.h
Normal file
23
sys/sys/joystick.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $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_ */
|
||||
494
sys/sys/kauth.h
Normal file
494
sys/sys/kauth.h
Normal file
@@ -0,0 +1,494 @@
|
||||
/* $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_ */
|
||||
59
sys/sys/kcore.h
Normal file
59
sys/sys/kcore.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* $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_ */
|
||||
74
sys/sys/kcpuset.h
Normal file
74
sys/sys/kcpuset.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* $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_ */
|
||||
53
sys/sys/kern_ctf.h
Normal file
53
sys/sys/kern_ctf.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* $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
|
||||
69
sys/sys/kernel.h
Normal file
69
sys/sys/kernel.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* $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_ */
|
||||
201
sys/sys/kernhist.h
Normal file
201
sys/sys/kernhist.h
Normal file
@@ -0,0 +1,201 @@
|
||||
/* $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_ */
|
||||
104
sys/sys/kgdb.h
Normal file
104
sys/sys/kgdb.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* $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_ */
|
||||
55
sys/sys/kmem.h
Normal file
55
sys/sys/kmem.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $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_ */
|
||||
54
sys/sys/kobj.h
Normal file
54
sys/sys/kobj.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $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_ */
|
||||
137
sys/sys/kobj_impl.h
Normal file
137
sys/sys/kobj_impl.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/* $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_ */
|
||||
68
sys/sys/kprintf.h
Normal file
68
sys/sys/kprintf.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* $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_ */
|
||||
62
sys/sys/ksem.h
Normal file
62
sys/sys/ksem.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $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_ */
|
||||
139
sys/sys/ksyms.h
Normal file
139
sys/sys/ksyms.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $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_ */
|
||||
60
sys/sys/kthread.h
Normal file
60
sys/sys/kthread.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* $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_ */
|
||||
414
sys/sys/ktrace.h
Normal file
414
sys/sys/ktrace.h
Normal file
@@ -0,0 +1,414 @@
|
||||
/* $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_ */
|
||||
100
sys/sys/lockdebug.h
Normal file
100
sys/sys/lockdebug.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $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__ */
|
||||
50
sys/sys/lockf.h
Normal file
50
sys/sys/lockf.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* $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_ */
|
||||
97
sys/sys/lwpctl.h
Normal file
97
sys/sys/lwpctl.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $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_ */
|
||||
92
sys/sys/malloc.h
Normal file
92
sys/sys/malloc.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* $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_ */
|
||||
64
sys/sys/mallocvar.h
Normal file
64
sys/sys/mallocvar.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* $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_ */
|
||||
929
sys/sys/mbuf.h
Normal file
929
sys/sys/mbuf.h
Normal file
@@ -0,0 +1,929 @@
|
||||
/* $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_ */
|
||||
779
sys/sys/midiio.h
Normal file
779
sys/sys/midiio.h
Normal file
@@ -0,0 +1,779 @@
|
||||
/* $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_ */
|
||||
203
sys/sys/module.h
Normal file
203
sys/sys/module.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/* $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_ */
|
||||
118
sys/sys/mqueue.h
Normal file
118
sys/sys/mqueue.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $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_ */
|
||||
220
sys/sys/msg.h
Normal file
220
sys/sys/msg.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/* $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_ */
|
||||
56
sys/sys/msgbuf.h
Normal file
56
sys/sys/msgbuf.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* $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_ */
|
||||
339
sys/sys/namei.h
Normal file
339
sys/sys/namei.h
Normal file
@@ -0,0 +1,339 @@
|
||||
/* $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_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user