Home | History | Annotate | Line # | Download | only in kern
kern_stub.c revision 1.46
      1  1.46  pgoyette /*	$NetBSD: kern_stub.c,v 1.46 2019/01/27 02:08:43 pgoyette Exp $	*/
      2   1.1        ad 
      3   1.1        ad /*-
      4   1.8        ad  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
      5   1.1        ad  * All rights reserved.
      6   1.1        ad  *
      7   1.1        ad  * Redistribution and use in source and binary forms, with or without
      8   1.1        ad  * modification, are permitted provided that the following conditions
      9   1.1        ad  * are met:
     10   1.1        ad  * 1. Redistributions of source code must retain the above copyright
     11   1.1        ad  *    notice, this list of conditions and the following disclaimer.
     12   1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     14   1.1        ad  *    documentation and/or other materials provided with the distribution.
     15   1.1        ad  *
     16   1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17   1.1        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18   1.1        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19   1.1        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20   1.1        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21   1.1        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22   1.1        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23   1.1        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24   1.1        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25   1.1        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26   1.1        ad  * POSSIBILITY OF SUCH DAMAGE.
     27   1.1        ad  */
     28   1.1        ad 
     29   1.1        ad /*
     30   1.3        ad  * Copyright (c) 1982, 1986, 1991, 1993
     31   1.3        ad  *	The Regents of the University of California.  All rights reserved.
     32   1.3        ad  *
     33   1.3        ad  * Redistribution and use in source and binary forms, with or without
     34   1.3        ad  * modification, are permitted provided that the following conditions
     35   1.3        ad  * are met:
     36   1.3        ad  * 1. Redistributions of source code must retain the above copyright
     37   1.3        ad  *    notice, this list of conditions and the following disclaimer.
     38   1.3        ad  * 2. Redistributions in binary form must reproduce the above copyright
     39   1.3        ad  *    notice, this list of conditions and the following disclaimer in the
     40   1.3        ad  *    documentation and/or other materials provided with the distribution.
     41   1.3        ad  * 3. Neither the name of the University nor the names of its contributors
     42   1.3        ad  *    may be used to endorse or promote products derived from this software
     43   1.3        ad  *    without specific prior written permission.
     44   1.3        ad  *
     45   1.3        ad  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     46   1.3        ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     47   1.3        ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     48   1.3        ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     49   1.3        ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     50   1.3        ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     51   1.3        ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     52   1.3        ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     53   1.3        ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     54   1.3        ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     55   1.3        ad  * SUCH DAMAGE.
     56   1.3        ad  *
     57   1.3        ad  *	@(#)subr_xxx.c	8.3 (Berkeley) 3/29/95
     58   1.3        ad  */
     59   1.3        ad 
     60   1.3        ad /*
     61   1.1        ad  * Stubs for system calls and facilities not included in the system.
     62   1.1        ad  */
     63   1.1        ad 
     64   1.1        ad #include <sys/cdefs.h>
     65  1.46  pgoyette __KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.46 2019/01/27 02:08:43 pgoyette Exp $");
     66   1.1        ad 
     67  1.41     pooka #ifdef _KERNEL_OPT
     68   1.3        ad #include "opt_ktrace.h"
     69  1.44  christos #include "opt_sysv.h"
     70  1.45  christos #include "opt_modular.h"
     71  1.41     pooka #endif
     72   1.1        ad 
     73   1.1        ad #include <sys/param.h>
     74   1.1        ad #include <sys/kernel.h>
     75   1.1        ad #include <sys/proc.h>
     76  1.16  christos #include <sys/fstypes.h>
     77   1.1        ad #include <sys/signalvar.h>
     78  1.12        ad #include <sys/syscall.h>
     79   1.3        ad #include <sys/ktrace.h>
     80   1.8        ad #include <sys/intr.h>
     81   1.8        ad #include <sys/cpu.h>
     82  1.12        ad #include <sys/module.h>
     83  1.26    dyoung #include <sys/bus.h>
     84  1.32    dyoung #include <sys/userconf.h>
     85  1.26    dyoung 
     86  1.26    dyoung bool default_bus_space_is_equal(bus_space_tag_t, bus_space_tag_t);
     87  1.35    dyoung bool default_bus_space_handle_is_equal(bus_space_tag_t, bus_space_handle_t,
     88  1.35    dyoung     bus_space_handle_t);
     89   1.1        ad 
     90   1.1        ad /*
     91  1.44  christos  * SYSV Semaphores, Shared Memory, Message Queues
     92  1.44  christos  */
     93  1.45  christos #ifndef MODULAR
     94  1.44  christos #ifndef SYSVMSG
     95  1.44  christos __strong_alias(msgctl1,enosys);
     96  1.44  christos #endif
     97  1.44  christos #ifndef SYSVSHM
     98  1.44  christos __strong_alias(shmctl1,enosys);
     99  1.44  christos #endif
    100  1.44  christos #ifndef SYSVSEM
    101  1.46  pgoyette  __strong_alias(semctl1,enosys);
    102  1.46  pgoyette #endif
    103  1.44  christos #endif
    104  1.45  christos #endif
    105  1.44  christos 
    106  1.44  christos /*
    107   1.3        ad  * ktrace stubs.  ktruser() goes to enosys as we want to fail the syscall,
    108   1.3        ad  * but not kill the process: utrace() is a debugging feature.
    109   1.3        ad  */
    110   1.3        ad #ifndef KTRACE
    111  1.38     pooka __strong_alias(ktr_csw,nullop);		/* Probes */
    112  1.38     pooka __strong_alias(ktr_emul,nullop);
    113  1.38     pooka __strong_alias(ktr_geniov,nullop);
    114  1.38     pooka __strong_alias(ktr_genio,nullop);
    115  1.38     pooka __strong_alias(ktr_mibio,nullop);
    116  1.38     pooka __strong_alias(ktr_namei,nullop);
    117  1.38     pooka __strong_alias(ktr_namei2,nullop);
    118  1.38     pooka __strong_alias(ktr_psig,nullop);
    119  1.38     pooka __strong_alias(ktr_syscall,nullop);
    120  1.38     pooka __strong_alias(ktr_sysret,nullop);
    121  1.38     pooka __strong_alias(ktr_kuser,nullop);
    122  1.38     pooka __strong_alias(ktr_mib,nullop);
    123  1.38     pooka __strong_alias(ktr_execarg,nullop);
    124  1.38     pooka __strong_alias(ktr_execenv,nullop);
    125  1.38     pooka __strong_alias(ktr_execfd,nullop);
    126  1.38     pooka 
    127  1.38     pooka __strong_alias(sys_fktrace,sys_nosys);	/* Syscalls */
    128  1.38     pooka __strong_alias(sys_ktrace,sys_nosys);
    129  1.38     pooka __strong_alias(sys_utrace,sys_nosys);
    130   1.3        ad 
    131   1.3        ad int	ktrace_on;			/* Misc */
    132  1.38     pooka __strong_alias(ktruser,enosys);
    133  1.38     pooka __strong_alias(ktr_point,nullop);
    134   1.3        ad #endif	/* KTRACE */
    135   1.1        ad 
    136  1.30    dyoung __weak_alias(device_register, voidop);
    137  1.30    dyoung __weak_alias(device_register_post_config, voidop);
    138  1.21    dyoung __weak_alias(spldebug_start, voidop);
    139  1.21    dyoung __weak_alias(spldebug_stop, voidop);
    140  1.20      elad __weak_alias(machdep_init,nullop);
    141  1.28    dyoung __weak_alias(pci_chipset_tag_create, eopnotsupp);
    142  1.28    dyoung __weak_alias(pci_chipset_tag_destroy, voidop);
    143  1.34    dyoung __weak_alias(bus_space_reserve, eopnotsupp);
    144  1.34    dyoung __weak_alias(bus_space_reserve_subregion, eopnotsupp);
    145  1.34    dyoung __weak_alias(bus_space_release, voidop);
    146  1.34    dyoung __weak_alias(bus_space_reservation_map, eopnotsupp);
    147  1.34    dyoung __weak_alias(bus_space_reservation_unmap, voidop);
    148  1.36    dyoung __weak_alias(bus_dma_tag_create, eopnotsupp);
    149  1.36    dyoung __weak_alias(bus_dma_tag_destroy, voidop);
    150  1.26    dyoung __weak_alias(bus_space_tag_create, eopnotsupp);
    151  1.26    dyoung __weak_alias(bus_space_tag_destroy, voidop);
    152  1.35    dyoung __strict_weak_alias(bus_space_is_equal, default_bus_space_is_equal);
    153  1.35    dyoung __strict_weak_alias(bus_space_handle_is_equal,
    154  1.35    dyoung     default_bus_space_handle_is_equal);
    155  1.32    dyoung __weak_alias(userconf_bootinfo, voidop);
    156  1.32    dyoung __weak_alias(userconf_init, voidop);
    157  1.32    dyoung __weak_alias(userconf_prompt, voidop);
    158  1.20      elad 
    159  1.27     pooka __weak_alias(kobj_renamespace, nullop);
    160  1.27     pooka 
    161  1.42  knakahar __weak_alias(interrupt_get_count, nullop);
    162  1.42  knakahar __weak_alias(interrupt_get_assigned, voidop);
    163  1.42  knakahar __weak_alias(interrupt_get_available, voidop);
    164  1.42  knakahar __weak_alias(interrupt_get_devname, voidop);
    165  1.42  knakahar __weak_alias(interrupt_construct_intrids, nullret);
    166  1.42  knakahar __weak_alias(interrupt_destruct_intrids, voidop);
    167  1.40  knakahar __weak_alias(interrupt_distribute, eopnotsupp);
    168  1.40  knakahar __weak_alias(interrupt_distribute_handler, eopnotsupp);
    169  1.39  knakahar 
    170   1.1        ad /*
    171  1.37     rmind  * Scheduler activations system calls.  These need to remain until libc's
    172  1.37     rmind  * major version is bumped.
    173   1.1        ad  */
    174   1.2     itohy __strong_alias(sys_sa_register,sys_nosys);
    175   1.2     itohy __strong_alias(sys_sa_stacks,sys_nosys);
    176   1.2     itohy __strong_alias(sys_sa_enable,sys_nosys);
    177   1.2     itohy __strong_alias(sys_sa_setconcurrency,sys_nosys);
    178   1.2     itohy __strong_alias(sys_sa_yield,sys_nosys);
    179   1.2     itohy __strong_alias(sys_sa_preempt,sys_nosys);
    180   1.2     itohy __strong_alias(sys_sa_unblockyield,sys_nosys);
    181  1.15        ad 
    182  1.15        ad /*
    183  1.15        ad  * Stubs for compat_netbsd32.
    184  1.15        ad  */
    185  1.15        ad __strong_alias(dosa_register,sys_nosys);
    186  1.15        ad __strong_alias(sa_stacks1,sys_nosys);
    187   1.1        ad 
    188   1.9        ad /*
    189   1.9        ad  * Stubs for architectures that do not support kernel preemption.
    190   1.9        ad  */
    191   1.8        ad #ifndef __HAVE_PREEMPTION
    192   1.8        ad bool
    193   1.8        ad cpu_kpreempt_enter(uintptr_t where, int s)
    194   1.8        ad {
    195   1.8        ad 
    196   1.8        ad 	return false;
    197   1.8        ad }
    198   1.8        ad 
    199   1.8        ad void
    200   1.8        ad cpu_kpreempt_exit(uintptr_t where)
    201   1.8        ad {
    202   1.8        ad 
    203   1.8        ad }
    204   1.8        ad 
    205   1.8        ad bool
    206   1.8        ad cpu_kpreempt_disabled(void)
    207   1.8        ad {
    208   1.8        ad 
    209   1.8        ad 	return true;
    210   1.8        ad }
    211   1.9        ad #else
    212   1.9        ad # ifndef MULTIPROCESSOR
    213   1.9        ad #   error __HAVE_PREEMPTION requires MULTIPROCESSOR
    214   1.9        ad # endif
    215   1.8        ad #endif	/* !__HAVE_PREEMPTION */
    216   1.8        ad 
    217   1.1        ad int
    218   1.5       dsl sys_nosys(struct lwp *l, const void *v, register_t *retval)
    219   1.1        ad {
    220   1.1        ad 
    221   1.6        ad 	mutex_enter(proc_lock);
    222   1.1        ad 	psignal(l->l_proc, SIGSYS);
    223   1.6        ad 	mutex_exit(proc_lock);
    224   1.1        ad 	return ENOSYS;
    225   1.1        ad }
    226   1.3        ad 
    227   1.3        ad /*
    228   1.3        ad  * Unsupported device function (e.g. writing to read-only device).
    229   1.3        ad  */
    230   1.3        ad int
    231   1.3        ad enodev(void)
    232   1.3        ad {
    233   1.3        ad 
    234   1.3        ad 	return (ENODEV);
    235   1.3        ad }
    236   1.3        ad 
    237   1.3        ad /*
    238   1.3        ad  * Unconfigured device function; driver not configured.
    239   1.3        ad  */
    240   1.3        ad int
    241   1.3        ad enxio(void)
    242   1.3        ad {
    243   1.3        ad 
    244   1.3        ad 	return (ENXIO);
    245   1.3        ad }
    246   1.3        ad 
    247   1.3        ad /*
    248   1.3        ad  * Unsupported ioctl function.
    249   1.3        ad  */
    250   1.3        ad int
    251   1.3        ad enoioctl(void)
    252   1.3        ad {
    253   1.3        ad 
    254   1.3        ad 	return (ENOTTY);
    255   1.3        ad }
    256   1.3        ad 
    257   1.3        ad /*
    258   1.3        ad  * Unsupported system function.
    259   1.3        ad  * This is used for an otherwise-reasonable operation
    260   1.3        ad  * that is not supported by the current system binary.
    261   1.3        ad  */
    262   1.3        ad int
    263   1.3        ad enosys(void)
    264   1.3        ad {
    265   1.3        ad 
    266   1.3        ad 	return (ENOSYS);
    267   1.3        ad }
    268   1.3        ad 
    269   1.3        ad /*
    270   1.3        ad  * Return error for operation not supported
    271   1.3        ad  * on a specific object or file type.
    272   1.3        ad  */
    273   1.3        ad int
    274   1.3        ad eopnotsupp(void)
    275   1.3        ad {
    276   1.3        ad 
    277   1.3        ad 	return (EOPNOTSUPP);
    278   1.3        ad }
    279   1.3        ad 
    280   1.3        ad /*
    281  1.21    dyoung  * Generic null operation, void return value.
    282  1.21    dyoung  */
    283  1.21    dyoung void
    284  1.21    dyoung voidop(void)
    285  1.21    dyoung {
    286  1.21    dyoung }
    287  1.21    dyoung 
    288  1.21    dyoung /*
    289   1.3        ad  * Generic null operation, always returns success.
    290   1.3        ad  */
    291   1.3        ad int
    292   1.3        ad nullop(void *v)
    293   1.3        ad {
    294   1.3        ad 
    295   1.3        ad 	return (0);
    296   1.3        ad }
    297  1.26    dyoung 
    298  1.42  knakahar /*
    299  1.42  knakahar  * Generic null operation, always returns null.
    300  1.42  knakahar  */
    301  1.42  knakahar void *
    302  1.42  knakahar nullret(void)
    303  1.42  knakahar {
    304  1.42  knakahar 
    305  1.42  knakahar 	return (NULL);
    306  1.42  knakahar }
    307  1.42  knakahar 
    308  1.26    dyoung bool
    309  1.35    dyoung default_bus_space_handle_is_equal(bus_space_tag_t t,
    310  1.35    dyoung     bus_space_handle_t h1, bus_space_handle_t h2)
    311  1.34    dyoung {
    312  1.34    dyoung 
    313  1.34    dyoung 	return memcmp(&h1, &h2, sizeof(h1)) == 0;
    314  1.34    dyoung }
    315  1.34    dyoung 
    316  1.34    dyoung bool
    317  1.26    dyoung default_bus_space_is_equal(bus_space_tag_t t1, bus_space_tag_t t2)
    318  1.26    dyoung {
    319  1.29    simonb 
    320  1.26    dyoung 	return memcmp(&t1, &t2, sizeof(t1)) == 0;
    321  1.26    dyoung }
    322