1*1a6ecb2cSmiod /* $OpenBSD: fpc_csr.c,v 1.1 2010/09/24 13:54:06 miod Exp $ */
2*1a6ecb2cSmiod
3*1a6ecb2cSmiod /*
4*1a6ecb2cSmiod * Copyright (c) 2010 Miodrag Vallat.
5*1a6ecb2cSmiod *
6*1a6ecb2cSmiod * Permission to use, copy, modify, and distribute this software for any
7*1a6ecb2cSmiod * purpose with or without fee is hereby granted, provided that the above
8*1a6ecb2cSmiod * copyright notice and this permission notice appear in all copies.
9*1a6ecb2cSmiod *
10*1a6ecb2cSmiod * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*1a6ecb2cSmiod * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*1a6ecb2cSmiod * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*1a6ecb2cSmiod * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*1a6ecb2cSmiod * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*1a6ecb2cSmiod * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*1a6ecb2cSmiod * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*1a6ecb2cSmiod */
18*1a6ecb2cSmiod
19*1a6ecb2cSmiod /*
20*1a6ecb2cSmiod * IRIX-compatible get_fpc_csr() and set_fpc_csr() functions
21*1a6ecb2cSmiod */
22*1a6ecb2cSmiod
23*1a6ecb2cSmiod #include <sys/types.h>
24*1a6ecb2cSmiod #include <machine/fpu.h>
25*1a6ecb2cSmiod
26*1a6ecb2cSmiod int
get_fpc_csr()27*1a6ecb2cSmiod get_fpc_csr()
28*1a6ecb2cSmiod {
29*1a6ecb2cSmiod int32_t csr;
30*1a6ecb2cSmiod
31*1a6ecb2cSmiod __asm__("cfc1 %0,$31" : "=r" (csr));
32*1a6ecb2cSmiod return csr;
33*1a6ecb2cSmiod }
34*1a6ecb2cSmiod
35*1a6ecb2cSmiod int
set_fpc_csr(int csr)36*1a6ecb2cSmiod set_fpc_csr(int csr)
37*1a6ecb2cSmiod {
38*1a6ecb2cSmiod int32_t oldcsr;
39*1a6ecb2cSmiod
40*1a6ecb2cSmiod __asm__("cfc1 %0,$31" : "=r" (oldcsr));
41*1a6ecb2cSmiod __asm__("ctc1 %0,$31" :: "r" (csr));
42*1a6ecb2cSmiod
43*1a6ecb2cSmiod return oldcsr;
44*1a6ecb2cSmiod }
45