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: releng/5.2/sys/sparc64/sparc64/sys_machdep.c 119291 2003-08-22 07:39:05Z imp $
   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/utrap.h>
   38 #include <machine/sysarch.h>
   39 
   40 static int sparc_sigtramp_install(struct thread *td, char *args);
   41 static int sparc_utrap_install(struct thread *td, char *args);
   42 
   43 #ifndef _SYS_SYSPROTO_H_
   44 struct sysarch_args {
   45         int     op;
   46         char    *parms;
   47 };
   48 #endif
   49 
   50 int
   51 sysarch(struct thread *td, struct sysarch_args *uap)
   52 {
   53         int error;
   54 
   55         mtx_lock(&Giant);
   56         switch (uap->op) {
   57         case SPARC_SIGTRAMP_INSTALL:
   58                 error = sparc_sigtramp_install(td, uap->parms);
   59                 break;
   60         case SPARC_UTRAP_INSTALL:
   61                 error = sparc_utrap_install(td, uap->parms);
   62                 break;
   63         default:
   64                 error = EINVAL;
   65                 break;
   66         }
   67         mtx_unlock(&Giant);
   68         return (error);
   69 }
   70 
   71 static int
   72 sparc_sigtramp_install(struct thread *td, char *args)
   73 {
   74         struct sparc_sigtramp_install_args sia;
   75         struct proc *p;
   76         int error;
   77 
   78         p = td->td_proc;
   79         if ((error = copyin(args, &sia, sizeof(sia))) != 0)
   80                 return (error);
   81         if (sia.sia_old != NULL) {
   82                 if (suword(sia.sia_old, (long)p->p_md.md_sigtramp) != 0)
   83                         return (EFAULT);
   84         }
   85         p->p_md.md_sigtramp = sia.sia_new;
   86         return (0);
   87 }
   88 
   89 static int
   90 sparc_utrap_install(struct thread *td, char *args)
   91 {
   92         struct sparc_utrap_install_args uia;
   93         struct sparc_utrap_args ua;
   94         struct md_utrap *ut;
   95         int error;
   96         int i;
   97 
   98         ut = td->td_proc->p_md.md_utrap;
   99         if ((error = copyin(args, &uia, sizeof(uia))) != 0)
  100                 return (error);
  101         if (uia.num < 0 || uia.num > UT_MAX ||
  102             (uia.handlers == NULL && uia.num > 0))
  103                 return (EINVAL);
  104         for (i = 0; i < uia.num; i++) {
  105                 if ((error = copyin(&uia.handlers[i], &ua, sizeof(ua))) != 0)
  106                         return (error);
  107                 if (ua.type != UTH_NOCHANGE &&
  108                     (ua.type < 0 || ua.type >= UT_MAX))
  109                         return (EINVAL);
  110                 if (ua.old_deferred != NULL) {
  111                         if ((error = suword(ua.old_deferred, 0)) != 0)
  112                                 return (error);
  113                 }
  114                 if (ua.old_precise != NULL) {
  115                         error = suword(ua.old_precise,
  116                             ut != NULL ? (long)ut->ut_precise[ua.type] : 0);
  117                         if (error != 0)
  118                                 return (error);
  119                 }
  120                 if (ua.type != UTH_NOCHANGE) {
  121                         if (ut == NULL) {
  122                                 ut = malloc(sizeof *ut, M_SUBPROC,
  123                                     M_WAITOK | M_ZERO);
  124                                 ut->ut_refcnt = 1;
  125                                 td->td_proc->p_md.md_utrap = ut;
  126                         }
  127                         ut->ut_precise[ua.type] = ua.new_precise;
  128                 }
  129         }
  130         return (0);
  131 }

Cache object: 444de5ab0fe03e50205f0b8a74e13928


[ 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.