[BACK]Return to sys_syscall.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Annotation of src/sys/kern/sys_syscall.c, Revision 1.5

1.5     ! dsl         1: /*     $NetBSD: sys_syscall.c,v 1.4 2007/12/22 11:38:55 dsl Exp $      */
1.1       dsl         2:
                      3: /*-
                      4:  * Copyright (c) 2006 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by David Laight.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. Neither the name of The NetBSD Foundation nor the names of its
                     19:  *    contributors may be used to endorse or promote products derived
                     20:  *    from this software without specific prior written permission.
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     23:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     24:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     25:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     26:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     27:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     28:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     29:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     30:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     31:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     32:  * POSSIBILITY OF SUCH DAMAGE.
                     33:  */
                     34:
                     35: #include <sys/cdefs.h>
1.5     ! dsl        36: __KERNEL_RCSID(0, "$NetBSD: sys_syscall.c,v 1.4 2007/12/22 11:38:55 dsl Exp $");
1.1       dsl        37:
                     38: #include <sys/syscall_stats.h>
                     39:
                     40: /*
                     41:  * MI indirect system call support.
                     42:  * Included from sys_indirect.c and compat/netbsd32/netbsd32_indirect.c
                     43:  *
                     44:  * SYS_SYSCALL is set to the required function name.
                     45:  */
                     46:
                     47: #define CONCAT(a,b) __CONCAT(a,b)
                     48:
                     49: int
1.4       dsl        50: SYS_SYSCALL(struct lwp *l, const struct CONCAT(SYS_SYSCALL, _args) *uap,
                     51:     register_t *rval)
1.1       dsl        52: {
1.3       dsl        53:        /* {
1.1       dsl        54:                syscallarg(int) code;
                     55:                syscallarg(register_t) args[SYS_MAXSYSARGS];
1.3       dsl        56:        } */
1.1       dsl        57:        const struct sysent *callp;
                     58:        struct proc *p = l->l_proc;
                     59:        int code;
                     60:        int error;
                     61: #ifdef NETBSD32_SYSCALL
                     62:        register_t args64[SYS_MAXSYSARGS];
                     63:        int i, narg;
                     64:        #define TRACE_ARGS args64
                     65: #else
1.5     ! dsl        66:        #define TRACE_ARGS &SCARG(uap, args[0])
1.1       dsl        67: #endif
                     68:
                     69:        callp = p->p_emul->e_sysent;
                     70:
                     71:        code = SCARG(uap, code) & (SYS_NSYSENT - 1);
                     72:        SYSCALL_COUNT(syscall_counts, code);
                     73:        callp += code;
                     74:
                     75:        if (__predict_false(callp->sy_flags & SYCALL_INDIRECT))
                     76:                return ENOSYS;
                     77:
                     78:        if (__predict_true(!p->p_trace_enabled))
                     79:                return callp->sy_call(l, &uap->args, rval);
                     80:
                     81: #ifdef NETBSD32_SYSCALL
                     82:        narg = callp->sy_argsize >> 2;
                     83:        for (i = 0; i < narg; i++)
                     84:                args64[i] = SCARG(uap, args[i]);
                     85:        /* XXX systrace will not modify the correct arguments! */
                     86: #endif
                     87:
                     88:        error = trace_enter(l, code, code, NULL, TRACE_ARGS);
                     89:        if (__predict_false(error != 0))
                     90:                return error;
                     91:        error = callp->sy_call(l, &uap->args, rval);
                     92:        trace_exit(l, code, TRACE_ARGS, rval, error);
                     93:        return error;
                     94:
                     95:        #undef TRACE_ARGS
                     96: }

CVSweb <webmaster@jp.NetBSD.org>