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