xref: /titanic_51/usr/src/uts/sun4u/starcat/sys/dr_mbx.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2000-2002 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_DR_MBX_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_DR_MBX_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
37*7c478bd9Sstevel@tonic-gate #include <sys/mboxsc.h>
38*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
39*7c478bd9Sstevel@tonic-gate #include <post/scat_const.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /* this version of the DR - SC mailbox interface */
42*7c478bd9Sstevel@tonic-gate #define	DRMBX_VERSION				0x0016
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #define	DR_KEY(a, b, c, d)	\
45*7c478bd9Sstevel@tonic-gate 	(((uint_t)(a) << 24) | ((uint_t)(b) << 16) \
46*7c478bd9Sstevel@tonic-gate 	| ((uint_t)(c) <<  8) | ((uint_t)(d)))
47*7c478bd9Sstevel@tonic-gate #define	KEY_DRSC		DR_KEY('D', 'R', 'S', 'C')
48*7c478bd9Sstevel@tonic-gate #define	KEY_SCDR		DR_KEY('S', 'C', 'D', 'R')
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	DRSC_TIMEOUT		30
51*7c478bd9Sstevel@tonic-gate #define	BD_TYPELEN		16
52*7c478bd9Sstevel@tonic-gate #define	DR_HPOPTLEN		512	/* maximum length of hpost options */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /* Commands */
55*7c478bd9Sstevel@tonic-gate #define	DRMSG_BOARDEVENT	0x1	/* must be 0x1 in every vesion */
56*7c478bd9Sstevel@tonic-gate #define	DRMSG_MBOX_INIT		0x2	/* must be 0x2 in every version */
57*7c478bd9Sstevel@tonic-gate #define	DRMSG_ASSIGN		0x3
58*7c478bd9Sstevel@tonic-gate #define	DRMSG_UNASSIGN		0x4
59*7c478bd9Sstevel@tonic-gate #define	DRMSG_CLAIM		0x5
60*7c478bd9Sstevel@tonic-gate #define	DRMSG_UNCLAIM		0x6
61*7c478bd9Sstevel@tonic-gate #define	DRMSG_POWERON		0x7
62*7c478bd9Sstevel@tonic-gate #define	DRMSG_POWEROFF		0x8
63*7c478bd9Sstevel@tonic-gate #define	DRMSG_TESTBOARD		0x9
64*7c478bd9Sstevel@tonic-gate #define	DRMSG_ABORT_TEST	0xa
65*7c478bd9Sstevel@tonic-gate #define	DRMSG_SHOWBOARD		0xb
66*7c478bd9Sstevel@tonic-gate #define	DRMSG_UNCONFIG		0xc
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /* Test status definitions */
70*7c478bd9Sstevel@tonic-gate #define	DR_TEST_STATUS_UNKNOWN	0x1
71*7c478bd9Sstevel@tonic-gate #define	DR_TEST_STATUS_IPOST	0x2
72*7c478bd9Sstevel@tonic-gate #define	DR_TEST_STATUS_PASSED	0x3
73*7c478bd9Sstevel@tonic-gate #define	DR_TEST_STATUS_FAILED	0x4
74*7c478bd9Sstevel@tonic-gate #define	DR_TEST_STATUS_ABORTED	0x5
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /* Message reply status definitions */
77*7c478bd9Sstevel@tonic-gate #define	DRMSG_REPLY_OK		0x0
78*7c478bd9Sstevel@tonic-gate #define	DRMSG_REPLY_FAIL	0x1
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate /* Error Code definitions */
81*7c478bd9Sstevel@tonic-gate #define	DRERR_NOACL		0x1	/* Board is not in domain's ACL */
82*7c478bd9Sstevel@tonic-gate #define	DRERR_NOT_ASSIGNED	0x2	/* Board isn't assigned to domain */
83*7c478bd9Sstevel@tonic-gate #define	DRERR_NOT_ACTIVE	0x3	/* Board is not active */
84*7c478bd9Sstevel@tonic-gate #define	DRERR_EMPTY_SLOT	0x4	/* The board (slot) is empty */
85*7c478bd9Sstevel@tonic-gate #define	DRERR_POWER_OFF		0x5	/* The specified board is powered off */
86*7c478bd9Sstevel@tonic-gate #define	DRERR_TEST_IN_PROGRESS	0x6	/* The board is being tested */
87*7c478bd9Sstevel@tonic-gate #define	DRERR_TESTING_BUSY	0x7	/* All SC test resources are in use */
88*7c478bd9Sstevel@tonic-gate #define	DRERR_TEST_REQUIRED	0x8	/* Board requires test prior to use */
89*7c478bd9Sstevel@tonic-gate #define	DRERR_UNAVAILABLE	0x9	/* Slot is not available to domain */
90*7c478bd9Sstevel@tonic-gate #define	DRERR_RECOVERABLE	0xa	/* Failed, may safely retry */
91*7c478bd9Sstevel@tonic-gate #define	DRERR_UNRECOVERABLE	0xb	/* Failed, resource unusable */
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  *	Protocol Header and message structure definitions
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /* DR-SC Protocol Header */
98*7c478bd9Sstevel@tonic-gate typedef struct {
99*7c478bd9Sstevel@tonic-gate 	uint32_t	message_id;
100*7c478bd9Sstevel@tonic-gate 	uint16_t	drproto_version;
101*7c478bd9Sstevel@tonic-gate 	uint8_t		command;
102*7c478bd9Sstevel@tonic-gate 	uint8_t		expbrd;
103*7c478bd9Sstevel@tonic-gate 	uint8_t		slot;
104*7c478bd9Sstevel@tonic-gate 	uint8_t		reply_status;
105*7c478bd9Sstevel@tonic-gate 	uint8_t		error_code;
106*7c478bd9Sstevel@tonic-gate 	uint8_t		pad[1];		/* explicit pad to 4 byte alignment */
107*7c478bd9Sstevel@tonic-gate } dr_proto_hdr_t;
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /* Showboard reply structure (from SC) */
110*7c478bd9Sstevel@tonic-gate typedef struct {
111*7c478bd9Sstevel@tonic-gate 	uint8_t		slot_empty	:1,
112*7c478bd9Sstevel@tonic-gate 			power_on	:1,
113*7c478bd9Sstevel@tonic-gate 			bd_assigned	:1,
114*7c478bd9Sstevel@tonic-gate 			bd_active	:1,
115*7c478bd9Sstevel@tonic-gate 			test_status	:4;
116*7c478bd9Sstevel@tonic-gate 	uint8_t		test_level;
117*7c478bd9Sstevel@tonic-gate 	char		board_type[BD_TYPELEN];
118*7c478bd9Sstevel@tonic-gate } dr_showboard_t;
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /* CPU Memory Controller constants and macros */
121*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_VALID_MASK		(0x1ull		<< 63)
122*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_UK_MASK		(0xFFFull	<< 41)
123*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_UM_MASK		(0x1FFFFFull	<< 20)
124*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_LK_MASK		(0xFull		<< 14)
125*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_LM_MASK		(0xFull		<< 8)
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_UK(madr)		(((madr) & DRMACH_MC_UK_MASK) >> 41)
128*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_UM_TO_PA(madr)	(((madr) & DRMACH_MC_UM_MASK) << 6)
129*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_LM_TO_PA(madr)	(((madr) & DRMACH_MC_LM_MASK) >> 2)
130*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_PA_TO_UM(pa)		(((pa) >> 6) & DRMACH_MC_UM_MASK)
131*7c478bd9Sstevel@tonic-gate #define	DRMACH_MC_PA_TO_LM(pa)		(((pa) << 2) & DRMACH_MC_LM_MASK)
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /* Claim/Unclaim/Unconfig request structures */
134*7c478bd9Sstevel@tonic-gate typedef struct {
135*7c478bd9Sstevel@tonic-gate 	uint8_t	valid	:1,
136*7c478bd9Sstevel@tonic-gate 		unused	:2,
137*7c478bd9Sstevel@tonic-gate 		slice	:5;
138*7c478bd9Sstevel@tonic-gate } dr_memslice_t;
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /*
141*7c478bd9Sstevel@tonic-gate  * Since uint64_t can't be used in DR mailbox messages due to alignment and
142*7c478bd9Sstevel@tonic-gate  * backwards compatibility issues, the 64 bit MADR and MACR register values must
143*7c478bd9Sstevel@tonic-gate  * be broken into high and low uint32_t values.
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate #define	DRMACH_MCREG_TO_U64(mcreg)	(((uint64_t)mcreg.hi) << 32 | \
146*7c478bd9Sstevel@tonic-gate 						((uint64_t)mcreg.lo))
147*7c478bd9Sstevel@tonic-gate #define	DRMACH_U64_TO_MCREGHI(u64)	((uint32_t)((u64) >> 32))
148*7c478bd9Sstevel@tonic-gate #define	DRMACH_U64_TO_MCREGLO(u64)	((uint32_t)(u64))
149*7c478bd9Sstevel@tonic-gate typedef struct {
150*7c478bd9Sstevel@tonic-gate 	uint32_t	hi;
151*7c478bd9Sstevel@tonic-gate 	uint32_t	lo;
152*7c478bd9Sstevel@tonic-gate } dr_mcreg_t;
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate /*
155*7c478bd9Sstevel@tonic-gate  * Each expander can contain S0_LPORT_COUNT memory controllers (each CPU has one
156*7c478bd9Sstevel@tonic-gate  * memory controller, and slot 1 doesn't support memory), and each controller
157*7c478bd9Sstevel@tonic-gate  * contains PMBANKS_PER_PORT * LMBANKS_PER_PMBANK (the total number of memory
158*7c478bd9Sstevel@tonic-gate  * banks supported by each controller) MADR registers
159*7c478bd9Sstevel@tonic-gate  */
160*7c478bd9Sstevel@tonic-gate typedef struct {
161*7c478bd9Sstevel@tonic-gate 	dr_mcreg_t	madr[S0_LPORT_COUNT][PMBANKS_PER_PORT *
162*7c478bd9Sstevel@tonic-gate 				LMBANKS_PER_PMBANK];
163*7c478bd9Sstevel@tonic-gate } dr_memregs_t;
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate typedef struct {
166*7c478bd9Sstevel@tonic-gate 	dr_memslice_t	mem_slice[18];
167*7c478bd9Sstevel@tonic-gate 	uint8_t		mem_clear;
168*7c478bd9Sstevel@tonic-gate 	uint8_t		pad[1];		/* explicit pad to 4 byte alignment */
169*7c478bd9Sstevel@tonic-gate 	dr_memregs_t	mem_regs[18];
170*7c478bd9Sstevel@tonic-gate } dr_unclaim_t;
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate typedef struct {
173*7c478bd9Sstevel@tonic-gate 	dr_memslice_t	mem_slice[18];
174*7c478bd9Sstevel@tonic-gate 	uint8_t		pad[2];		/* explicit pad to 4 byte alignment */
175*7c478bd9Sstevel@tonic-gate 	dr_memregs_t	mem_regs[18];
176*7c478bd9Sstevel@tonic-gate } dr_claim_t;
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate typedef struct {
179*7c478bd9Sstevel@tonic-gate 	dr_memslice_t	mem_slice[18];
180*7c478bd9Sstevel@tonic-gate 	uint8_t		pad[2];		/* explicit pad to 4 byte alignment */
181*7c478bd9Sstevel@tonic-gate 	dr_memregs_t	mem_regs[18];
182*7c478bd9Sstevel@tonic-gate } dr_unconfig_t;
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate /* CPU Portid macros */
185*7c478bd9Sstevel@tonic-gate #define	DRMBX_PORTID2EXP(cpu_portid) \
186*7c478bd9Sstevel@tonic-gate 	(((cpu_portid) >> 5) & 0x1F)
187*7c478bd9Sstevel@tonic-gate #define	DRMBX_PORTID2SLOT(cpu_portid) \
188*7c478bd9Sstevel@tonic-gate 	(((((cpu_portid) >> 4) & 0x7E) | (((cpu_portid) >> 3) & 0x01)) & 1)
189*7c478bd9Sstevel@tonic-gate #define	DRMBX_PORTID2AGID(cpu_portid)	((cpu_portid) & 0x1F)
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate /* Test board request structure */
192*7c478bd9Sstevel@tonic-gate typedef struct {
193*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrhi;
194*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrlo;
195*7c478bd9Sstevel@tonic-gate 	uint32_t	memlen;
196*7c478bd9Sstevel@tonic-gate 	uint16_t	cpu_portid;
197*7c478bd9Sstevel@tonic-gate 	uint8_t		force		:1,
198*7c478bd9Sstevel@tonic-gate 			immediate 	:1,
199*7c478bd9Sstevel@tonic-gate 			reserved 	:6;
200*7c478bd9Sstevel@tonic-gate 	char		hpost_opts[DR_HPOPTLEN];
201*7c478bd9Sstevel@tonic-gate } dr_testboard_req_t;
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /* Test board reply structure (from SC) */
204*7c478bd9Sstevel@tonic-gate typedef struct {
205*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrhi;
206*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrlo;
207*7c478bd9Sstevel@tonic-gate 	uint32_t	memlen;
208*7c478bd9Sstevel@tonic-gate 	uint16_t	cpu_portid;
209*7c478bd9Sstevel@tonic-gate 	uint8_t		cpu_recovered	:1,
210*7c478bd9Sstevel@tonic-gate 			test_status 	:4,
211*7c478bd9Sstevel@tonic-gate 			reserved 	:3;
212*7c478bd9Sstevel@tonic-gate } dr_testboard_reply_t;
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /* Test Abort structure (bi-directional) */
215*7c478bd9Sstevel@tonic-gate typedef struct {
216*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrhi;
217*7c478bd9Sstevel@tonic-gate 	uint32_t	memaddrlo;
218*7c478bd9Sstevel@tonic-gate 	uint32_t	memlen;
219*7c478bd9Sstevel@tonic-gate 	uint16_t	cpu_portid;
220*7c478bd9Sstevel@tonic-gate } dr_abort_test_t;
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate /* Board event structure (from SC) */
224*7c478bd9Sstevel@tonic-gate typedef struct {
225*7c478bd9Sstevel@tonic-gate 	uint16_t	initialized	:1,
226*7c478bd9Sstevel@tonic-gate 			board_insertion	:1,
227*7c478bd9Sstevel@tonic-gate 			board_removal	:1,
228*7c478bd9Sstevel@tonic-gate 			slot_assign	:1,
229*7c478bd9Sstevel@tonic-gate 			slot_unassign	:1,
230*7c478bd9Sstevel@tonic-gate 			slot_avail	:1,
231*7c478bd9Sstevel@tonic-gate 			slot_unavail	:1,
232*7c478bd9Sstevel@tonic-gate 			power_on	:1,
233*7c478bd9Sstevel@tonic-gate 			power_off	:1,
234*7c478bd9Sstevel@tonic-gate 			reserved	:7;
235*7c478bd9Sstevel@tonic-gate } dr_boardevent_t;
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate  * NOTE: The structures in this union all require 4 byte alignment or less.  It
239*7c478bd9Sstevel@tonic-gate  * is forbidden to add any structure that requires 8 byte alignment, as doing so
240*7c478bd9Sstevel@tonic-gate  * will alter the dr_mbox_msg_t structure, thereby breaking compatibility with
241*7c478bd9Sstevel@tonic-gate  * older software.  (Since the dr_proto_hdr_t structure is 12 bytes long, it
242*7c478bd9Sstevel@tonic-gate  * can't be followed immediately by an 8 byte aligned structure, and the
243*7c478bd9Sstevel@tonic-gate  * compiler will implicitly insert 4 padding bytes.)
244*7c478bd9Sstevel@tonic-gate  */
245*7c478bd9Sstevel@tonic-gate typedef union {
246*7c478bd9Sstevel@tonic-gate 	dr_showboard_t		dm_sb;
247*7c478bd9Sstevel@tonic-gate 	dr_unclaim_t		dm_ur;
248*7c478bd9Sstevel@tonic-gate 	dr_claim_t		dm_cr;
249*7c478bd9Sstevel@tonic-gate 	dr_unconfig_t		dm_uc;
250*7c478bd9Sstevel@tonic-gate 	dr_testboard_req_t	dm_tb;
251*7c478bd9Sstevel@tonic-gate 	dr_testboard_reply_t	dm_tr;
252*7c478bd9Sstevel@tonic-gate 	dr_abort_test_t		dm_ta;
253*7c478bd9Sstevel@tonic-gate 	dr_boardevent_t		dm_be;
254*7c478bd9Sstevel@tonic-gate } dr_msg_t;
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate typedef struct {
257*7c478bd9Sstevel@tonic-gate 	dr_proto_hdr_t		p_hdr;
258*7c478bd9Sstevel@tonic-gate 	dr_msg_t		msgdata;
259*7c478bd9Sstevel@tonic-gate } dr_mbox_msg_t;
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
262*7c478bd9Sstevel@tonic-gate }
263*7c478bd9Sstevel@tonic-gate #endif
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate #endif /* _SYS_DR_MBX_H */
266