xref: /onnv-gate/usr/src/uts/sun4u/cherrystone/sys/cherrystone.h (revision 605:16d50513eb5c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*605Slm66018  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_CHERRYSTONE_H
280Sstevel@tonic-gate #define	_CHERRYSTONE_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /*
370Sstevel@tonic-gate  * cherrystone.h - Cherrystone common header file
380Sstevel@tonic-gate  *
390Sstevel@tonic-gate  * This header file contains the common definitions and macros for the
400Sstevel@tonic-gate  * Cherrystone platform. We define them all here to avoid them being redefined
410Sstevel@tonic-gate  * in numerous different drivers and daemons.
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate #define	CHERRYSTONE_SBD_SLOTS		2
440Sstevel@tonic-gate #define	CHERRYSTONE_CPUS_PER_BOARD	2
450Sstevel@tonic-gate #define	CHERRYSTONE_MAX_CPUS		(CHERRYSTONE_SBD_SLOTS * \
46*605Slm66018 						CHERRYSTONE_CPUS_PER_BOARD)
470Sstevel@tonic-gate #define	CHERRYSTONE_BANKS_PER_MC	4
480Sstevel@tonic-gate #define	CHERRYSTONE_MAX_SLICE		(CHERRYSTONE_MAX_CPUS * \
49*605Slm66018 						CHERRYSTONE_BANKS_PER_MC)
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  *   Slot SlotID   Agent ID
530Sstevel@tonic-gate  *   ---- ------  --------
540Sstevel@tonic-gate  *    0     0  <==>  0
550Sstevel@tonic-gate  *    0     1  <==>  2
560Sstevel@tonic-gate  *    1     0  <==>  1
570Sstevel@tonic-gate  *    1     1  <==>  3
580Sstevel@tonic-gate  *    4[*]  -  <==>  8 (Schizo0)
590Sstevel@tonic-gate  *    5[*]  -  <==>  9 (Schizo1)
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  *    [*] Fake slot numbers used for prtdiag bookkeeping
620Sstevel@tonic-gate  */
630Sstevel@tonic-gate #define	CHERRYSTONE_GETSLOT(AID)	(((AID&0xc)>>1)|(AID&1))
640Sstevel@tonic-gate #define	CHERRYSTONE_GETSLOT_LABEL(AID)	('A' + CHERRYSTONE_GETSLOT(AID))
650Sstevel@tonic-gate #define	CHERRYSTONE_GETSID(AID)		((AID&2)>>1)
660Sstevel@tonic-gate #define	CHERRYSTONE_GETAID(SLOT, SID)	(((SLOT&2)<<1)|(SLOT&1)|((SID)<<1))
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate  * These values are taken from Appendices R and U of the UltraSPARC-III
700Sstevel@tonic-gate  * JPS1 Implementation Supplement.
710Sstevel@tonic-gate  */
720Sstevel@tonic-gate #define	MC_VALID_SHIFT		63
730Sstevel@tonic-gate #define	MC_UK_SHIFT		41
740Sstevel@tonic-gate #define	MC_UM_SHIFT		20
750Sstevel@tonic-gate #define	MC_LK_SHIFT		14
760Sstevel@tonic-gate #define	MC_LM_SHIFT		8
770Sstevel@tonic-gate #define	PHYS2UM_SHIFT		26
780Sstevel@tonic-gate #define	MC_UK(memdec)		(((memdec) >> MC_UK_SHIFT) & 0xfffu)
790Sstevel@tonic-gate #define	MC_LK(memdec)		(((memdec) >> MC_LK_SHIFT)& 0x3fu)
800Sstevel@tonic-gate #define	MC_INTLV(memdec)	((~(MC_LK(memdec)) & 0xfu) + 1)
810Sstevel@tonic-gate #define	MC_UK2SPAN(memdec)	((MC_UK(memdec) + 1) << PHYS2UM_SHIFT)
820Sstevel@tonic-gate #define	MC_SPANMB(memdec)	(MC_UK2SPAN(memdec) >> 20)
830Sstevel@tonic-gate #define	MC_UM(memdec)		(((memdec) >> MC_UM_SHIFT) & 0x1fffffu)
840Sstevel@tonic-gate #define	MC_LM(memdec)		(((memdec) >> MC_LM_SHIFT) & 0x3f)
850Sstevel@tonic-gate #define	MC_BASE(memdec)		(MC_UM(memdec) & ~(MC_UK(memdec)))
860Sstevel@tonic-gate #define	MC_BASE2UM(base)	(((base) & 0x1fffffu) << MC_UM_SHIFT)
870Sstevel@tonic-gate #define	SAF_MASK		0x000007ffff800000ull
880Sstevel@tonic-gate #define	MC_OFFSET_MASK		0xffu
890Sstevel@tonic-gate 
90*605Slm66018 /*
91*605Slm66018  * Cherrystone slices are defined by bits 36..39 of the physical address space
92*605Slm66018  */
93*605Slm66018 
94*605Slm66018 #define	PA_SLICE_SHIFT		(36)
95*605Slm66018 #define	PFN_SLICE_SHIFT		(PA_SLICE_SHIFT - MMU_PAGESHIFT)
96*605Slm66018 #define	PA_2_SLICE(pa)		(((pa) >> PA_SLICE_SHIFT) & \
97*605Slm66018 					CHERRYSTONE_SLICE_MASK)
98*605Slm66018 #define	PFN_2_SLICE(pfn)	(((pfn) >> PFN_SLICE_SHIFT) & \
99*605Slm66018 					CHERRYSTONE_SLICE_MASK)
100*605Slm66018 
101*605Slm66018 /* Define the number of possible slices for the span of slice bits */
102*605Slm66018 #define	CHERRYSTONE_SLICE_MASK		(0xf)
103*605Slm66018 
1040Sstevel@tonic-gate extern uint64_t lddsafaddr(uint64_t physaddr);
1050Sstevel@tonic-gate extern uint64_t lddmcdecode(uint64_t physaddr);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #ifdef	__cplusplus
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate #endif
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate #endif /* _CHERRYSTONE_H */
112