summaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/fpumacro.h
blob: dab13447254f4db5e09f946b5bfebe2d96fa588d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* fpumacro.h: FPU related macros.
 *
 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
 */

#ifndef _SPARC64_FPUMACRO_H
#define _SPARC64_FPUMACRO_H

extern __inline__ unsigned long fprs_read(void)
{
	unsigned long retval;

	__asm__ __volatile__("rd %%fprs, %0" : "=r" (retval));

	return retval;
}

extern __inline__ void fprs_write(unsigned long val)
{
	__asm__ __volatile__("wr %0, 0x0, %%fprs" : : "r" (val));
}

extern __inline__ void fpsave(unsigned long *fpregs,
			      unsigned long *fsr,
			      unsigned long *gsr)
{
	__asm__ __volatile__ ("
	wr	%%g0, %3, %%asi
	rd	%%gsr, %%g1
	membar	#LoadStore | #StoreStore
	stx	%%fsr, [%1]
	stx	%%g1, [%2]
	stda	%%f0, [%0] %%asi
	stda	%%f16, [%0 + 64] %%asi
	stda	%%f32, [%0 + 128] %%asi
	stda	%%f48, [%0 + 192] %%asi
	membar	#Sync
"	: /* No outputs */
	: "r" (fpregs), "r" (fsr), "r" (gsr), "i" (ASI_BLK_P)
	: "g1");
}

extern __inline__ void fpload(unsigned long *fpregs,
			      unsigned long *fsr,
			      unsigned long *gsr)
{
	__asm__ __volatile__ ("
	wr	%%g0, %3, %%asi
	membar	#StoreLoad | #LoadLoad
	ldda	[%0] %%asi, %%f0
	ldda	[%0 + 64] %%asi, %%f16
	ldda	[%0 + 128] %%asi, %%f32
	ldda	[%0 + 192] %%asi, %%f48
	ldx	[%1], %%fsr
	ldx	[%2], %%g1
	wr	%%g1, 0, %%gsr
	membar	#Sync
"	: /* No outputs */
	: "r" (fpregs), "r" (fsr), "r" (gsr), "i" (ASI_BLK_P)
	: "g1");
}

#endif /* !(_SPARC64_FPUMACRO_H) */