2 * Copyright (c) 2001 Jake Burkholder.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
29 #include <sys/param.h>
30 #include <sys/systm.h>
32 #include <sys/malloc.h>
33 #include <sys/mutex.h>
35 #include <sys/sysproto.h>
37 #include <machine/md_var.h>
38 #include <machine/utrap.h>
39 #include <machine/sysarch.h>
41 static int sparc_sigtramp_install(struct thread *td, char *args);
42 static int sparc_utrap_install(struct thread *td, char *args);
44 #ifndef _SYS_SYSPROTO_H_
52 sysarch(struct thread *td, struct sysarch_args *uap)
58 case SPARC_SIGTRAMP_INSTALL:
59 error = sparc_sigtramp_install(td, uap->parms);
61 case SPARC_UTRAP_INSTALL:
62 error = sparc_utrap_install(td, uap->parms);
73 sparc_sigtramp_install(struct thread *td, char *args)
75 struct sparc_sigtramp_install_args sia;
80 if ((error = copyin(args, &sia, sizeof(sia))) != 0)
82 if (sia.sia_old != NULL) {
83 if (suword(sia.sia_old, (long)p->p_md.md_sigtramp) != 0)
86 p->p_md.md_sigtramp = sia.sia_new;
91 sparc_utrap_install(struct thread *td, char *args)
93 struct sparc_utrap_install_args uia;
94 struct sparc_utrap_args ua;
99 ut = td->td_proc->p_md.md_utrap;
100 if ((error = copyin(args, &uia, sizeof(uia))) != 0)
102 if (uia.num < 0 || uia.num > UT_MAX ||
103 (uia.handlers == NULL && uia.num > 0))
105 for (i = 0; i < uia.num; i++) {
106 if ((error = copyin(&uia.handlers[i], &ua, sizeof(ua))) != 0)
108 if (ua.type != UTH_NOCHANGE &&
109 (ua.type < 0 || ua.type >= UT_MAX))
111 if (ua.old_deferred != NULL) {
112 if ((error = suword(ua.old_deferred, 0)) != 0)
115 if (ua.old_precise != NULL) {
116 error = suword(ua.old_precise,
117 ut != NULL ? (long)ut->ut_precise[ua.type] : 0);
121 if (ua.type != UTH_NOCHANGE) {
124 td->td_proc->p_md.md_utrap = ut;
126 ut->ut_precise[ua.type] = ua.new_precise;