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
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_SERENGETI_H
28 #define _SYS_SERENGETI_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 * serengeti.h - Serengeti/WildCat common header file
39 * This header file contains the common definitions and macros for the
40 * Serengeti and WildCat platforms. We define them all here to avoid them
41 * being redefined in numerous different drivers.
44 #include <sys/dditypes.h>
60 #define SG_MAX_IO_PER_BD 5 /* 4 pci buses + cpci */
61 #define SG_MAX_CMPS_PER_BD 4
62 #define SG_MAX_CPUS_PER_BD 8
63 #define SG_MAX_MEM_PER_BD 1
64 #define SG_MAX_CPU_BDS 6
65 #define SG_MAX_IO_BDS 4
66 #define SG_MAX_POWER_SUPPLIES 6
67 #define SG_MAX_FAN_TRAYS 6
68 #define SG_MAX_REPEATER_BDS 4
69 #define SG_MAX_BDS (SG_MAX_CPU_BDS + SG_MAX_IO_BDS)
70 #define SG_MAX_CPUS (SG_MAX_CPUS_PER_BD * SG_MAX_CPU_BDS)
72 #define SG_MAX_SLOTS_PER_IO_BD 8
73 #define SG_SCHIZO_PER_IO_BD 2
75 #define SSM_MAX_INSTANCES 16
76 #define SSM_MAX_BDS (SSM_MAX_INSTANCES * SG_MAX_BDS)
78 #define SG_MIN_CPU_SAFARI_ID 0 /* 0x00 */
79 #define SG_MAX_CPU_SAFARI_ID 23 /* 0x17 */
80 #define SG_MIN_IO_SAFARI_ID 24 /* 0x18 */
81 #define SG_MAX_IO_SAFARI_ID 31 /* 0x1F */
85 * possible states for the Keyswitch Position.
87 #define SG_KEYSWITCH_POSN_UNKNOWN (-1)
88 #define SG_KEYSWITCH_POSN_ON 2
89 #define SG_KEYSWITCH_POSN_DIAG 3
90 #define SG_KEYSWITCH_POSN_SECURE 4
99 /* we only need the 5 LSB of the portid to calculate the board number */
100 #define SG_SAFARI_ID_MASK 0x1F /* 5 bits */
101 #define SG_CPU_ID_MASK 0x21F /* bit 9 and bits 0-4 */
102 #define SG_CORE_ID_MASK 0x200 /* bit 9 */
103 #define SG_NODE_MASK 0x0F /* 4 bits */
104 #define SG_PORTID_NODE_SHIFT 5
107 * For Serengeti and WildCat the portid consists of 10 bits.
109 * [9] [8 -------- 5][4 --------- 0]
111 * |___ Used in CMP to identify core 1. Unused with non-CMP.
114 * Aid <4:2> : Board ID/Number
117 * (Aid <4:0> - 24) / 2 + 6 : Board ID/Number
118 * (Aid <4:0> - 24) % 2 : Schizo ID
122 * For Jaguar there are two CPU IDs the can be derived from portid
123 * and coreid. On Serengeti, bit 9 is set for core 1, resulting in
124 * the cpuid for core 1 being 512 off from the one for core 0.
126 #define SG_JG_CORE1_SHIFT 9
127 #define SG_JG_CORE1_OFFSET (1 << SG_JG_CORE1_SHIFT)
128 #define SG_PORTID_TO_CPUID(p, c) ((p) + ((c) << SG_JG_CORE1_SHIFT))
129 #define SG_PORTID_TO_CPU_UNIT(p, c) ((p % SG_MAX_CMPS_PER_BD) | \
130 ((c) * SG_MAX_CMPS_PER_BD))
131 #define SG_CPUID_TO_PORTID(c) ((c) & SG_SAFARI_ID_MASK)
132 #define SG_CPUID_TO_COREID(c) (((c) & SG_CORE_ID_MASK) >> \
134 #define SG_CPUID_TO_CPU_UNIT(c) SG_PORTID_TO_CPU_UNIT( \
135 SG_CPUID_TO_PORTID(c), \
136 SG_CPUID_TO_COREID(c))
139 * SG_PORTID_TO_NODEID
141 * Calculates the SSM NodeID from the portid
143 #define SG_PORTID_TO_NODEID(portid) (((portid) >> SG_PORTID_NODE_SHIFT) & \
147 * SG_PORTID_TO_SAFARI_ID
149 * Calculates the Safari Agent ID from the portid.
151 #define SG_PORTID_TO_SAFARI_ID(portid) ((portid) & SG_SAFARI_ID_MASK)
155 * SG_PORTID_TO_BOARD_NUM
157 * If a valid portid is passed in, this macro returns the board number
158 * associated with it, otherwise it returns -1.
160 #define SG_PORTID_TO_BOARD_NUM(portid) \
161 ((SG_PORTID_IS_CPU_TYPE(portid)) ? \
162 (SG_CPU_BD_PORTID_TO_BD_NUM(portid)) : \
163 ((SG_PORTID_IS_IO_TYPE(portid)) ? \
164 SG_IO_BD_PORTID_TO_BD_NUM(portid) : (-1)))
167 * SG_BOARD_IS_CPU_TYPE
169 * If the board number of a board of CPU type is passed in, TRUE is returned,
172 #define SG_BOARD_IS_CPU_TYPE(board_num) \
173 ((((board_num) >= 0) && ((board_num) < SG_MAX_CPU_BDS)) ? TRUE: FALSE)
176 * SG_BOARD_IS_IO_TYPE
178 * If the board number of a board of IO type is passed in, TRUE is returned,
181 #define SG_BOARD_IS_IO_TYPE(board_num) \
182 ((((board_num) >= SG_MAX_CPU_BDS) && \
183 ((board_num) < SG_MAX_BDS)) ? TRUE: FALSE)
186 * SG_PORTID_IS_CPU_TYPE
188 * If the portid associated with a CPU board is passed in, TRUE is returned,
191 #define SG_PORTID_IS_CPU_TYPE(portid) \
192 (((((portid) & SG_SAFARI_ID_MASK) >= SG_MIN_CPU_SAFARI_ID) && \
193 (((portid) & SG_SAFARI_ID_MASK) <= SG_MAX_CPU_SAFARI_ID)) ? TRUE: FALSE)
196 * SG_PORTID_IS_IO_TYPE
198 * If the portid associated with an IO board is passed in, TRUE is returned,
201 #define SG_PORTID_IS_IO_TYPE(portid) \
202 (((((portid) & SG_SAFARI_ID_MASK) >= SG_MIN_IO_SAFARI_ID) && \
203 (((portid) & SG_SAFARI_ID_MASK) <= SG_MAX_IO_SAFARI_ID)) ? TRUE: FALSE)
206 * SG_CPU_BD_PORTID_TO_BD_NUM
208 * If the portid associated with a CPU board is passed in, the board number
209 * associated with this portid is returned, otherwise -1.
211 #define SG_CPU_BD_PORTID_TO_BD_NUM(portid) \
212 ((SG_PORTID_IS_CPU_TYPE(portid)) ? \
213 (((portid) & SG_SAFARI_ID_MASK) / 4) : (-1))
216 * SG_IO_BD_PORTID_TO_BD_NUM
218 * If the portid associated with an IO board is passed in, the board number
219 * associated with this portid is returned, otherwise -1.
221 #define SG_IO_BD_PORTID_TO_BD_NUM(portid) \
222 (SG_PORTID_IS_IO_TYPE(portid) ? \
223 (((((portid) & SG_SAFARI_ID_MASK) - 24) / 2) + 6) : (-1))
226 * SG_PORTID_TO_CPU_POSN
228 * If the portid associated with a CPU board is passed in, the position
229 * of the CPU module for this portid is returned, otherwise -1.
231 #define SG_PORTID_TO_CPU_POSN(portid) \
232 ((SG_PORTID_IS_CPU_TYPE(portid)) ? \
233 (((portid) & SG_SAFARI_ID_MASK) % 4) : (-1))
236 * Serengeti slices are defined by bits 34..41 of the physical address
237 * space, and can contain Safari agent ID bits depending upon the SC
238 * firmware being used.
241 #define PA_SLICE_SHIFT (34)
242 #define PFN_SLICE_SHIFT (PA_SLICE_SHIFT - MMU_PAGESHIFT)
243 #define PA_2_SLICE(pa) (((pa) >> PA_SLICE_SHIFT) & SG_SLICE_MASK)
244 #define PFN_2_SLICE(pfn) (((pfn) >> PFN_SLICE_SHIFT) & SG_SLICE_MASK)
246 /* Define the max memory banks per CPU board */
247 #define SG_MAX_BANKS_PER_MC (4)
249 /* Define the number of possible slices for the span of slice bits */
250 #define SG_SLICE_MASK (0xff)
251 #define SG_MAX_SLICE (SG_SLICE_MASK + 1)
254 * b represents the SB and c represents the processor (P)
255 * in relation to the SB.
257 #define MAKE_CPUID(b, c) ((b*4) + c)
259 /* Each physical CPU has 2 ecache DIMMs */
260 #define SG_NUM_ECACHE_DIMMS_PER_CPU 2
262 /* Bit 4 of the physical address indicates ecache dimm 0 or 1 */
263 #define SG_ECACHE_DIMM_SHIFT 4
264 #define SG_ECACHE_DIMM_MASK 0x10
266 extern dev_info_t
*find_chosen_dip(void);
268 extern int sg_get_prom_version(int *sysp
, int *intfp
, int *bldp
);
269 extern int sg_prom_sb_dr_check(void);
270 extern int sg_prom_cpci_dr_check(void);
271 extern int sg_get_ecacheunum(int cpuid
, uint64_t physaddr
, char *buf
,
272 uint_t buflen
, int *lenp
);
278 #endif /* _SYS_SERENGETI_H */