xref: /titanic_51/usr/src/uts/sun4u/starfire/sys/idn_sigb.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 (c) 1999-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  * Inter-Domain Network Sigblock Interface.
27*7c478bd9Sstevel@tonic-gate  *
28*7c478bd9Sstevel@tonic-gate  * ******************************************************
29*7c478bd9Sstevel@tonic-gate  * ******************************************************
30*7c478bd9Sstevel@tonic-gate  * IMPORTANT:	THE DEFINITIONS HERE ARE DUPLICATES OF
31*7c478bd9Sstevel@tonic-gate  *		THE cbe_idn_sigb.h FILE IN cbe/cbutils.
32*7c478bd9Sstevel@tonic-gate  *		ANY CHANGES THERE MUST BE RELECTED
33*7c478bd9Sstevel@tonic-gate  *		HERE AND VICE VERSA.  WE CANNOT INCLUDE
34*7c478bd9Sstevel@tonic-gate  *		THIS HEADER IN THE BUILD OF CBE.
35*7c478bd9Sstevel@tonic-gate  * ******************************************************
36*7c478bd9Sstevel@tonic-gate  * ******************************************************
37*7c478bd9Sstevel@tonic-gate  */
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifndef _SYS_IDN_SIGB_H
40*7c478bd9Sstevel@tonic-gate #define	_SYS_IDN_SIGB_H
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
47*7c478bd9Sstevel@tonic-gate extern "C" {
48*7c478bd9Sstevel@tonic-gate #endif
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #ifdef _SSP
51*7c478bd9Sstevel@tonic-gate #include <domain_config.h>
52*7c478bd9Sstevel@tonic-gate #include <sigblock.h>
53*7c478bd9Sstevel@tonic-gate #define	_MAX_DOMAINS	MAX_DOMAINS_PER_MACH
54*7c478bd9Sstevel@tonic-gate #else /* _SSP */
55*7c478bd9Sstevel@tonic-gate #include <sys/starfire.h>
56*7c478bd9Sstevel@tonic-gate #include <sys/cpu_sgnblk_defs.h>
57*7c478bd9Sstevel@tonic-gate #include <sys/cpu_sgn.h>
58*7c478bd9Sstevel@tonic-gate #define	MAX_BOARDS	STARFIRE_MAX_BOARDS
59*7c478bd9Sstevel@tonic-gate #define	MAX_DOMAINS	MAX_BOARDS
60*7c478bd9Sstevel@tonic-gate #define	_MAX_DOMAINS	MAX_DOMAINS
61*7c478bd9Sstevel@tonic-gate #endif /* _SSP */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #define	SSI_LINK	(('I' << 8) | 0x01)
64*7c478bd9Sstevel@tonic-gate #define	SSI_UNLINK	(('I' << 8) | 0x02)
65*7c478bd9Sstevel@tonic-gate #define	SSI_INFO	(('I' << 8) | 0x03)
66*7c478bd9Sstevel@tonic-gate #define	SSI_ACK		0x10
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	VALID_IDNSIGBCMD(c)	((((c) & ~SSI_ACK) == SSI_LINK) || \
69*7c478bd9Sstevel@tonic-gate 				(((c) & ~SSI_ACK) == SSI_UNLINK) || \
70*7c478bd9Sstevel@tonic-gate 				(((c) & ~SSI_ACK) == SSI_INFO))
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * SSI_LINK
74*7c478bd9Sstevel@tonic-gate  * timeout field must be first.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate typedef struct {
77*7c478bd9Sstevel@tonic-gate 	int32_t		timeout;	/* seconds */
78*7c478bd9Sstevel@tonic-gate 	int32_t		cpuid;
79*7c478bd9Sstevel@tonic-gate 	int32_t		domid;
80*7c478bd9Sstevel@tonic-gate 	int32_t		master_pri;
81*7c478bd9Sstevel@tonic-gate } idnsb_link_t;
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /*
85*7c478bd9Sstevel@tonic-gate  * SSI_UNLINK
86*7c478bd9Sstevel@tonic-gate  * timeout field must be first.
87*7c478bd9Sstevel@tonic-gate  *
88*7c478bd9Sstevel@tonic-gate  * If both cpuid and domid are specified then they must match the
89*7c478bd9Sstevel@tonic-gate  * correct domain from the local domain's perspective.  The cpuid
90*7c478bd9Sstevel@tonic-gate  * and/or domid have precedence over the boardset parameter.
91*7c478bd9Sstevel@tonic-gate  * The boardset parameter is provided if the caller is unable to
92*7c478bd9Sstevel@tonic-gate  * determine the cpuid/domid of the target domain.  This may happen
93*7c478bd9Sstevel@tonic-gate  * if the target domain is currently down.
94*7c478bd9Sstevel@tonic-gate  *
95*7c478bd9Sstevel@tonic-gate  * idnsb_unlink_t.force values.
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate #define	SSIFORCE_OFF	0
98*7c478bd9Sstevel@tonic-gate #define	SSIFORCE_SOFT	1
99*7c478bd9Sstevel@tonic-gate #define	SSIFORCE_HARD	2
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate typedef struct {
102*7c478bd9Sstevel@tonic-gate 	int32_t		timeout;	/* seconds */
103*7c478bd9Sstevel@tonic-gate 	int32_t		cpuid;
104*7c478bd9Sstevel@tonic-gate 	int32_t		domid;
105*7c478bd9Sstevel@tonic-gate 	ushort_t	boardset;
106*7c478bd9Sstevel@tonic-gate 	short		force;
107*7c478bd9Sstevel@tonic-gate 	ushort_t	idnset;
108*7c478bd9Sstevel@tonic-gate } idnsb_unlink_t;
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate /*
112*7c478bd9Sstevel@tonic-gate  * SSI_INFO
113*7c478bd9Sstevel@tonic-gate  *	Assumes max of 16 boards/domain.
114*7c478bd9Sstevel@tonic-gate  *
115*7c478bd9Sstevel@tonic-gate  * idnsb_info_t.idn_active values.
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate #define	SSISTATE_INACTIVE	0
118*7c478bd9Sstevel@tonic-gate #define	SSISTATE_BUSY		1
119*7c478bd9Sstevel@tonic-gate #define	SSISTATE_ACTIVE		2
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate typedef struct {
122*7c478bd9Sstevel@tonic-gate 	ushort_t	domain_boardset[_MAX_DOMAINS];
123*7c478bd9Sstevel@tonic-gate 	uchar_t		idn_active;
124*7c478bd9Sstevel@tonic-gate 	uchar_t		idn_state;	/* same as GSTATE */
125*7c478bd9Sstevel@tonic-gate 	uchar_t		local_index;
126*7c478bd9Sstevel@tonic-gate 	uchar_t		local_cpuid;
127*7c478bd9Sstevel@tonic-gate 	uchar_t		master_index;
128*7c478bd9Sstevel@tonic-gate 	uchar_t		master_cpuid;
129*7c478bd9Sstevel@tonic-gate 	ushort_t	awol_domset;
130*7c478bd9Sstevel@tonic-gate 	ushort_t	conn_domset;
131*7c478bd9Sstevel@tonic-gate 	ushort_t	_filler;
132*7c478bd9Sstevel@tonic-gate } idnsb_info_t;
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate #define	INIT_IDNKERR(ep) \
135*7c478bd9Sstevel@tonic-gate 		(bzero((caddr_t)(ep), sizeof (idnsb_error_t)))
136*7c478bd9Sstevel@tonic-gate #define	SET_IDNKERR_ERRNO(ep, err)	((ep)->k_errno = (int)(err))
137*7c478bd9Sstevel@tonic-gate #define	SET_IDNKERR_IDNERR(ep, err)	((ep)->k_idnerr = (int)(err))
138*7c478bd9Sstevel@tonic-gate #define	SET_IDNKERR_PARAM0(ep, p0)	((ep)->k_param[0] = (uint_t)(p0))
139*7c478bd9Sstevel@tonic-gate #define	SET_IDNKERR_PARAM1(ep, p1)	((ep)->k_param[1] = (uint_t)(p1))
140*7c478bd9Sstevel@tonic-gate #define	SET_IDNKERR_PARAM2(ep, p2)	((ep)->k_param[2] = (uint_t)(p2))
141*7c478bd9Sstevel@tonic-gate #define	GET_IDNKERR_ERRNO(ep)		((ep)->k_errno)
142*7c478bd9Sstevel@tonic-gate #define	GET_IDNKERR_IDNERR(ep)		((ep)->k_idnerr)
143*7c478bd9Sstevel@tonic-gate #define	GET_IDNKERR_PARAM0(ep)		((ep)->k_param[0])
144*7c478bd9Sstevel@tonic-gate #define	GET_IDNKERR_PARAM1(ep)		((ep)->k_param[1])
145*7c478bd9Sstevel@tonic-gate #define	GET_IDNKERR_PARAM2(ep)		((ep)->k_param[2])
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate #define	IDNKERR_DRV_DISABLED	0x100	/* IDN driver disabled */
148*7c478bd9Sstevel@tonic-gate 					/* param=none */
149*7c478bd9Sstevel@tonic-gate #define	IDNKERR_DATA_LEN	0x101	/* invalid length of idnsb_data_t */
150*7c478bd9Sstevel@tonic-gate 					/* p0=length */
151*7c478bd9Sstevel@tonic-gate #define	IDNKERR_INFO_FAILED	0x102	/* SSI_INFO failed */
152*7c478bd9Sstevel@tonic-gate 					/* param=none */
153*7c478bd9Sstevel@tonic-gate #define	IDNKERR_INVALID_DOMAIN	0x103	/* invalid domain specified */
154*7c478bd9Sstevel@tonic-gate 					/* p0=domid, p1=cpuid */
155*7c478bd9Sstevel@tonic-gate #define	IDNKERR_INVALID_FORCE	0x104	/* invalid force option specified */
156*7c478bd9Sstevel@tonic-gate 					/* p0=force */
157*7c478bd9Sstevel@tonic-gate #define	IDNKERR_INVALID_CMD	0x105	/* invalid IDN/SSI command req */
158*7c478bd9Sstevel@tonic-gate 					/* p0=cmd */
159*7c478bd9Sstevel@tonic-gate #define	IDNKERR_INVALID_WTIME	0x106	/* invalid waittime specified */
160*7c478bd9Sstevel@tonic-gate 					/* p0=waittime */
161*7c478bd9Sstevel@tonic-gate #define	IDNKERR_SMR_CORRUPTED	0x107	/* SMR memory is corrupted */
162*7c478bd9Sstevel@tonic-gate 					/* p0=domid (against who detected) */
163*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CPU_CONFIG	0x108	/* missing a cpu per board */
164*7c478bd9Sstevel@tonic-gate 					/* p0=domid */
165*7c478bd9Sstevel@tonic-gate #define	IDNKERR_HW_ERROR	0x109	/* error programming hardware */
166*7c478bd9Sstevel@tonic-gate 					/* p0=domid */
167*7c478bd9Sstevel@tonic-gate #define	IDNKERR_SIGBINTR_LOCKED	0x10a	/* sigbintr is locked */
168*7c478bd9Sstevel@tonic-gate #define	IDNKERR_SIGBINTR_BUSY	0x10b	/* sigbintr is busy working */
169*7c478bd9Sstevel@tonic-gate #define	IDNKERR_SIGBINTR_NOTRDY	0x10c	/* sigbintr thread not ready */
170*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_FATAL	0x10d	/* fatal error during config */
171*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_MULTIPLE	0x10e	/* multiple config conflicts */
172*7c478bd9Sstevel@tonic-gate 					/* p0=domid, p1=count */
173*7c478bd9Sstevel@tonic-gate 	/*
174*7c478bd9Sstevel@tonic-gate 	 * For all CONFIG errors:
175*7c478bd9Sstevel@tonic-gate 	 *	p0=domid, p1=expected, p2=actual.
176*7c478bd9Sstevel@tonic-gate 	 */
177*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_MTU	0x10f	/* MTU configs conflict */
178*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_BUF	0x110	/* SMR_BUF_SIZE conflicts */
179*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_SLAB	0x111	/* slab-size conflicts */
180*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_NWR	0x112	/* NWR sizes conflict */
181*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_NETS	0x113	/* MAX_NETS conflict */
182*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_MBOX	0x114	/* MBOX_PER_NETS conflict */
183*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_NMCADR	0x115	/* Number of MCADRS conflicts */
184*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_MCADR	0x116	/* Missing MCADR */
185*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_CKSUM	0x117	/* checksum setting conflicts */
186*7c478bd9Sstevel@tonic-gate #define	IDNKERR_CONFIG_SMR	0x118	/* master's SMR too large */
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate typedef struct {
189*7c478bd9Sstevel@tonic-gate 	int		k_errno;
190*7c478bd9Sstevel@tonic-gate 	int		k_idnerr;
191*7c478bd9Sstevel@tonic-gate 	uint_t		k_param[3];
192*7c478bd9Sstevel@tonic-gate } idnsb_error_t;
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate typedef struct {
195*7c478bd9Sstevel@tonic-gate 	union {
196*7c478bd9Sstevel@tonic-gate 		int		_ssb_timeout;	/* link & unlink only (secs) */
197*7c478bd9Sstevel@tonic-gate 		idnsb_link_t	_ssb_link;
198*7c478bd9Sstevel@tonic-gate 		idnsb_unlink_t	_ssb_unlink;
199*7c478bd9Sstevel@tonic-gate 		idnsb_info_t	_ssb_info;
200*7c478bd9Sstevel@tonic-gate 	} _u;
201*7c478bd9Sstevel@tonic-gate 	idnsb_error_t	ssb_error;
202*7c478bd9Sstevel@tonic-gate } idnsb_data_t;
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #define	ssb_timeout	_u._ssb_timeout
205*7c478bd9Sstevel@tonic-gate #define	ssb_link	_u._ssb_link
206*7c478bd9Sstevel@tonic-gate #define	ssb_unlink	_u._ssb_unlink
207*7c478bd9Sstevel@tonic-gate #define	ssb_info	_u._ssb_info
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate /*
211*7c478bd9Sstevel@tonic-gate  * Boot information set by IDN driver when loaded.
212*7c478bd9Sstevel@tonic-gate  * SSIEVENT_BOOT Indicates IDN driver is ready for linking.
213*7c478bd9Sstevel@tonic-gate  *		 If this nibble is cleared (0) it
214*7c478bd9Sstevel@tonic-gate  *		 indicates domain has halted.
215*7c478bd9Sstevel@tonic-gate  * SSIEVENT_AWOL Indicates local IDN has reported
216*7c478bd9Sstevel@tonic-gate  *		 some domains (boards) have gone AWOL.
217*7c478bd9Sstevel@tonic-gate  * (event_handled) is primarily used by SSP/CB applications for
218*7c478bd9Sstevel@tonic-gate  * synchronization with respect to handling event triggered in (event).
219*7c478bd9Sstevel@tonic-gate  * The respective bits from (event) are set in (event_handled)
220*7c478bd9Sstevel@tonic-gate  * when the event has been successfully processed by IDNevent(SSP).
221*7c478bd9Sstevel@tonic-gate  * It is cleared by CBE based TCL scripts (mon_signatures.tcl, idn.tcl)
222*7c478bd9Sstevel@tonic-gate  * when event is detected and needs processing.
223*7c478bd9Sstevel@tonic-gate  * SSIEVENT_VERSION represents the version of the SSP side of
224*7c478bd9Sstevel@tonic-gate  * the IDN software.  While idnsb_event_t.version represents the
225*7c478bd9Sstevel@tonic-gate  * version of the OS side of the IDN software.
226*7c478bd9Sstevel@tonic-gate  *
227*7c478bd9Sstevel@tonic-gate  * Protocol:	Host				SSP
228*7c478bd9Sstevel@tonic-gate  *		----				---
229*7c478bd9Sstevel@tonic-gate  *		event
230*7c478bd9Sstevel@tonic-gate  *		- 1 -> evt[].e_handled
231*7c478bd9Sstevel@tonic-gate  *		- X -> evt[].e_event
232*7c478bd9Sstevel@tonic-gate  *		- Y -> evt[].e_event_data
233*7c478bd9Sstevel@tonic-gate  *		- 0 -> evt[].e_handled
234*7c478bd9Sstevel@tonic-gate  *					(!evt[].e_handled)
235*7c478bd9Sstevel@tonic-gate  *					...process(evt[].e_event)
236*7c478bd9Sstevel@tonic-gate  *					- evt[].e_handled_data =
237*7c478bd9Sstevel@tonic-gate  *							evt[].e_event_data
238*7c478bd9Sstevel@tonic-gate  *					- evt[].e_handled = 1
239*7c478bd9Sstevel@tonic-gate  */
240*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_COOKIE		"IDN"
241*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_COOKIE_LEN	3
242*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_VERSION	1
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_BOOT		0	/* index to evt[] */
245*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_BOOT_VAL	0xb
246*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_BOOT_SHIFT	(SSIEVENT_BOOT << 2)
247*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_BOOT_MASK	(_SSIEVENT_BOOT_VAL << _SSIEVENT_BOOT_SHIFT)
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_AWOL		1
250*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_AWOL_VAL	0xa
251*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_AWOL_SHIFT	(SSIEVENT_AWOL << 2)
252*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_AWOL_MASK	(_SSIEVENT_AWOL_VAL << _SSIEVENT_AWOL_SHIFT)
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_NUM		2	/* actual max simultaneous events */
255*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_MAXNUM		3	/* last one in reserve */
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_VALUE(i) \
258*7c478bd9Sstevel@tonic-gate 	((i == 0) ? _SSIEVENT_BOOT_VAL : ((i == 1) ? _SSIEVENT_AWOL_VAL : 0))
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate #define	_SSIEVENT_MASKS(i) \
261*7c478bd9Sstevel@tonic-gate 	((i == 0) ? _SSIEVENT_BOOT_MASK : ((i == 1) ? _SSIEVENT_AWOL_MASK : 0))
262*7c478bd9Sstevel@tonic-gate /*
263*7c478bd9Sstevel@tonic-gate  * Get a bitmask of the current "state".
264*7c478bd9Sstevel@tonic-gate  */
265*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_GET_STATE_MASK(s) \
266*7c478bd9Sstevel@tonic-gate 	(((s).idn_evt[SSIEVENT_BOOT].e_event ? _SSIEVENT_BOOT_MASK : 0) \
267*7c478bd9Sstevel@tonic-gate 	| ((s).idn_evt[SSIEVENT_AWOL].e_event ? _SSIEVENT_AWOL_MASK : 0))
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_GET_STATE(s, e) \
270*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_event ? _SSIEVENT_VALUE(e) : 0)
271*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CLR_STATE(s, e) \
272*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_event = 0)
273*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_SET_STATE(s, e) \
274*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_event = _SSIEVENT_VALUE(e))
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate /*
277*7c478bd9Sstevel@tonic-gate  * Get a bitmask of the currently handled states.
278*7c478bd9Sstevel@tonic-gate  */
279*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_GET_HANDLED_MASK(s) \
280*7c478bd9Sstevel@tonic-gate 	(((s).idn_evt[SSIEVENT_BOOT].e_handled ? _SSIEVENT_BOOT_MASK : 0) \
281*7c478bd9Sstevel@tonic-gate 	| ((s).idn_evt[SSIEVENT_AWOL].e_handled ? _SSIEVENT_AWOL_MASK : 0))
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_GET_HANDLED(s, e) \
284*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_handled ? _SSIEVENT_VALUE(e) : 0)
285*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CLR_HANDLED(s, e) \
286*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_handled = 0)
287*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_SET_HANDLED(s, e) \
288*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_handled = _SSIEVENT_VALUE(e))
289*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_SET_HANDLED_DATA(s, e, d) \
290*7c478bd9Sstevel@tonic-gate 			((s).idn_evt[e].e_handled_data = (ushort_t)(d))
291*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_GET_HANDLED_EVT(i, e) \
292*7c478bd9Sstevel@tonic-gate 				((i).e_handled ? _SSIEVENT_VALUE(e) : 0)
293*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CLR_HANDLED_EVT(i)	((i).e_handled = 0)
294*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_SET_HANDLED_EVT(i, e)	((i).e_handled = _SSIEVENT_VALUE(e))
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate  * Check for the state of a particular event within a state bitmask.
298*7c478bd9Sstevel@tonic-gate  */
299*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CHK_STATE_MASK(m, e) \
300*7c478bd9Sstevel@tonic-gate 	((((m) & (0xf << ((e) << 2))) == _SSIEVENT_MASKS(e)) ? 1 : 0)
301*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CHK_HANDLED_MASK(m, e)	SSIEVENT_CHK_STATE_MASK((m), (e))
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate /*
304*7c478bd9Sstevel@tonic-gate  * Build the state mask managed in the cbe to represent the state
305*7c478bd9Sstevel@tonic-gate  * of the respective events above.
306*7c478bd9Sstevel@tonic-gate  */
307*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_DEL_STATE_MASK(m, e)	((m) &= ~(0xf << ((e) << 2)))
308*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_ADD_STATE_MASK(m, e) \
309*7c478bd9Sstevel@tonic-gate 		(SSIEVENT_DEL_STATE_MASK((m), (e)), \
310*7c478bd9Sstevel@tonic-gate 		((m) |= _SSIEVENT_MASKS(e)))
311*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_STATE_MASK	(_SSIEVENT_BOOT_MASK | _SSIEVENT_AWOL_MASK)
312*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_STATE_NIL	0
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
315*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_SET(s, e, d) { \
316*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_HANDLED(*(s), (e)); \
317*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
318*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_STATE(*(s), (e)); \
319*7c478bd9Sstevel@tonic-gate 		(s)->idn_evt[e].e_event_data = (ushort_t)(d); \
320*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
321*7c478bd9Sstevel@tonic-gate 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
322*7c478bd9Sstevel@tonic-gate }
323*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_CLEAR(s, e, d) { \
324*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_HANDLED(*(s), (e)); \
325*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
326*7c478bd9Sstevel@tonic-gate 		SSIEVENT_CLR_STATE(*(s), (e)); \
327*7c478bd9Sstevel@tonic-gate 		(s)->idn_evt[e].e_event_data &= (ushort_t)~(d); \
328*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
329*7c478bd9Sstevel@tonic-gate 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
330*7c478bd9Sstevel@tonic-gate }
331*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_ADD(s, e, d) { \
332*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_HANDLED(*(s), (e)); \
333*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
334*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_STATE(*(s), (e)); \
335*7c478bd9Sstevel@tonic-gate 		(s)->idn_evt[e].e_event_data |= (ushort_t)(d); \
336*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
337*7c478bd9Sstevel@tonic-gate 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
338*7c478bd9Sstevel@tonic-gate }
339*7c478bd9Sstevel@tonic-gate #define	SSIEVENT_DEL(s, e, d) { \
340*7c478bd9Sstevel@tonic-gate 		SSIEVENT_SET_HANDLED(*(s), (e)); \
341*7c478bd9Sstevel@tonic-gate 		membar_stst_stld(); \
342*7c478bd9Sstevel@tonic-gate 		(s)->idn_evt[e].e_event_data &= (ushort_t)~(d); \
343*7c478bd9Sstevel@tonic-gate 		if ((s)->idn_evt[e].e_event_data != 0) { \
344*7c478bd9Sstevel@tonic-gate 			SSIEVENT_SET_STATE(*(s), (e)); \
345*7c478bd9Sstevel@tonic-gate 			membar_stst_stld(); \
346*7c478bd9Sstevel@tonic-gate 			SSIEVENT_CLR_HANDLED(*(s), (e)); \
347*7c478bd9Sstevel@tonic-gate 		} else { \
348*7c478bd9Sstevel@tonic-gate 			membar_stst_stld(); \
349*7c478bd9Sstevel@tonic-gate 			SSIEVENT_CLR_STATE(*(s), (e)); \
350*7c478bd9Sstevel@tonic-gate 		} \
351*7c478bd9Sstevel@tonic-gate }
352*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate typedef struct idnevent {
355*7c478bd9Sstevel@tonic-gate 	uchar_t		e_event;
356*7c478bd9Sstevel@tonic-gate 	uchar_t		e_handled;
357*7c478bd9Sstevel@tonic-gate 	ushort_t	e_event_data;
358*7c478bd9Sstevel@tonic-gate 	ushort_t	e_handled_data;
359*7c478bd9Sstevel@tonic-gate 	ushort_t	reserved;
360*7c478bd9Sstevel@tonic-gate } idnevent_t;
361*7c478bd9Sstevel@tonic-gate 
362*7c478bd9Sstevel@tonic-gate /*
363*7c478bd9Sstevel@tonic-gate  * IMPORTANT: This data structure must be the size of a sigbmbox_t
364*7c478bd9Sstevel@tonic-gate  *	      so that it fits in the space it steals in the sigblock.
365*7c478bd9Sstevel@tonic-gate  *            Also, any changes to this structure must be cross-checked
366*7c478bd9Sstevel@tonic-gate  *	      with (struct idnsb) in <sun4u1/sys/idn.h> with respect
367*7c478bd9Sstevel@tonic-gate  *	      the area from reserved1 on down.
368*7c478bd9Sstevel@tonic-gate  */
369*7c478bd9Sstevel@tonic-gate #define	IDNSB_EVENT_SIZE	(sizeof (sigbmbox_t))
370*7c478bd9Sstevel@tonic-gate typedef struct {
371*7c478bd9Sstevel@tonic-gate 	struct _idnsb_event {
372*7c478bd9Sstevel@tonic-gate 		union {
373*7c478bd9Sstevel@tonic-gate 			struct {
374*7c478bd9Sstevel@tonic-gate 				char	_cookie[SSIEVENT_COOKIE_LEN];
375*7c478bd9Sstevel@tonic-gate 				uchar_t	_version;
376*7c478bd9Sstevel@tonic-gate 			} _ss;
377*7c478bd9Sstevel@tonic-gate 			struct {
378*7c478bd9Sstevel@tonic-gate 				uint_t	_cookie : 24;
379*7c478bd9Sstevel@tonic-gate 				uint_t	_version : 8;
380*7c478bd9Sstevel@tonic-gate 			} _sn;
381*7c478bd9Sstevel@tonic-gate 		} _u;
382*7c478bd9Sstevel@tonic-gate 		uint_t		_reserved1;	/* reserved for IDN driver */
383*7c478bd9Sstevel@tonic-gate 		idnevent_t	_evt[SSIEVENT_MAXNUM];
384*7c478bd9Sstevel@tonic-gate 	} _s;
385*7c478bd9Sstevel@tonic-gate 
386*7c478bd9Sstevel@tonic-gate 		/* reserved for IDN driver */
387*7c478bd9Sstevel@tonic-gate 	char	reserved2[IDNSB_EVENT_SIZE - sizeof (struct _idnsb_event)];
388*7c478bd9Sstevel@tonic-gate } idnsb_event_t;
389*7c478bd9Sstevel@tonic-gate 
390*7c478bd9Sstevel@tonic-gate #define	idn_evt			_s._evt
391*7c478bd9Sstevel@tonic-gate #define	idn_reserved1		_s._reserved1
392*7c478bd9Sstevel@tonic-gate #define	idn_cookie_str		_s._u._ss._cookie
393*7c478bd9Sstevel@tonic-gate #define	idn_version_byte	_s._u._ss._version
394*7c478bd9Sstevel@tonic-gate #define	idn_cookie		_s._u._sn._cookie
395*7c478bd9Sstevel@tonic-gate #define	idn_version		_s._u._sn._version
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
398*7c478bd9Sstevel@tonic-gate }
399*7c478bd9Sstevel@tonic-gate #endif
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate #endif /* _SYS_IDN_SIGB_H */
402