Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / system / util / barrier_subr_v8.s
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: barrier_subr_v8.s
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23#pragma ident "@(#)1.2 02/05/23 barrier_subr_v8.s"
24
25#include <sys/asm_linkage.h>
26
27#if 0
28
29 ENTRY(barrier)
30 ld [%o0 + 20], %o1 ! load bp->sbp into %o1
31 ! atomic decrement of running count
32 add %o1, 4, %o2
33retry: ld [%o2], %o3
34 add %o3, -1, %o4
35 cas [%o2], %o3, %o4
36 cmp %o3, %o4
37 bne retry
38 nop
39
40 ! check if this is the last one
41 cmp %o3, 1
42 bne wait
43 nop
44
45 ! YES, switch sub-barriers, reset count and CV
46 add %o0, 4, %o2 ! %o2 = &bp->sb[0]
47 cmp %o1, %o2
48 bne 1f
49 nop
50 add %o0, 12, %o2 ! %o2 = &bp->sb[1]
511: st %o2, [%o0 + 20] ! store %o2 into bp->sbp
52 set 1, %o4
53 st %o4, [%o2]
54 ld [%o0], %o3
55 st %o3, [%o2 + 4]
56
57 ! release the CV busy-waiters
58 retl
59 clr [%o1]
60
61 ! NO, busy-wait on CV
62wait: ld [%o1], %o2
63 tst %o2
64 bne wait
65 nop
66 retl
67 nop
68 SET_SIZE(barrier)
69
70#else
71
72 .global cpu_barrier
73 ENTRY(barrier)
74 or %o0, 0, %o5 ! loopticks
75 set cpu_barrier, %o0
76 ld [%o0 + 20], %o1 ! load bp->sbp into %o1
77 ld [%o0 + 24], %o0 !!!!!! global tick pointer
78
79 ! atomic decrement of running count
80 add %o1, 4, %o2
81retry: ld [%o2], %o3
82 add %o3, -1, %o4
83 cas [%o2], %o3, %o4
84 cmp %o3, %o4
85 bne retry
86 nop
87
88retry1: ldx [%o0], %o2 !!
89 add %o2, %o5, %o4 !!
90 casx [%o0], %o2, %o4 !!
91 cmp %o2, %o4 !!
92 bne,pn %xcc, retry1
93 nop !!
94
95 ! check if this is the last one
96 cmp %o3, 1
97 bne wait
98 nop
99
100 ! YES, switch sub-barriers, reset count and CV
101 set cpu_barrier, %o0
102 add %o0, 4, %o2 ! %o2 = &bp->sb[0]
103 cmp %o1, %o2
104 bne 1f
105 nop
106 add %o0, 12, %o2 ! %o2 = &bp->sb[1]
1071: st %o2, [%o0 + 20] ! store %o2 into bp->sbp
108 set 1, %o4
109 st %o4, [%o2]
110 ld [%o0], %o3
111 st %o3, [%o2 + 4]
112
113 ! release the CV busy-waiters
114 retl
115 clr [%o1]
116
117 ! NO, busy-wait on CV
118wait: ld [%o1], %o2
119 tst %o2
120 bne wait
121 nop
122 retl
123 nop
124 SET_SIZE(barrier)
125
126
127
128#endif