1 /* $NetBSD: kern_stub.c,v 1.29 2010/06/13 13:43:02 simonb 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.29 2010/06/13 13:43:02 simonb Exp $"); 66 67 #include "opt_ptrace.h" 68 #include "opt_ktrace.h" 69 #include "opt_sa.h" 70 71 #include <sys/param.h> 72 #include <sys/kernel.h> 73 #include <sys/proc.h> 74 #include <sys/fstypes.h> 75 #include <sys/signalvar.h> 76 #include <sys/syscall.h> 77 #include <sys/ktrace.h> 78 #include <sys/intr.h> 79 #include <sys/cpu.h> 80 #include <sys/module.h> 81 #include <sys/bus.h> 82 83 bool default_bus_space_is_equal(bus_space_tag_t, bus_space_tag_t); 84 85 /* 86 * Nonexistent system call-- signal process (may want to handle it). Flag 87 * error in case process won't see signal immediately (blocked or ignored). 88 */ 89 #ifndef PTRACE 90 __weak_alias(sys_ptrace,sys_nosys); 91 #endif /* PTRACE */ 92 93 /* 94 * ktrace stubs. ktruser() goes to enosys as we want to fail the syscall, 95 * but not kill the process: utrace() is a debugging feature. 96 */ 97 #ifndef KTRACE 98 __weak_alias(ktr_csw,nullop); /* Probes */ 99 __weak_alias(ktr_emul,nullop); 100 __weak_alias(ktr_geniov,nullop); 101 __weak_alias(ktr_genio,nullop); 102 __weak_alias(ktr_mibio,nullop); 103 __weak_alias(ktr_namei,nullop); 104 __weak_alias(ktr_namei2,nullop); 105 __weak_alias(ktr_psig,nullop); 106 __weak_alias(ktr_saupcall,nullop); 107 __weak_alias(ktr_syscall,nullop); 108 __weak_alias(ktr_sysret,nullop); 109 __weak_alias(ktr_kuser,nullop); 110 __weak_alias(ktr_mmsg,nullop); 111 __weak_alias(ktr_mib,nullop); 112 __weak_alias(ktr_mool,nullop); 113 __weak_alias(ktr_execarg,nullop); 114 __weak_alias(ktr_execenv,nullop); 115 116 __weak_alias(sys_fktrace,sys_nosys); /* Syscalls */ 117 __weak_alias(sys_ktrace,sys_nosys); 118 __weak_alias(sys_utrace,sys_nosys); 119 120 int ktrace_on; /* Misc */ 121 __weak_alias(ktruser,enosys); 122 __weak_alias(ktr_point,nullop); 123 #endif /* KTRACE */ 124 125 __weak_alias(spldebug_start, voidop); 126 __weak_alias(spldebug_stop, voidop); 127 __weak_alias(machdep_init,nullop); 128 __weak_alias(pci_chipset_tag_create, eopnotsupp); 129 __weak_alias(pci_chipset_tag_destroy, voidop); 130 __weak_alias(bus_space_tag_create, eopnotsupp); 131 __weak_alias(bus_space_tag_destroy, voidop); 132 __weak_alias(bus_space_is_equal, default_bus_space_is_equal); 133 134 __weak_alias(kobj_renamespace, nullop); 135 136 #if !defined(KERN_SA) 137 /* 138 * Scheduler activations system calls. These need to remain, even when 139 * KERN_SA isn't defined, until libc's major version is bumped. 140 */ 141 __strong_alias(sys_sa_register,sys_nosys); 142 __strong_alias(sys_sa_stacks,sys_nosys); 143 __strong_alias(sys_sa_enable,sys_nosys); 144 __strong_alias(sys_sa_setconcurrency,sys_nosys); 145 __strong_alias(sys_sa_yield,sys_nosys); 146 __strong_alias(sys_sa_preempt,sys_nosys); 147 __strong_alias(sys_sa_unblockyield,sys_nosys); 148 149 /* 150 * Stubs for compat_netbsd32. 151 */ 152 __strong_alias(dosa_register,sys_nosys); 153 __strong_alias(sa_stacks1,sys_nosys); 154 #endif 155 156 /* 157 * Stubs for architectures that do not support kernel preemption. 158 */ 159 #ifndef __HAVE_PREEMPTION 160 bool 161 cpu_kpreempt_enter(uintptr_t where, int s) 162 { 163 164 return false; 165 } 166 167 void 168 cpu_kpreempt_exit(uintptr_t where) 169 { 170 171 } 172 173 bool 174 cpu_kpreempt_disabled(void) 175 { 176 177 return true; 178 } 179 #else 180 # ifndef MULTIPROCESSOR 181 # error __HAVE_PREEMPTION requires MULTIPROCESSOR 182 # endif 183 #endif /* !__HAVE_PREEMPTION */ 184 185 int 186 sys_nosys(struct lwp *l, const void *v, register_t *retval) 187 { 188 189 mutex_enter(proc_lock); 190 psignal(l->l_proc, SIGSYS); 191 mutex_exit(proc_lock); 192 return ENOSYS; 193 } 194 195 /* 196 * Unsupported device function (e.g. writing to read-only device). 197 */ 198 int 199 enodev(void) 200 { 201 202 return (ENODEV); 203 } 204 205 /* 206 * Unconfigured device function; driver not configured. 207 */ 208 int 209 enxio(void) 210 { 211 212 return (ENXIO); 213 } 214 215 /* 216 * Unsupported ioctl function. 217 */ 218 int 219 enoioctl(void) 220 { 221 222 return (ENOTTY); 223 } 224 225 /* 226 * Unsupported system function. 227 * This is used for an otherwise-reasonable operation 228 * that is not supported by the current system binary. 229 */ 230 int 231 enosys(void) 232 { 233 234 return (ENOSYS); 235 } 236 237 /* 238 * Return error for operation not supported 239 * on a specific object or file type. 240 */ 241 int 242 eopnotsupp(void) 243 { 244 245 return (EOPNOTSUPP); 246 } 247 248 /* 249 * Generic null operation, void return value. 250 */ 251 void 252 voidop(void) 253 { 254 } 255 256 /* 257 * Generic null operation, always returns success. 258 */ 259 /*ARGSUSED*/ 260 int 261 nullop(void *v) 262 { 263 264 return (0); 265 } 266 267 bool 268 default_bus_space_is_equal(bus_space_tag_t t1, bus_space_tag_t t2) 269 { 270 271 return memcmp(&t1, &t2, sizeof(t1)) == 0; 272 } 273