Home | History | Annotate | Line # | Download | only in kern
kern_stub.c revision 1.8
      1 /*	$NetBSD: kern_stub.c,v 1.8 2008/04/28 21:17:16 ad Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 /*
     30  * Copyright (c) 1982, 1986, 1991, 1993
     31  *	The Regents of the University of California.  All rights reserved.
     32  *
     33  * Redistribution and use in source and binary forms, with or without
     34  * modification, are permitted provided that the following conditions
     35  * are met:
     36  * 1. Redistributions of source code must retain the above copyright
     37  *    notice, this list of conditions and the following disclaimer.
     38  * 2. Redistributions in binary form must reproduce the above copyright
     39  *    notice, this list of conditions and the following disclaimer in the
     40  *    documentation and/or other materials provided with the distribution.
     41  * 3. Neither the name of the University nor the names of its contributors
     42  *    may be used to endorse or promote products derived from this software
     43  *    without specific prior written permission.
     44  *
     45  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     46  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     47  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     48  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     49  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     50  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     51  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     52  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     53  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     54  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     55  * SUCH DAMAGE.
     56  *
     57  *	@(#)subr_xxx.c	8.3 (Berkeley) 3/29/95
     58  */
     59 
     60 /*
     61  * Stubs for system calls and facilities not included in the system.
     62  */
     63 
     64 #include <sys/cdefs.h>
     65 __KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.8 2008/04/28 21:17:16 ad Exp $");
     66 
     67 #include "opt_ptrace.h"
     68 #include "opt_ktrace.h"
     69 
     70 #include <sys/param.h>
     71 #include <sys/kernel.h>
     72 #include <sys/proc.h>
     73 #include <sys/signalvar.h>
     74 #include <sys/syscallargs.h>
     75 #include <sys/ktrace.h>
     76 #include <sys/intr.h>
     77 #include <sys/cpu.h>
     78 
     79 /*
     80  * Nonexistent system call-- signal process (may want to handle it).  Flag
     81  * error in case process won't see signal immediately (blocked or ignored).
     82  */
     83 #ifndef PTRACE
     84 __weak_alias(sys_ptrace,sys_nosys);
     85 #endif	/* PTRACE */
     86 
     87 /*
     88  * ktrace stubs.  ktruser() goes to enosys as we want to fail the syscall,
     89  * but not kill the process: utrace() is a debugging feature.
     90  */
     91 #ifndef KTRACE
     92 __weak_alias(ktr_csw,nullop);		/* Probes */
     93 __weak_alias(ktr_emul,nullop);
     94 __weak_alias(ktr_geniov,nullop);
     95 __weak_alias(ktr_genio,nullop);
     96 __weak_alias(ktr_mibio,nullop);
     97 __weak_alias(ktr_namei,nullop);
     98 __weak_alias(ktr_namei2,nullop);
     99 __weak_alias(ktr_psig,nullop);
    100 __weak_alias(ktr_syscall,nullop);
    101 __weak_alias(ktr_sysret,nullop);
    102 __weak_alias(ktr_kuser,nullop);
    103 __weak_alias(ktr_mmsg,nullop);
    104 __weak_alias(ktr_mib,nullop);
    105 __weak_alias(ktr_mool,nullop);
    106 __weak_alias(ktr_execarg,nullop);
    107 __weak_alias(ktr_execenv,nullop);
    108 
    109 __weak_alias(sys_fktrace,sys_nosys);	/* Syscalls */
    110 __weak_alias(sys_ktrace,sys_nosys);
    111 __weak_alias(sys_utrace,sys_nosys);
    112 
    113 int	ktrace_on;			/* Misc */
    114 __weak_alias(ktruser,enosys);
    115 __weak_alias(ktr_point,nullop);
    116 #endif	/* KTRACE */
    117 
    118 /*
    119  * Scheduler activations system calls.  These need to remain until libc's
    120  * major version is bumped.
    121  */
    122 __strong_alias(sys_sa_register,sys_nosys);
    123 __strong_alias(sys_sa_stacks,sys_nosys);
    124 __strong_alias(sys_sa_enable,sys_nosys);
    125 __strong_alias(sys_sa_setconcurrency,sys_nosys);
    126 __strong_alias(sys_sa_yield,sys_nosys);
    127 __strong_alias(sys_sa_preempt,sys_nosys);
    128 __strong_alias(sys_sa_unblockyield,sys_nosys);
    129 
    130 #ifndef __HAVE_PREEMPTION
    131 bool
    132 cpu_kpreempt_enter(uintptr_t where, int s)
    133 {
    134 
    135 	return false;
    136 }
    137 
    138 void
    139 cpu_kpreempt_exit(uintptr_t where)
    140 {
    141 
    142 }
    143 
    144 bool
    145 cpu_kpreempt_disabled(void)
    146 {
    147 
    148 	return true;
    149 }
    150 #endif	/* !__HAVE_PREEMPTION */
    151 
    152 /* ARGSUSED */
    153 int
    154 sys_nosys(struct lwp *l, const void *v, register_t *retval)
    155 {
    156 
    157 	mutex_enter(proc_lock);
    158 	psignal(l->l_proc, SIGSYS);
    159 	mutex_exit(proc_lock);
    160 	return ENOSYS;
    161 }
    162 
    163 /*
    164  * Unsupported device function (e.g. writing to read-only device).
    165  */
    166 int
    167 enodev(void)
    168 {
    169 
    170 	return (ENODEV);
    171 }
    172 
    173 /*
    174  * Unconfigured device function; driver not configured.
    175  */
    176 int
    177 enxio(void)
    178 {
    179 
    180 	return (ENXIO);
    181 }
    182 
    183 /*
    184  * Unsupported ioctl function.
    185  */
    186 int
    187 enoioctl(void)
    188 {
    189 
    190 	return (ENOTTY);
    191 }
    192 
    193 /*
    194  * Unsupported system function.
    195  * This is used for an otherwise-reasonable operation
    196  * that is not supported by the current system binary.
    197  */
    198 int
    199 enosys(void)
    200 {
    201 
    202 	return (ENOSYS);
    203 }
    204 
    205 /*
    206  * Return error for operation not supported
    207  * on a specific object or file type.
    208  */
    209 int
    210 eopnotsupp(void)
    211 {
    212 
    213 	return (EOPNOTSUPP);
    214 }
    215 
    216 /*
    217  * Generic null operation, always returns success.
    218  */
    219 /*ARGSUSED*/
    220 int
    221 nullop(void *v)
    222 {
    223 
    224 	return (0);
    225 }
    226