1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_CHERRYSTONE_H
28 #define	_CHERRYSTONE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * cherrystone.h - Cherrystone common header file
38  *
39  * This header file contains the common definitions and macros for the
40  * Cherrystone platform. We define them all here to avoid them being redefined
41  * in numerous different drivers and daemons.
42  */
43 #define	CHERRYSTONE_SBD_SLOTS		2
44 #define	CHERRYSTONE_CPUS_PER_BOARD	2
45 #define	CHERRYSTONE_MAX_CPUS		(CHERRYSTONE_SBD_SLOTS * \
46 					CHERRYSTONE_CPUS_PER_BOARD)
47 #define	CHERRYSTONE_BANKS_PER_MC	4
48 #define	CHERRYSTONE_MAX_SLICE		(CHERRYSTONE_MAX_CPUS * \
49 
50 /*
51  *   Slot SlotID   Agent ID
52  *   ---- ------  --------
53  *    0     0  <==>  0
54  *    0     1  <==>  2
55  *    1     0  <==>  1
56  *    1     1  <==>  3
57  *    4[*]  -  <==>  8 (Schizo0)
58  *    5[*]  -  <==>  9 (Schizo1)
59  *
60  *    [*] Fake slot numbers used for prtdiag bookkeeping
61  */
62 #define	CHERRYSTONE_GETSLOT(AID)	(((AID&0xc)>>1)|(AID&1))
63 #define	CHERRYSTONE_GETSLOT_LABEL(AID)	('A' + CHERRYSTONE_GETSLOT(AID))
64 #define	CHERRYSTONE_GETSID(AID)		((AID&2)>>1)
65 #define	CHERRYSTONE_GETAID(SLOT, SID)	(((SLOT&2)<<1)|(SLOT&1)|((SID)<<1))
66 
67 /*
68  * These values are taken from Appendices R and U of the UltraSPARC-III
69  * JPS1 Implementation Supplement.
70  */
71 #define	MC_VALID_SHIFT		63
72 #define	MC_UK_SHIFT		41
73 #define	MC_UM_SHIFT		20
74 #define	MC_LK_SHIFT		14
75 #define	MC_LM_SHIFT		8
76 #define	PHYS2UM_SHIFT		26
77 #define	MC_UK(memdec)		(((memdec) >> MC_UK_SHIFT) & 0xfffu)
78 #define	MC_LK(memdec)		(((memdec) >> MC_LK_SHIFT)& 0x3fu)
79 #define	MC_INTLV(memdec)	((~(MC_LK(memdec)) & 0xfu) + 1)
80 #define	MC_UK2SPAN(memdec)	((MC_UK(memdec) + 1) << PHYS2UM_SHIFT)
81 #define	MC_SPANMB(memdec)	(MC_UK2SPAN(memdec) >> 20)
82 #define	MC_UM(memdec)		(((memdec) >> MC_UM_SHIFT) & 0x1fffffu)
83 #define	MC_LM(memdec)		(((memdec) >> MC_LM_SHIFT) & 0x3f)
84 #define	MC_BASE(memdec)		(MC_UM(memdec) & ~(MC_UK(memdec)))
85 #define	MC_BASE2UM(base)	(((base) & 0x1fffffu) << MC_UM_SHIFT)
86 #define	SAF_MASK		0x000007ffff800000ull
87 #define	MC_OFFSET_MASK		0xffu
88 
89 extern uint64_t lddsafaddr(uint64_t physaddr);
90 extern uint64_t lddmcdecode(uint64_t physaddr);
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif /* _CHERRYSTONE_H */
97