8354 sync regcomp(3C) with upstream (fix make catalog)
[unleashed/tickless.git] / usr / src / uts / sun4u / sys / spitregs.h
blob492990c7200f58190e385a9611f29b4698726795
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_SPITREGS_H
28 #define _SYS_SPITREGS_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * This file is cpu dependent.
40 #ifdef _STARFIRE
42 * Starfire's cpu upaids are not the same
43 * as cpuids.
44 * XXX - our obp took the liberty of
45 * converting cpu upaids into cpuids when
46 * presenting it as upa-portid property.
48 #define CPUID_TO_UPAID(upaid) (((upaid & 0x3C) << 1) | \
49 ((upaid & 0x40) >> 4) | \
50 (upaid &0x3))
51 #else
53 * The mid is the same as the cpu id.
54 * We might want to change this later
56 #define CPUID_TO_UPAID(cpuid) (cpuid)
57 #endif /* _STARFIRE */
60 * LSU Control Register
62 * +------+----+----+----+----+----+----+-----+------+----+----+----+---+
63 * | Resv | PM | VM | PR | PW | VR | VW | Rsv | FM | DM | IM | DC | IC|
64 * +------+----+----+----+----+----+----+-----+------+----+----+----+---+
65 * 63 41 33 25 24 23 22 21 20 19 4 3 2 1 0
69 #define LSU_IC 0x00000000001 /* icache enable */
70 #define LSU_DC 0x00000000002 /* dcache enable */
71 #define LSU_IM 0x00000000004 /* immu enable */
72 #define LSU_DM 0x00000000008 /* dmmu enable */
73 #define LSU_FM 0x000000FFFF0 /* parity mask */
74 #define LSU_VW 0x00000200000 /* virtual watchpoint write enable */
75 #define LSU_VR 0x00000400000 /* virtual watchpoint read enable */
76 #define LSU_PW 0x00000800000 /* physical watchpoint write enable */
77 #define LSU_PR 0x00001000000 /* physical watchpoint read enable */
78 #define LSU_VM 0x001fe000000 /* virtual watchpoint byte mask */
79 #define LSU_PM 0x1fe00000000 /* physical watch point byte mask */
81 #define LSU_VM_SHIFT 25
82 #define LSU_PM_SHIFT 33
85 * Defines for the different types of dcache_flush
86 * it is stored in dflush_type
88 #define FLUSHALL_TYPE 0x0 /* blasts all cache lines */
89 #define FLUSHMATCH_TYPE 0x1 /* flush entire cache but check each */
90 /* each line for a match */
91 #define FLUSHPAGE_TYPE 0x2 /* flush only one page and check */
92 /* each line for a match */
95 * D-Cache Tag Data Register
97 * +----------+--------+----------+
98 * | Reserved | DC_Tag | DC_Valid |
99 * +----------+--------+----------+
100 * 63 30 29 2 1 0
103 #define ICACHE_FLUSHSZ 0x20 /* one line in i$ */
104 #define DC_PTAG_SHIFT 34
105 #define DC_LINE_SHIFT 30
106 #define SF_DC_VBIT_SHIFT 2
107 #define SF_DC_VBIT_MASK 0x3
108 #define IC_LINE_SHIFT 3
109 #define IC_LINE 512
110 #define INDEX_BIT_SHIFT 13
113 * Definitions of sun4u cpu implementations as specified in version register
115 #define SPITFIRE_IMPL 0x10
116 #define IS_SPITFIRE(impl) ((impl) == SPITFIRE_IMPL)
117 #define SPITFIRE_MAJOR_VERSION(rev) (((rev) >> 4) & 0xf)
118 #define SPITFIRE_MINOR_VERSION(rev) ((rev) & 0xf)
120 #define BLACKBIRD_IMPL 0x11
121 #define IS_BLACKBIRD(impl) ((impl) == BLACKBIRD_IMPL)
122 #define BLACKBIRD_MAJOR_VERSION(rev) (((rev) >> 4) & 0xf)
123 #define BLACKBIRD_MINOR_VERSION(rev) ((rev) & 0xf)
125 #define SABRE_IMPL 0x12
126 #define HUMMBRD_IMPL 0x13
129 * Bits of Spitfire Asynchronous Fault Status Register
131 #define P_AFSR_STICKY 0x00000001FFF00000ULL /* mask for all sticky bits */
132 #define P_AFSR_ERRS 0x000000001EE00000ULL /* mask for remaining errors */
133 #define P_AFSR_ME 0x0000000100000000ULL /* errors > 1, same type!=CE */
134 #define P_AFSR_PRIV 0x0000000080000000ULL /* priv/supervisor access */
135 #define P_AFSR_ISAP 0x0000000040000000ULL /* incoming system addr. parity */
136 #define P_AFSR_ETP 0x0000000020000000ULL /* ecache tag parity */
137 #define P_AFSR_IVUE 0x0000000010000000ULL /* interrupt vector with UE */
138 #define P_AFSR_TO 0x0000000008000000ULL /* bus timeout */
139 #define P_AFSR_BERR 0x0000000004000000ULL /* bus error */
140 #define P_AFSR_LDP 0x0000000002000000ULL /* data parity error from SDB */
141 #define P_AFSR_CP 0x0000000001000000ULL /* copyout parity error */
142 #define P_AFSR_WP 0x0000000000800000ULL /* writeback ecache data parity */
143 #define P_AFSR_EDP 0x0000000000400000ULL /* ecache data parity */
144 #define P_AFSR_UE 0x0000000000200000ULL /* uncorrectable ECC error */
145 #define P_AFSR_CE 0x0000000000100000ULL /* correctable ECC error */
146 #define P_AFSR_ETS 0x00000000000F0000ULL /* cache tag parity syndrome */
147 #define P_AFSR_P_SYND 0x000000000000FFFFULL /* data parity syndrome */
150 * All error types
152 #define S_AFSR_ALL_ERRS (P_AFSR_STICKY & ~P_AFSR_PRIV)
155 * Shifts for Spitfire Asynchronous Fault Status Register
157 #define P_AFSR_D_SIZE_SHIFT (57)
158 #define P_AFSR_CP_SHIFT (24)
159 #define P_AFSR_ETS_SHIFT (16)
162 * AFSR error bits for AFT Level 1 messages (uncorrected + parity + BERR + TO)
164 #define P_AFSR_LEVEL1 (P_AFSR_UE | P_AFSR_EDP | P_AFSR_WP | P_AFSR_CP |\
165 P_AFSR_LDP | P_AFSR_BERR | P_AFSR_TO)
168 * Bits of Spitfire Asynchronous Fault Status Register
170 #define S_AFSR_MASK 0x00000001FFFFFFFFULL /* <33:0>: valid AFSR bits */
173 * Bits of Spitfire Asynchronous Fault Address Register
174 * The Sabre AFAR includes more bits since it only has a UDBH, no UDBL
176 #define S_AFAR_PA 0x000001FFFFFFFFF0ULL /* PA<40:4>: physical address */
177 #define SABRE_AFAR_PA 0x000001FFFFFFFFF8ULL /* PA<40:3>: physical address */
180 * Bits of Spitfire/Sabre/Hummingbird Error Enable Registers
182 #define EER_EPEN 0x00000000000000010ULL /* enable ETP, EDP, WP, CP */
183 #define EER_UEEN 0x00000000000000008ULL /* enable UE */
184 #define EER_ISAPEN 0x00000000000000004ULL /* enable ISAP */
185 #define EER_NCEEN 0x00000000000000002ULL /* enable the other errors */
186 #define EER_CEEN 0x00000000000000001ULL /* enable CE */
187 #define EER_DISABLE 0x00000000000000000ULL /* no errors enabled */
188 #define EER_ECC_DISABLE (EER_EPEN|EER_UEEN|EER_ISAPEN)
189 #define EER_CE_DISABLE (EER_EPEN|EER_UEEN|EER_ISAPEN|EER_NCEEN)
190 #define EER_ENABLE (EER_EPEN|EER_UEEN|EER_ISAPEN|EER_NCEEN|EER_CEEN)
193 * Bits and vaddrs of Spitfire Datapath Error Registers
195 #define P_DER_UE 0x00000000000000200ULL /* UE has occurred */
196 #define P_DER_CE 0x00000000000000100ULL /* CE has occurred */
197 #define P_DER_E_SYND 0x000000000000000FFULL /* SYND<7:0>: ECC syndrome */
198 #define P_DER_H 0x0 /* datapath error reg upper */
199 #define P_DER_L 0x18 /* datapath error reg upper */
202 * Bits of Spitfire Datapath Control Register
204 #define P_DCR_VER 0x000001E00 /* datapath version */
205 #define P_DCR_F_MODE 0x000000100 /* send FCB<7:0> */
206 #define P_DCR_FCB 0x0000000FF /* ECC check bits to force */
207 #define P_DCR_H 0x20 /* datapath control reg upper */
208 #define P_DCR_L 0x38 /* datapath control reg lower */
211 * Bits and shifts for the Spitfire (S), Sabre (SB) and Hummingbird (HB)
212 * Ecache tag data
214 #define S_ECTAG_MASK 0x000000000003FFFFFULL /* spitfire ecache tag mask */
215 #define SB_ECTAG_MASK 0x00000000000000FFFULL /* sabre ecache tag mask */
216 #define HB_ECTAG_MASK 0x0000000000000FFFFULL /* hbird ecache tag mask */
217 #define S_ECSTATE_MASK 0x00000000001C00000ULL /* spitfire tag state mask */
218 #define SB_ECSTATE_MASK 0x0000000000000C000ULL /* sabre tag state mask */
219 #define HB_ECSTATE_MASK 0x00000000000030000ULL /* hbird tag state mask */
220 #define S_ECPAR_MASK 0x0000000001E000000ULL /* spitfire tag parity mask */
221 #define SB_ECPAR_MASK 0x00000000000030000ULL /* sabre tag parity mask */
222 #define HB_ECPAR_MASK 0x00000000000300000ULL /* hbird tag parity mask */
223 #define S_ECTAG_SHIFT 19 /* spitfire ecache tag shift */
224 #define SB_ECTAG_SHIFT 18 /* sabre ecache tag shift */
225 #define HB_ECTAG_SHIFT 16 /* hbird ecache tag shift */
226 #define S_ECSTATE_SHIFT 22 /* spitfire tag state shift */
227 #define SB_ECSTATE_SHIFT 14 /* sabre tag state shift */
228 #define HB_ECSTATE_SHIFT 16 /* hbird tag state shift */
229 #define S_ECPAR_SHIFT 25 /* spitfire tag parity shift */
230 #define SB_ECPAR_SHIFT 16 /* sabre tag parity shift */
231 #define HB_ECPAR_SHIFT 20 /* hbird tag parity shift */
232 #define S_ECACHE_MAX_LSIZE 64 /* E$ line size */
235 * Constants representing the complete Spitfire (S), Sabre (SB) and Hummingbird
236 * (HB) tag state:
238 #define S_ECSTATE_SHR 0x1 /* shared */
239 #define S_ECSTATE_EXL 0x3 /* exclusive */
240 #define S_ECSTATE_OWN 0x5 /* owner */
241 #define S_ECSTATE_MOD 0x7 /* modified */
242 #define SB_ECSTATE_EXL 0x2 /* exclusive */
243 #define SB_ECSTATE_MOD 0x3 /* modified */
244 #define HB_ECSTATE_EXL 0x2 /* exclusive */
245 #define HB_ECSTATE_MOD 0x3 /* modified */
248 * Constants representing the individual Spitfire (S), Sabre (SB) and
249 * Hummingbird (HB) state bits:
251 #define S_ECSTATE_VALID 0x1 /* line is valid */
252 #define S_ECSTATE_DIRTY 0x4 /* line is dirty */
253 #define SB_ECSTATE_VALID 0x2 /* line is valid */
254 #define SB_ECSTATE_DIRTY 0x1 /* line is dirty */
255 #define HB_ECSTATE_VALID 0x2 /* line is valid */
256 #define HB_ECSTATE_DIRTY 0x1 /* line is dirty */
259 * Constants representing the individual Spitfire (S), Sabre (SB) and
260 * Hummingbird (HB) state parity and address parity bits:
262 #define S_ECSTATE_PARITY 0x8 /* tag state parity bit */
263 #define S_EC_PARITY 0xF /* all parity bits */
264 #define SB_ECSTATE_PARITY 0x2 /* tag state parity bit */
265 #define SB_EC_PARITY 0x3 /* all parity bits */
266 #define HB_ECSTATE_PARITY 0x2 /* tag state parity bit */
267 #define HB_EC_PARITY 0x3 /* all parity bits */
269 #ifdef HUMMINGBIRD
271 #define HB_ESTAR_MODE INT64_C(0x1FE0000F080) /* estar mode reg */
272 #define HB_MEM_CNTRL0 INT64_C(0x1FE0000F010) /* mem control0 reg */
273 #define HB_REFRESH_COUNT_MASK 0x7F00 /* mc0<14:8>: ref cnt */
274 #define HB_REFRESH_COUNT_SHIFT 8 /* bits to shift */
275 #define HB_REFRESH_INTERVAL INT64_C(7800) /* 7800 nsecs memory */
276 /* refresh interval */
277 /* works for all DIMM */
278 /* same value as OBP */
279 #define HB_REFRESH_CLOCKS_PER_COUNT INT64_C(64) /* cpu clks per count */
280 #define HB_SELF_REFRESH_MASK 0x10000 /* mc0<16>: self ref */
281 #define HB_SELF_REFRESH_SHIFT 16 /* bits to shift */
282 #define HB_SELF_REFRESH_DISABLE 0 /* disable self ref */
283 #define HB_SELF_REFRESH_ENABLE 1 /* enable self ref */
285 #define HB_ECLK_1 INT64_C(0x0000000000000000) /* 1/1 clock */
286 #define HB_ECLK_2 INT64_C(0x0000000000000001) /* 1/2 clock */
287 #define HB_ECLK_4 INT64_C(0x0000000000000003) /* 1/4 clock */
288 #define HB_ECLK_6 INT64_C(0x0000000000000002) /* 1/6 clock */
289 #define HB_ECLK_8 INT64_C(0x0000000000000004) /* 1/8 clock */
290 #define HB_ECLK_MASK (HB_ECLK_1|HB_ECLK_2|HB_ECLK_4|HB_ECLK_6|HB_ECLK_8)
294 * UPA Configuration Register
296 * +--------------+----+------+------+----------+------+-------------+
297 * | Resv | RR | DM | ELIM | PCON | MID | PCAP |
298 * +--------------+----+------+------+----------+------+-------------+
299 * 63 39 38 37..36 35..33 32......22 21..17 16..........0
303 #define HB_UPA_DMAP_DATA_BIT 36 /* loads and stores direct mapped */
304 #define HB_UPA_DMAP_INSTR_BIT 37 /* instruction misses direct mapped */
305 #define HB_UPA_RR_BIT 38 /* reset rand generator */
307 #endif /* HUMMINGBIRD */
310 * The minimum size needed to ensure consistency on a virtually address
311 * cache. Computed by taking the largest virtually indexed cache and dividing
312 * by its associativity.
314 #define S_VAC_SIZE 0x4000
316 #ifdef _KERNEL
318 #ifndef _ASM
319 #include <sys/kstat.h>
321 void get_udb_errors(uint64_t *udbh, uint64_t *udbl);
324 * The scrub_misc structure contains miscellaneous bookeepping items for
325 * scrubbing the E$.
327 * Counter of outstanding E$ scrub requests. The counter for a given CPU id
328 * is atomically incremented and decremented _only_ on that CPU,
329 * to avoid cacheline ownership bouncing.
332 typedef struct spitfire_scrub_misc {
333 uint32_t ec_scrub_outstanding; /* outstanding reqs */
334 int ecache_flush_index; /* offset into E$ for flush */
335 int ecache_busy; /* keeps track if cpu busy */
336 int ecache_nlines; /* no. of E$ lines */
337 int ecache_mirror; /* E$ is mirrored */
338 kstat_t *ecache_ksp; /* ptr to the kstat */
339 } spitfire_scrub_misc_t;
342 * Spitfire module private data structure. One of these is allocated for each
343 * valid cpu at setup time and is pointed to by the machcpu "cpu_private"
344 * pointer.
346 typedef struct spitfire_private {
347 spitfire_scrub_misc_t sfpr_scrub_misc;
348 uint64_t sfpr_scrub_afsr;
349 } spitfire_private_t;
351 #endif /* !_ASM */
353 #endif /* _KERNEL */
355 #ifdef __cplusplus
357 #endif
359 #endif /* _SYS_SPITREGS_H */