1195128Sgonzo/*-
2195128Sgonzo * Copyright (c) 1990 The Regents of the University of California.
3195128Sgonzo * All rights reserved.
4195128Sgonzo *
5195128Sgonzo * Redistribution and use in source and binary forms, with or without
6195128Sgonzo * modification, are permitted provided that the following conditions
7195128Sgonzo * are met:
8195128Sgonzo * 1. Redistributions of source code must retain the above copyright
9195128Sgonzo *    notice, this list of conditions and the following disclaimer.
10195128Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
11195128Sgonzo *    notice, this list of conditions and the following disclaimer in the
12195128Sgonzo *    documentation and/or other materials provided with the distribution.
13195128Sgonzo * 3. All advertising materials mentioning features or use of this software
14195128Sgonzo *    must display the following acknowledgement:
15195128Sgonzo *	This product includes software developed by the University of
16195128Sgonzo *	California, Berkeley and its contributors.
17195128Sgonzo * 4. Neither the name of the University nor the names of its contributors
18195128Sgonzo *    may be used to endorse or promote products derived from this software
19195128Sgonzo *    without specific prior written permission.
20195128Sgonzo *
21195128Sgonzo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22195128Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23195128Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24195128Sgonzo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25195128Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26195128Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27195128Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28195128Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29195128Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30195128Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31195128Sgonzo * SUCH DAMAGE.
32195128Sgonzo *
33195128Sgonzo *	from: @(#)sys_machdep.c	5.5 (Berkeley) 1/19/91
34195128Sgonzo */
35195128Sgonzo
36195128Sgonzo#include <sys/cdefs.h>
37195128Sgonzo__FBSDID("$FreeBSD$");
38195128Sgonzo
39195128Sgonzo#include <sys/param.h>
40195128Sgonzo#include <sys/systm.h>
41195128Sgonzo#include <sys/proc.h>
42195128Sgonzo#include <sys/sysproto.h>
43195128Sgonzo#include <sys/syscall.h>
44195128Sgonzo#include <sys/sysent.h>
45195128Sgonzo
46195128Sgonzo#include <machine/sysarch.h>
47195128Sgonzo
48195128Sgonzo#ifndef _SYS_SYSPROTO_H_
49195128Sgonzostruct sysarch_args {
50195128Sgonzo	int op;
51195128Sgonzo	char *parms;
52195128Sgonzo};
53195128Sgonzo#endif
54195128Sgonzo
55195128Sgonzoint
56195128Sgonzosysarch(td, uap)
57195128Sgonzo	struct thread *td;
58195128Sgonzo	register struct sysarch_args *uap;
59195128Sgonzo{
60195128Sgonzo	int error;
61195128Sgonzo	void *tlsbase;
62195128Sgonzo
63195128Sgonzo	switch (uap->op) {
64195128Sgonzo	case MIPS_SET_TLS :
65195128Sgonzo		td->td_md.md_tls = (void*)uap->parms;
66195128Sgonzo		error = 0;
67195128Sgonzo		break;
68195128Sgonzo
69195128Sgonzo	case MIPS_GET_TLS :
70195128Sgonzo		tlsbase = td->td_md.md_tls;
71195128Sgonzo		error = copyout(&tlsbase, uap->parms, sizeof(tlsbase));
72195128Sgonzo		break;
73195128Sgonzo	default:
74195128Sgonzo		error = EINVAL;
75195128Sgonzo	}
76195128Sgonzo	return (error);
77195128Sgonzo}
78