xref: /illumos-gate/usr/src/uts/sun4u/serengeti/sys/ssm.h (revision 03831d35)
1*03831d35Sstevel /*
2*03831d35Sstevel  * CDDL HEADER START
3*03831d35Sstevel  *
4*03831d35Sstevel  * The contents of this file are subject to the terms of the
5*03831d35Sstevel  * Common Development and Distribution License (the "License").
6*03831d35Sstevel  * You may not use this file except in compliance with the License.
7*03831d35Sstevel  *
8*03831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*03831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
10*03831d35Sstevel  * See the License for the specific language governing permissions
11*03831d35Sstevel  * and limitations under the License.
12*03831d35Sstevel  *
13*03831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*03831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*03831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*03831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*03831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*03831d35Sstevel  *
19*03831d35Sstevel  * CDDL HEADER END
20*03831d35Sstevel  */
21*03831d35Sstevel 
22*03831d35Sstevel /*
23*03831d35Sstevel  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*03831d35Sstevel  * Use is subject to license terms.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel #ifndef	_SYS_SSM_H
28*03831d35Sstevel #define	_SYS_SSM_H
29*03831d35Sstevel 
30*03831d35Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*03831d35Sstevel 
32*03831d35Sstevel #ifdef	__cplusplus
33*03831d35Sstevel extern "C" {
34*03831d35Sstevel #endif
35*03831d35Sstevel 
36*03831d35Sstevel #include <sys/types.h>		/* needed by <sys/dditypes.h> */
37*03831d35Sstevel #include <sys/dditypes.h>	/* needed for definition of dev_info_t */
38*03831d35Sstevel #include <sys/mutex.h>
39*03831d35Sstevel 
40*03831d35Sstevel /*
41*03831d35Sstevel  * ssm soft state macros: IIIIMMMM
42*03831d35Sstevel  *                 instance-minor no
43*03831d35Sstevel  */
44*03831d35Sstevel #define	SSM_INSTANCE_SHIFT	4
45*03831d35Sstevel #define	SSM_BOARD_MASK		0xff
46*03831d35Sstevel 
47*03831d35Sstevel 
48*03831d35Sstevel struct ssm_soft_state {
49*03831d35Sstevel 	dev_info_t	*dip;		/* own dev info */
50*03831d35Sstevel 	int		ssm_nodeid;	/* node id */
51*03831d35Sstevel 	dev_info_t	*top_node;
52*03831d35Sstevel 	int		initialized;	/* instance has been initialized */
53*03831d35Sstevel 	kmutex_t	ssm_sft_lock;	/* protects this struct */
54*03831d35Sstevel 	ddi_iblock_cookie_t ssm_fm_ibc; /* returned ibc from our parent */
55*03831d35Sstevel 	int		ssm_fm_cap;	/* our fm capability */
56*03831d35Sstevel };
57*03831d35Sstevel 
58*03831d35Sstevel typedef struct {
59*03831d35Sstevel 	int	instance;	/* instance for this wildcat node */
60*03831d35Sstevel 	int	wnode;		/* node num */
61*03831d35Sstevel } ssm_sbdp_info_t;
62*03831d35Sstevel 
63*03831d35Sstevel /*
64*03831d35Sstevel  * useful debugging stuff
65*03831d35Sstevel  */
66*03831d35Sstevel #define	SSM_ATTACH_DEBUG	0x0002
67*03831d35Sstevel #define	SSM_CTLOPS_DEBUG	0x0004
68*03831d35Sstevel #define	SSM_EVENT_DEBUG		0x0008
69*03831d35Sstevel 
70*03831d35Sstevel #define	_SSM_IOCTL		(('m' << 16) | ('p' << 8))
71*03831d35Sstevel #define	SSM_TEARDOWN_SBD	(_SSM_IOCTL | 0x1)
72*03831d35Sstevel 
73*03831d35Sstevel #ifdef DEBUG
74*03831d35Sstevel #define	CMD2EVNT(m)	((m) == SGDR_BD_ABSENT	? SG_EVT_BOARD_ABSENT :	\
75*03831d35Sstevel 			    (m) == SGDR_BD_PRESENT ? SG_EVT_BOARD_PRESENT :\
76*03831d35Sstevel 			    (m) == SGDR_UNASSIGN ? SG_EVT_UNASSIGN : 	\
77*03831d35Sstevel 			    (m) == SGDR_ASSIGN ? SG_EVT_ASSIGN :	\
78*03831d35Sstevel 			    (m) == SGDR_UNAVAILABLE ? SG_EVT_UNAVAILABLE :\
79*03831d35Sstevel 			    (m) == SGDR_AVAILABLE ? SG_EVT_AVAILABLE : 	\
80*03831d35Sstevel 			    (m) == SGDR_POWER_OFF ? SG_EVT_POWER_OFF : 	\
81*03831d35Sstevel 			    (m) == SGDR_POWER_ON ? SG_EVT_POWER_ON :	\
82*03831d35Sstevel 			    (m) == SGDR_PASSED_TEST ? SG_EVT_PASSED_TEST :\
83*03831d35Sstevel 			    (m) == SGDR_FAILED_TEST ? SG_EVT_FAILED_TEST :\
84*03831d35Sstevel 			    0)
85*03831d35Sstevel 
86*03831d35Sstevel #define	EVNT2STR(c)	((c) == SG_EVT_BOARD_ABSENT ? "board_absent" :\
87*03831d35Sstevel 			    (c) == SG_EVT_BOARD_PRESENT ? "board_present" :\
88*03831d35Sstevel 			    (c) == SG_EVT_UNASSIGN ? "unassign" :	\
89*03831d35Sstevel 			    (c) == SG_EVT_ASSIGN ? "assign" :		\
90*03831d35Sstevel 			    (c) == SG_EVT_UNAVAILABLE ? "unavailable" :	\
91*03831d35Sstevel 			    (c) == SG_EVT_AVAILABLE ? "available" :	\
92*03831d35Sstevel 			    (c) == SG_EVT_POWER_OFF ? "power_off" :	\
93*03831d35Sstevel 			    (c) == SG_EVT_POWER_ON	? "power_on" :	\
94*03831d35Sstevel 			    (c) == SG_EVT_PASSED_TEST ? "passed_test" :	\
95*03831d35Sstevel 			    (c) == SG_EVT_FAILED_TEST ? "failed_test" :	\
96*03831d35Sstevel 			    NULL)
97*03831d35Sstevel #endif
98*03831d35Sstevel 
99*03831d35Sstevel #ifdef	__cplusplus
100*03831d35Sstevel }
101*03831d35Sstevel #endif
102*03831d35Sstevel 
103*03831d35Sstevel #endif /* _SYS_SSM_H */
104