xref: /illumos-gate/usr/src/uts/sun4u/cherrystone/sys/cherrystone.h (revision 3d393ee6c37fa10ac512ed6d36109ad616dc7c1a)
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 2005 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 						CHERRYSTONE_BANKS_PER_MC)
50 
51 /*
52  *   Slot SlotID   Agent ID
53  *   ---- ------  --------
54  *    0     0  <==>  0
55  *    0     1  <==>  2
56  *    1     0  <==>  1
57  *    1     1  <==>  3
58  *    4[*]  -  <==>  8 (Schizo0)
59  *    5[*]  -  <==>  9 (Schizo1)
60  *
61  *    [*] Fake slot numbers used for prtdiag bookkeeping
62  */
63 #define	CHERRYSTONE_GETSLOT(AID)	(((AID&0xc)>>1)|(AID&1))
64 #define	CHERRYSTONE_GETSLOT_LABEL(AID)	('A' + CHERRYSTONE_GETSLOT(AID))
65 #define	CHERRYSTONE_GETSID(AID)		((AID&2)>>1)
66 #define	CHERRYSTONE_GETAID(SLOT, SID)	(((SLOT&2)<<1)|(SLOT&1)|((SID)<<1))
67 
68 /*
69  * These values are taken from Appendices R and U of the UltraSPARC-III
70  * JPS1 Implementation Supplement.
71  */
72 #define	MC_VALID_SHIFT		63
73 #define	MC_UK_SHIFT		41
74 #define	MC_UM_SHIFT		20
75 #define	MC_LK_SHIFT		14
76 #define	MC_LM_SHIFT		8
77 #define	PHYS2UM_SHIFT		26
78 #define	MC_UK(memdec)		(((memdec) >> MC_UK_SHIFT) & 0xfffu)
79 #define	MC_LK(memdec)		(((memdec) >> MC_LK_SHIFT)& 0x3fu)
80 #define	MC_INTLV(memdec)	((~(MC_LK(memdec)) & 0xfu) + 1)
81 #define	MC_UK2SPAN(memdec)	((MC_UK(memdec) + 1) << PHYS2UM_SHIFT)
82 #define	MC_SPANMB(memdec)	(MC_UK2SPAN(memdec) >> 20)
83 #define	MC_UM(memdec)		(((memdec) >> MC_UM_SHIFT) & 0x1fffffu)
84 #define	MC_LM(memdec)		(((memdec) >> MC_LM_SHIFT) & 0x3f)
85 #define	MC_BASE(memdec)		(MC_UM(memdec) & ~(MC_UK(memdec)))
86 #define	MC_BASE2UM(base)	(((base) & 0x1fffffu) << MC_UM_SHIFT)
87 #define	SAF_MASK		0x000007ffff800000ull
88 #define	MC_OFFSET_MASK		0xffu
89 
90 /*
91  * Cherrystone slices are defined by bits 36..39 of the physical address space
92  */
93 
94 #define	PA_SLICE_SHIFT		(36)
95 #define	PFN_SLICE_SHIFT		(PA_SLICE_SHIFT - MMU_PAGESHIFT)
96 #define	PA_2_SLICE(pa)		(((pa) >> PA_SLICE_SHIFT) & \
97 					CHERRYSTONE_SLICE_MASK)
98 #define	PFN_2_SLICE(pfn)	(((pfn) >> PFN_SLICE_SHIFT) & \
99 					CHERRYSTONE_SLICE_MASK)
100 
101 /* Define the number of possible slices for the span of slice bits */
102 #define	CHERRYSTONE_SLICE_MASK		(0xf)
103 
104 extern uint64_t lddsafaddr(uint64_t physaddr);
105 extern uint64_t lddmcdecode(uint64_t physaddr);
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif /* _CHERRYSTONE_H */
112