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
65
66
67
68
69
70
71
72
73
74
75
76
|
/* $OpenBSD: uthread_machdep_asm.S,v 1.3 2002/11/29 09:27:34 deraadt Exp $ */
/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
#include <machine/asm.h>
#define INTOFF(n) ((n)*8)
#define FPOFF(n) (INTOFF(9) + (n)*8)
#define ALIGN(x) (((x)+15)&~15)
#define FRAMESIZE ALIGN(FPOFF(8))
.set noreorder
.globl _thread_machdep_switch
.ent _thread_machdep_switch, 2
_thread_machdep_switch:
.frame sp, FRAMESIZE, ra
ldgp gp, 0(pv)
lda sp, -FRAMESIZE(sp)
stq ra, INTOFF(0)(sp)
stq s0, INTOFF(1)(sp)
stq s1, INTOFF(2)(sp)
stq s2, INTOFF(3)(sp)
stq s3, INTOFF(4)(sp)
stq s4, INTOFF(5)(sp)
stq s5, INTOFF(6)(sp)
stq s6, INTOFF(7)(sp)
stq t12, INTOFF(8)(sp)
stt fs0, FPOFF(0)(sp)
stt fs1, FPOFF(1)(sp)
stt fs2, FPOFF(2)(sp)
stt fs3, FPOFF(3)(sp)
stt fs4, FPOFF(4)(sp)
stt fs5, FPOFF(5)(sp)
stt fs6, FPOFF(6)(sp)
stt fs7, FPOFF(7)(sp)
stq sp, 0(a1)
or a0, zero, pv
ldq sp, 0(a0)
ldt fs7, FPOFF(7)(sp)
ldt fs6, FPOFF(6)(sp)
ldt fs5, FPOFF(5)(sp)
ldt fs4, FPOFF(4)(sp)
ldt fs3, FPOFF(3)(sp)
ldt fs2, FPOFF(2)(sp)
ldt fs1, FPOFF(1)(sp)
ldt fs0, FPOFF(0)(sp)
ldq t12, INTOFF(8)(sp)
ldq s6, INTOFF(7)(sp)
ldq s5, INTOFF(6)(sp)
ldq s4, INTOFF(5)(sp)
ldq s3, INTOFF(4)(sp)
ldq s2, INTOFF(3)(sp)
ldq s1, INTOFF(2)(sp)
ldq s0, INTOFF(1)(sp)
ldq ra, INTOFF(0)(sp)
lda sp,FRAMESIZE(sp)
RET
.end _thread_machdep_switch
LEAF(_atomic_lock,1)
LDGP(pv)
0: ldq_l v0, 0(a0) /* read existing lock value */
mov 1, t0 /* locked value to store */
stq_c t0, 0(a0) /* attempt to store, status in t0 */
beq t0, 1f /* branch forward to optimise prediction */
mb /* sync with other processors */
RET /* return with v0==0 if lock obtained */
1: br 0b /* loop to try again */
END(_atomic_lock)
|