Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: mon_macros.h | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | #ifndef _MON_MACROS_H | |
39 | #define _MON_MACROS_H | |
40 | ||
41 | #ident "@(#) mon_macros.h 1.13 05/04/11 10:05:17" | |
42 | ||
43 | #define R_IMPL_CHEETAH 0x14 | |
44 | #define R_IMPL_CHEETAHPLUS 0x15 | |
45 | #define R_IMPL_JALAPENO 0x16 | |
46 | #define R_IMPL_GEMINI 0x17 | |
47 | #define R_IMPL_JAGUAR 0x18 | |
48 | #define R_IMPL_PANTHER 0x19 | |
49 | #define R_IMPL_MILLENNIUM 0x20 | |
50 | #define R_IMPL_SERRANO 0x22 | |
51 | #define R_IMPL_NIAGRA 0x23 | |
52 | ||
53 | #ifdef CHTAH_CPU | |
54 | ||
55 | #define PHCPUID_MASK 0x3ff | |
56 | #define PHCPUID_SHIFT 17 | |
57 | #define MAXPHCPU (PHCPUID_MASK+1) | |
58 | #define LOG2MAXCPU 8 | |
59 | ||
60 | #elif defined(BW_CPU) | |
61 | ||
62 | #define PHCPUID_MASK 0xff | |
63 | #define PHCPUID_SHIFT 17 | |
64 | #define MAXPHCPU 32 | |
65 | #define LOG2MAXCPU 5 | |
66 | ||
67 | #else | |
68 | ||
69 | #define MAXPHCPU 1 | |
70 | ||
71 | #endif | |
72 | ||
73 | #ifdef _ASM | |
74 | ||
75 | #define SAVE_OREGS( memptr, offset )\ | |
76 | stx %o0, [memptr + offset + 0x00] ;\ | |
77 | stx %o1, [memptr + offset + 0x08] ;\ | |
78 | stx %o2, [memptr + offset + 0x10] ;\ | |
79 | stx %o3, [memptr + offset + 0x18] ;\ | |
80 | stx %o4, [memptr + offset + 0x20] ;\ | |
81 | stx %o5, [memptr + offset + 0x28] ;\ | |
82 | stx %o6, [memptr + offset + 0x30] ;\ | |
83 | stx %o7, [memptr + offset + 0x38] | |
84 | ||
85 | #define RESTORE_OREGS( memptr, offset )\ | |
86 | ldx [memptr + offset + 0x00], %o0 ;\ | |
87 | ldx [memptr + offset + 0x08], %o1 ;\ | |
88 | ldx [memptr + offset + 0x10], %o2 ;\ | |
89 | ldx [memptr + offset + 0x18], %o3 ;\ | |
90 | ldx [memptr + offset + 0x20], %o4 ;\ | |
91 | ldx [memptr + offset + 0x28], %o5 ;\ | |
92 | ldx [memptr + offset + 0x30], %o6 ;\ | |
93 | ldx [memptr + offset + 0x38], %o7 | |
94 | ||
95 | ||
96 | #define GET_MUTEX(mutexname, mutexreg, scr1 ) \ | |
97 | setx mutexname, scr1, mutexreg ;\ | |
98 | 7:;\ | |
99 | ldstub [mutexreg], scr1 ;\ | |
100 | brz scr1, 9f ;\ | |
101 | nop ;\ | |
102 | 8:;\ | |
103 | ldub [mutexreg], scr1 ;\ | |
104 | brnz,pn scr1, 8b ;\ | |
105 | membar #LoadLoad ;\ | |
106 | ba 7b ;\ | |
107 | nop ;\ | |
108 | 9:;\ | |
109 | rd %pc, scr1 ;\ | |
110 | st scr1, [mutexreg + 4] | |
111 | ||
112 | ||
113 | #define FREE_MUTEX( mutexname, mutexreg, scr1 ) \ | |
114 | setx mutexname, scr1, mutexreg ;\ | |
115 | stub %g0, [mutexreg] ;\ | |
116 | membar #LoadStore|#StoreStore | |
117 | ||
118 | /* | |
119 | * VERS_TO_IMPL() | |
120 | * | |
121 | * The scratch register must be different from the output but | |
122 | * can be the same as the input_ver_reg. | |
123 | * | |
124 | * The input and output can be the same provided the scratch | |
125 | * register is different. | |
126 | * | |
127 | * VERS_TO_IMPL( %g1, %g2, %g3 ) OK Vers is preserved | |
128 | * VERS_TO_IMPL( %g1, %g2, %g1 ) OK Vers on input is impl on o/p | |
129 | * VERS_TO_IMPL( %g1, %g1, %g2 ) OK Vers is corrupted | |
130 | * VERS_TO_IMPL( %g1, %g1, %g1 ) ***BAD Will not work *** | |
131 | */ | |
132 | ||
133 | #define VERS_TO_IMPL( input_vers_reg, output_impl_reg ) \ | |
134 | sllx input_vers_reg, 16, output_impl_reg ;\ | |
135 | srlx output_impl_reg, 48, output_impl_reg | |
136 | ||
137 | #ifdef CHTAH_CPU | |
138 | ||
139 | #define GET_VERS( scratch, output_ver ) \ | |
140 | rdpr %ver, output_ver | |
141 | ||
142 | #define GET_IMPL(scratch,impl) \ | |
143 | rdpr %ver, impl; \ | |
144 | VERS_TO_IMPL(impl,impl) | |
145 | ||
146 | #define GET_PHCPUID(scratch,reg)\ | |
147 | ldxa [%g0]ASI_UPA_CONFIG,reg; \ | |
148 | srlx reg,PHCPUID_SHIFT,reg; \ | |
149 | and reg,PHCPUID_MASK,reg | |
150 | ||
151 | #endif | |
152 | ||
153 | #ifdef HPV | |
154 | ||
155 | #include "rust_hpv_macros.h" | |
156 | ||
157 | #define GET_VERS( scratch, output_ver ) \ | |
158 | mov %o0, scratch;\ | |
159 | set hcall_rust_rd_ver_reg, %o0;\ | |
160 | DO_HPRIVCALL(%o0) ;\ | |
161 | mov %o0, output_ver;\ | |
162 | mov scratch, %o0 | |
163 | ||
164 | #define GET_IMPL( scratch, output_impl )\ | |
165 | GET_VERS( scratch, output_impl );\ | |
166 | VERS_TO_IMPL(impl,impl) | |
167 | ||
168 | #define GET_PHCPUID(scratch,reg) \ | |
169 | mov %o0,scratch; \ | |
170 | GET_CPU_ID(reg); \ | |
171 | mov scratch,%o0 | |
172 | #endif | |
173 | ||
174 | #endif | |
175 | ||
176 | #endif /* _MON_MACROS_H */ |