The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sparc64/sparc64/sys_machdep.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2001 Jake Burkholder.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #include <sys/param.h>
   30 #include <sys/systm.h>
   31 #include <sys/lock.h>
   32 #include <sys/malloc.h>
   33 #include <sys/mutex.h>
   34 #include <sys/proc.h>
   35 #include <sys/sysproto.h>
   36 
   37 #include <machine/md_var.h>
   38 #include <machine/utrap.h>
   39 #include <machine/sysarch.h>
   40 
   41 static int sparc_sigtramp_install(struct thread *td, char *args);
   42 static int sparc_utrap_install(struct thread *td, char *args);
   43 
   44 #ifndef _SYS_SYSPROTO_H_
   45 struct sysarch_args {
   46         int     op;
   47         char    *parms;
   48 };
   49 #endif
   50 
   51 int
   52 sysarch(struct thread *td, struct sysarch_args *uap)
   53 {
   54         int error;
   55 
   56         mtx_lock(&Giant);
   57         switch (uap->op) {
   58         case SPARC_SIGTRAMP_INSTALL:
   59                 error = sparc_sigtramp_install(td, uap->parms);
   60                 break;
   61         case SPARC_UTRAP_INSTALL:
   62                 error = sparc_utrap_install(td, uap->parms);
   63                 break;
   64         default:
   65                 error = EINVAL;
   66                 break;
   67         }
   68         mtx_unlock(&Giant);
   69         return (error);
   70 }
   71 
   72 static int
   73 sparc_sigtramp_install(struct thread *td, char *args)
   74 {
   75         struct sparc_sigtramp_install_args sia;
   76         struct proc *p;
   77         int error;
   78 
   79         p = td->td_proc;
   80         if ((error = copyin(args, &sia, sizeof(sia))) != 0)
   81                 return (error);
   82         if (sia.sia_old != NULL) {
   83                 if (suword(sia.sia_old, (long)p->p_md.md_sigtramp) != 0)
   84                         return (EFAULT);
   85         }
   86         p->p_md.md_sigtramp = sia.sia_new;
   87         return (0);
   88 }
   89 
   90 static int
   91 sparc_utrap_install(struct thread *td, char *args)
   92 {
   93         struct sparc_utrap_install_args uia;
   94         struct sparc_utrap_args ua;
   95         struct md_utrap *ut;
   96         int error;
   97         int i;
   98 
   99         ut = td->td_proc->p_md.md_utrap;
  100         if ((error = copyin(args, &uia, sizeof(uia))) != 0)
  101                 return (error);
  102         if (uia.num < 0 || uia.num > UT_MAX ||
  103             (uia.handlers == NULL && uia.num > 0))
  104                 return (EINVAL);
  105         for (i = 0; i < uia.num; i++) {
  106                 if ((error = copyin(&uia.handlers[i], &ua, sizeof(ua))) != 0)
  107                         return (error);
  108                 if (ua.type != UTH_NOCHANGE &&
  109                     (ua.type < 0 || ua.type >= UT_MAX))
  110                         return (EINVAL);
  111                 if (ua.old_deferred != NULL) {
  112                         if ((error = suword(ua.old_deferred, 0)) != 0)
  113                                 return (error);
  114                 }
  115                 if (ua.old_precise != NULL) {
  116                         error = suword(ua.old_precise,
  117                             ut != NULL ? (long)ut->ut_precise[ua.type] : 0);
  118                         if (error != 0)
  119                                 return (error);
  120                 }
  121                 if (ua.type != UTH_NOCHANGE) {
  122                         if (ut == NULL) {
  123                                 ut = utrap_alloc();
  124                                 td->td_proc->p_md.md_utrap = ut;
  125                         }
  126                         ut->ut_precise[ua.type] = ua.new_precise;
  127                 }
  128         }
  129         return (0);
  130 }

Cache object: 6f25f38f6358c4291418de3dc7a12bce


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.