xref: /titanic_53/usr/src/uts/sun4u/sys/sbbcvar.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 2005 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_SBBCVAR_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SBBCVAR_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 typedef struct sbbc_intr_map {
37*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_hi;
38*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_mid;
39*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_low;
40*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_intr;
41*7c478bd9Sstevel@tonic-gate 	uint32_t intr_ctlr_nodeid;
42*7c478bd9Sstevel@tonic-gate 	uint32_t ino;
43*7c478bd9Sstevel@tonic-gate }sbbc_intr_map_t;
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate struct sbbc_intr_map_mask {
46*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_hi;
47*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_mid;
48*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_low;
49*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_intr;
50*7c478bd9Sstevel@tonic-gate };
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /* sbbc intrspec for initializing its children. */
53*7c478bd9Sstevel@tonic-gate struct sbbc_intrspec {
54*7c478bd9Sstevel@tonic-gate 	struct intrspec intr_spec;
55*7c478bd9Sstevel@tonic-gate 	dev_info_t *dip;		/* Interrupt parent dip */
56*7c478bd9Sstevel@tonic-gate 	uint32_t intr;			/* for lookup */
57*7c478bd9Sstevel@tonic-gate };
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /*
60*7c478bd9Sstevel@tonic-gate  * definition of sbbc child reg spec entry:
61*7c478bd9Sstevel@tonic-gate  */
62*7c478bd9Sstevel@tonic-gate typedef struct {
63*7c478bd9Sstevel@tonic-gate 	uint32_t addr_hi;
64*7c478bd9Sstevel@tonic-gate 	uint32_t addr_low;
65*7c478bd9Sstevel@tonic-gate 	uint32_t size;
66*7c478bd9Sstevel@tonic-gate } sbbc_child_regspec_t;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /* SBBC range entry */
69*7c478bd9Sstevel@tonic-gate typedef struct sbbc_pci_rangespec {
70*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_hi;		/* Child hi range address */
71*7c478bd9Sstevel@tonic-gate 	uint32_t sbbc_phys_low;		/* Child low range address */
72*7c478bd9Sstevel@tonic-gate 	uint32_t pci_phys_hi;		/* Parent hi rng addr */
73*7c478bd9Sstevel@tonic-gate 	uint32_t pci_phys_mid;		/* Parent mid rng addr */
74*7c478bd9Sstevel@tonic-gate 	uint32_t pci_phys_low;		/* Parent low rng addr */
75*7c478bd9Sstevel@tonic-gate 	uint32_t rng_size;		/* Range size */
76*7c478bd9Sstevel@tonic-gate } sbbc_pci_rangespec_t;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate typedef int procid_t;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate /* Max. SBBC devices/children */
81*7c478bd9Sstevel@tonic-gate #define	MAX_SBBC_DEVICES	3
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /* Only used for fixed or legacy interrupts */
84*7c478bd9Sstevel@tonic-gate #define	SBBC_INTR_STATE_DISABLE	0	/* disabled */
85*7c478bd9Sstevel@tonic-gate #define	SBBC_INTR_STATE_ENABLE	1	/* enabled */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate typedef struct sbbc_child_intr {
88*7c478bd9Sstevel@tonic-gate 	char *name;
89*7c478bd9Sstevel@tonic-gate 	uint_t inum;
90*7c478bd9Sstevel@tonic-gate 	uint_t status;
91*7c478bd9Sstevel@tonic-gate 	uint_t (*intr_handler)();
92*7c478bd9Sstevel@tonic-gate 	caddr_t arg1;
93*7c478bd9Sstevel@tonic-gate 	caddr_t	arg2;
94*7c478bd9Sstevel@tonic-gate } sbbc_child_intr_t;
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate typedef struct sbbcsoft {
97*7c478bd9Sstevel@tonic-gate 	int instance;
98*7c478bd9Sstevel@tonic-gate 	int oflag;
99*7c478bd9Sstevel@tonic-gate 	uint_t myinumber;
100*7c478bd9Sstevel@tonic-gate 	dev_info_t *dip;			/* device information */
101*7c478bd9Sstevel@tonic-gate 	pci_regspec_t *reg;
102*7c478bd9Sstevel@tonic-gate 	int nreg;
103*7c478bd9Sstevel@tonic-gate 	sbbc_pci_rangespec_t *rangep;
104*7c478bd9Sstevel@tonic-gate 	int range_cnt;
105*7c478bd9Sstevel@tonic-gate 	int range_len;
106*7c478bd9Sstevel@tonic-gate 	struct pci_sbbc *pci_sbbc_map;		/* sbbc registers and devices */
107*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t pci_sbbc_map_handle;
108*7c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t sbbc_iblock_cookie; /* interrupt block cookie */
109*7c478bd9Sstevel@tonic-gate 	kmutex_t sbbc_intr_mutex;		/* lock for interrupts */
110*7c478bd9Sstevel@tonic-gate 	sbbc_child_intr_t *child_intr[MAX_SBBC_DEVICES]; /* intr per device */
111*7c478bd9Sstevel@tonic-gate 	boolean_t suspended;			/* TRUE if driver suspended */
112*7c478bd9Sstevel@tonic-gate 	kmutex_t umutex;			/* lock for this structure */
113*7c478bd9Sstevel@tonic-gate } sbbcsoft_t;
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #define	TRUE		1
116*7c478bd9Sstevel@tonic-gate #define	FALSE		0
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate #if defined(DEBUG)
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_ATTACH		0x1
122*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_DETACH		0x2
123*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_CTLOPS		0x4
124*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_INITCHILD	0x8
125*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_UNINITCHILD	0x10
126*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_BUSMAP		0x20
127*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_INTR		0x40
128*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_PCICONF	0x80
129*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_MAPRANGES	0x100
130*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_PROPERTIES	0x200
131*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_OPEN		0x400
132*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_CLOSE		0x800
133*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_IOCTL		0x1000
134*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG_INTROPS	0x2000
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG0(flag, dip, fmt) \
138*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, 0, 0, 0, 0, 0);
139*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG1(flag, dip, fmt, a1) \
140*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
141*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG2(flag, dip, fmt, a1, a2) \
142*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
143*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG3(flag, dip, fmt, a1, a2, a3) \
144*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
145*7c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), 0, 0);
146*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) \
147*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
148*7c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), (uintptr_t)(a4), 0);
149*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \
150*7c478bd9Sstevel@tonic-gate 	sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
151*7c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5));
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate #else /* DEBUG */
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG0(flag, dip, fmt)
156*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG1(flag, dip, fmt, a1)
157*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG2(flag, dip, fmt, a1, a2)
158*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG3(flag, dip, fmt, a1, a2, a3)
159*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4)
160*7c478bd9Sstevel@tonic-gate #define	SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate /* debugging flags */
165*7c478bd9Sstevel@tonic-gate /*
166*7c478bd9Sstevel@tonic-gate  * To enable tracing, uncomment this line:
167*7c478bd9Sstevel@tonic-gate  * #define	SBBC_TRACE	1
168*7c478bd9Sstevel@tonic-gate  */
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate #if defined(SBBC_TRACE)
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate #ifndef NSBBCTRACE
173*7c478bd9Sstevel@tonic-gate #define	NSBBCTRACE	1024
174*7c478bd9Sstevel@tonic-gate #endif
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate struct sbbctrace {
177*7c478bd9Sstevel@tonic-gate 	int count;
178*7c478bd9Sstevel@tonic-gate 	int function;		/* address of function */
179*7c478bd9Sstevel@tonic-gate 	int trace_action;	/* descriptive 4 characters */
180*7c478bd9Sstevel@tonic-gate 	int object;		/* object operated on */
181*7c478bd9Sstevel@tonic-gate };
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate /*
184*7c478bd9Sstevel@tonic-gate  * For debugging, allocate space for the trace buffer
185*7c478bd9Sstevel@tonic-gate  */
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate extern struct sbbctrace sbbctrace_buffer[];
188*7c478bd9Sstevel@tonic-gate extern struct sbbctrace *sbbctrace_ptr;
189*7c478bd9Sstevel@tonic-gate extern int sbbctrace_count;
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate #define	SBBCTRACEINIT() {				\
192*7c478bd9Sstevel@tonic-gate 	if (sbbctrace_ptr == NULL)		\
193*7c478bd9Sstevel@tonic-gate 		sbbctrace_ptr = sbbctrace_buffer; \
194*7c478bd9Sstevel@tonic-gate 	}
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate #define	LOCK_TRACE()	(uint_t)ddi_enter_critical()
197*7c478bd9Sstevel@tonic-gate #define	UNLOCK_TRACE(x)	ddi_exit_critical((uint_t)x)
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate #define	SBBCTRACE(func, act, obj) {		\
200*7c478bd9Sstevel@tonic-gate 	int __s = LOCK_TRACE();			\
201*7c478bd9Sstevel@tonic-gate 	int *_p = &sbbctrace_ptr->count;	\
202*7c478bd9Sstevel@tonic-gate 	*_p++ = ++sbbctrace_count;		\
203*7c478bd9Sstevel@tonic-gate 	*_p++ = (int)(func);			\
204*7c478bd9Sstevel@tonic-gate 	*_p++ = (int)(act);			\
205*7c478bd9Sstevel@tonic-gate 	*_p++ = (int)(obj);			\
206*7c478bd9Sstevel@tonic-gate 	if ((struct sbbctrace *)(void *)_p >= &sbbctrace_buffer[NSBBCTRACE])\
207*7c478bd9Sstevel@tonic-gate 		sbbctrace_ptr = sbbctrace_buffer; \
208*7c478bd9Sstevel@tonic-gate 	else					\
209*7c478bd9Sstevel@tonic-gate 		sbbctrace_ptr = (struct sbbctrace *)(void *)_p; \
210*7c478bd9Sstevel@tonic-gate 	UNLOCK_TRACE(__s);			\
211*7c478bd9Sstevel@tonic-gate 	}
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate #else	/* !SBBC_TRACE */
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate /* If no tracing, define no-ops */
216*7c478bd9Sstevel@tonic-gate #define	SBBCTRACEINIT()
217*7c478bd9Sstevel@tonic-gate #define	SBBCTRACE(a, b, c)
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate #endif	/* !SBBC_TRACE */
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
222*7c478bd9Sstevel@tonic-gate }
223*7c478bd9Sstevel@tonic-gate #endif
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SBBCVAR_H */
226