Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: barrier_subr_v9.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 | #ifdef ARCH_X64 | |
24 | ||
25 | /* | |
26 | * void barrier(uint32_t loopticks) | |
27 | * Hmm, this function is not used anymore and should be deleted. | |
28 | * In fact, the following files should be deleted: | |
29 | * system/util/barrier_subr_v9.s | |
30 | * system/util/barrier_subr_v8.s | |
31 | * system/util/include/barrier.h | |
32 | * system/util/barrier.cc | |
33 | * and all references to cpu_barrier | |
34 | */ | |
35 | ||
36 | #else | |
37 | ||
38 | #pragma ident "@(#)1.3 07/07/10 barrier_subr_v9.s" | |
39 | ||
40 | #include <sys/asm_linkage.h> | |
41 | ||
42 | #if 0 | |
43 | ||
44 | ENTRY(barrier) | |
45 | ldx [%o0+24], %o1 ! load bp->sbp into %o1 | |
46 | ||
47 | ! atomic decrement of running count | |
48 | add %o1, 4, %o2 | |
49 | retry: ld [%o2], %o3 | |
50 | add %o3, -1, %o4 | |
51 | cas [%o2], %o3, %o4 | |
52 | cmp %o3, %o4 | |
53 | bne retry | |
54 | nop | |
55 | ||
56 | ! check if this is the last one | |
57 | cmp %o3, 1 | |
58 | bne wait | |
59 | nop | |
60 | ||
61 | ! YES, switch sub-barriers, reset count and CV | |
62 | add %o0, 4, %o2 ! %o2 = &bp->sb[0] | |
63 | cmp %o1, %o2 | |
64 | bne 1f | |
65 | nop | |
66 | add %o0, 12, %o2 ! %o2 = &bp->sb[1] | |
67 | 1: stx %o2, [%o0 + 24] ! store %o2 into bp->sbp | |
68 | set 1, %o4 | |
69 | st %o4, [%o2] | |
70 | ld [%o0], %o3 | |
71 | st %o3, [%o2 + 4] | |
72 | ||
73 | ! release the CV busy-waiters | |
74 | retl | |
75 | clr [%o1] | |
76 | ||
77 | ! NO, busy-wait on CV | |
78 | wait: ld [%o1], %o2 | |
79 | tst %o2 | |
80 | bne wait | |
81 | nop | |
82 | retl | |
83 | nop | |
84 | SET_SIZE(barrier) | |
85 | ||
86 | #else | |
87 | ||
88 | .global cpu_barrier | |
89 | ENTRY(barrier) | |
90 | or %o0, 0, %o5 ! loopticks | |
91 | setx cpu_barrier, %o2, %o0 | |
92 | ldx [%o0 + 24], %o1 ! load bp->sbp into %o1 | |
93 | ldx [%o0 + 32], %o0 !!!!!! global tick pointer | |
94 | ||
95 | ! atomic decrement of running count | |
96 | add %o1, 4, %o2 | |
97 | retry: ld [%o2], %o3 | |
98 | add %o3, -1, %o4 | |
99 | cas [%o2], %o3, %o4 | |
100 | cmp %o3, %o4 | |
101 | bne retry | |
102 | nop | |
103 | ||
104 | retry1: ldx [%o0], %o2 !! global_tick + looptick | |
105 | add %o2, %o5, %o4 !! | |
106 | casx [%o0], %o2, %o4 !! | |
107 | cmp %o2, %o4 !! | |
108 | bne,pn %xcc, retry1 | |
109 | nop !! | |
110 | ||
111 | ! check if this is the last one | |
112 | cmp %o3, 1 | |
113 | bne wait | |
114 | nop | |
115 | ||
116 | ! YES, switch sub-barriers, reset count and CV | |
117 | setx cpu_barrier, %o2, %o0 | |
118 | add %o0, 4, %o2 ! %o2 = &bp->sb[0] | |
119 | cmp %o1, %o2 | |
120 | bne 1f | |
121 | nop | |
122 | add %o0, 12, %o2 ! %o2 = &bp->sb[1] | |
123 | 1: stx %o2, [%o0 + 24] ! store %o2 into bp->sbp | |
124 | set 1, %o4 | |
125 | st %o4, [%o2] | |
126 | ld [%o0], %o3 | |
127 | st %o3, [%o2 + 4] | |
128 | ||
129 | ! release the CV busy-waiters | |
130 | retl | |
131 | clr [%o1] | |
132 | ||
133 | ! NO, busy-wait on CV | |
134 | wait: ld [%o1], %o2 | |
135 | tst %o2 | |
136 | bne wait | |
137 | nop | |
138 | retl | |
139 | nop | |
140 | SET_SIZE(barrier) | |
141 | ||
142 | #endif | |
143 | ||
144 | ||
145 | #endif |