4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_SBBCVAR_H
27 #define _SYS_SBBCVAR_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
35 typedef struct sbbc_intr_map
{
36 uint32_t sbbc_phys_hi
;
37 uint32_t sbbc_phys_mid
;
38 uint32_t sbbc_phys_low
;
40 uint32_t intr_ctlr_nodeid
;
44 struct sbbc_intr_map_mask
{
45 uint32_t sbbc_phys_hi
;
46 uint32_t sbbc_phys_mid
;
47 uint32_t sbbc_phys_low
;
51 /* sbbc intrspec for initializing its children. */
52 struct sbbc_intrspec
{
53 struct intrspec intr_spec
;
54 dev_info_t
*dip
; /* Interrupt parent dip */
55 uint32_t intr
; /* for lookup */
59 * definition of sbbc child reg spec entry:
65 } sbbc_child_regspec_t
;
67 /* SBBC range entry */
68 typedef struct sbbc_pci_rangespec
{
69 uint32_t sbbc_phys_hi
; /* Child hi range address */
70 uint32_t sbbc_phys_low
; /* Child low range address */
71 uint32_t pci_phys_hi
; /* Parent hi rng addr */
72 uint32_t pci_phys_mid
; /* Parent mid rng addr */
73 uint32_t pci_phys_low
; /* Parent low rng addr */
74 uint32_t rng_size
; /* Range size */
75 } sbbc_pci_rangespec_t
;
79 /* Max. SBBC devices/children */
80 #define MAX_SBBC_DEVICES 3
82 /* Only used for fixed or legacy interrupts */
83 #define SBBC_INTR_STATE_DISABLE 0 /* disabled */
84 #define SBBC_INTR_STATE_ENABLE 1 /* enabled */
86 typedef struct sbbc_child_intr
{
90 uint_t (*intr_handler
)();
95 typedef struct sbbcsoft
{
99 dev_info_t
*dip
; /* device information */
102 sbbc_pci_rangespec_t
*rangep
;
105 struct sbbc_regs_map
*pci_sbbc_map
; /* SBBC Internal Registers */
106 ddi_acc_handle_t pci_sbbc_map_handle
;
107 ddi_iblock_cookie_t sbbc_iblock_cookie
; /* interrupt block cookie */
108 kmutex_t sbbc_intr_mutex
; /* lock for interrupts */
109 sbbc_child_intr_t
*child_intr
[MAX_SBBC_DEVICES
]; /* intr per device */
110 boolean_t suspended
; /* TRUE if driver suspended */
111 kmutex_t umutex
; /* lock for this structure */
120 #define SBBC_DBG_ATTACH 0x1
121 #define SBBC_DBG_DETACH 0x2
122 #define SBBC_DBG_CTLOPS 0x4
123 #define SBBC_DBG_INITCHILD 0x8
124 #define SBBC_DBG_UNINITCHILD 0x10
125 #define SBBC_DBG_BUSMAP 0x20
126 #define SBBC_DBG_INTR 0x40
127 #define SBBC_DBG_PCICONF 0x80
128 #define SBBC_DBG_MAPRANGES 0x100
129 #define SBBC_DBG_PROPERTIES 0x200
130 #define SBBC_DBG_OPEN 0x400
131 #define SBBC_DBG_CLOSE 0x800
132 #define SBBC_DBG_IOCTL 0x1000
133 #define SBBC_DBG_INTROPS 0x2000
136 #define SBBC_DBG0(flag, dip, fmt) \
137 sbbc_dbg(flag, dip, fmt, 0, 0, 0, 0, 0);
138 #define SBBC_DBG1(flag, dip, fmt, a1) \
139 sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
140 #define SBBC_DBG2(flag, dip, fmt, a1, a2) \
141 sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
142 #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) \
143 sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
144 (uintptr_t)(a3), 0, 0);
145 #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) \
146 sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
147 (uintptr_t)(a3), (uintptr_t)(a4), 0);
148 #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \
149 sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
150 (uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5));
154 #define SBBC_DBG0(flag, dip, fmt)
155 #define SBBC_DBG1(flag, dip, fmt, a1)
156 #define SBBC_DBG2(flag, dip, fmt, a1, a2)
157 #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3)
158 #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4)
159 #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)
163 /* debugging flags */
165 * To enable tracing, uncomment this line:
166 * #define SBBC_TRACE 1
169 #if defined(SBBC_TRACE)
172 #define NSBBCTRACE 1024
177 int function
; /* address of function */
178 int trace_action
; /* descriptive 4 characters */
179 int object
; /* object operated on */
183 * For debugging, allocate space for the trace buffer
186 extern struct sbbctrace sbbctrace_buffer
[];
187 extern struct sbbctrace
*sbbctrace_ptr
;
188 extern int sbbctrace_count
;
190 #define SBBCTRACEINIT() { \
191 if (sbbctrace_ptr == NULL) \
192 sbbctrace_ptr = sbbctrace_buffer; \
195 #define LOCK_TRACE() (uint_t)ddi_enter_critical()
196 #define UNLOCK_TRACE(x) ddi_exit_critical((uint_t)x)
198 #define SBBCTRACE(func, act, obj) { \
199 int __s = LOCK_TRACE(); \
200 int *_p = &sbbctrace_ptr->count; \
201 *_p++ = ++sbbctrace_count; \
202 *_p++ = (int)(func); \
203 *_p++ = (int)(act); \
204 *_p++ = (int)(obj); \
205 if ((struct sbbctrace *)(void *)_p >= &sbbctrace_buffer[NSBBCTRACE])\
206 sbbctrace_ptr = sbbctrace_buffer; \
208 sbbctrace_ptr = (struct sbbctrace *)(void *)_p; \
212 #else /* !SBBC_TRACE */
214 /* If no tracing, define no-ops */
215 #define SBBCTRACEINIT()
216 #define SBBCTRACE(a, b, c)
218 #endif /* !SBBC_TRACE */
224 #endif /* _SYS_SBBCVAR_H */