1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SBBCVAR_H
#define _SYS_SBBCVAR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sbbc_intr_map {
uint32_t sbbc_phys_hi;
uint32_t sbbc_phys_mid;
uint32_t sbbc_phys_low;
uint32_t sbbc_intr;
uint32_t intr_ctlr_nodeid;
uint32_t ino;
}sbbc_intr_map_t;
struct sbbc_intr_map_mask {
uint32_t sbbc_phys_hi;
uint32_t sbbc_phys_mid;
uint32_t sbbc_phys_low;
uint32_t sbbc_intr;
};
/* sbbc intrspec for initializing its children. */
struct sbbc_intrspec {
struct intrspec intr_spec;
dev_info_t *dip; /* Interrupt parent dip */
uint32_t intr; /* for lookup */
};
/*
* definition of sbbc child reg spec entry:
*/
typedef struct {
uint32_t addr_hi;
uint32_t addr_low;
uint32_t size;
} sbbc_child_regspec_t;
/* SBBC range entry */
typedef struct sbbc_pci_rangespec {
uint32_t sbbc_phys_hi; /* Child hi range address */
uint32_t sbbc_phys_low; /* Child low range address */
uint32_t pci_phys_hi; /* Parent hi rng addr */
uint32_t pci_phys_mid; /* Parent mid rng addr */
uint32_t pci_phys_low; /* Parent low rng addr */
uint32_t rng_size; /* Range size */
} sbbc_pci_rangespec_t;
typedef int procid_t;
/* Max. SBBC devices/children */
#define MAX_SBBC_DEVICES 3
/* Only used for fixed or legacy interrupts */
#define SBBC_INTR_STATE_DISABLE 0 /* disabled */
#define SBBC_INTR_STATE_ENABLE 1 /* enabled */
typedef struct sbbc_child_intr {
char *name;
uint_t inum;
uint_t status;
uint_t (*intr_handler)();
caddr_t arg1;
caddr_t arg2;
} sbbc_child_intr_t;
typedef struct sbbcsoft {
int instance;
int oflag;
uint_t myinumber;
dev_info_t *dip; /* device information */
pci_regspec_t *reg;
int nreg;
sbbc_pci_rangespec_t *rangep;
int range_cnt;
int range_len;
struct sbbc_regs_map *pci_sbbc_map; /* SBBC Internal Registers */
ddi_acc_handle_t pci_sbbc_map_handle;
ddi_iblock_cookie_t sbbc_iblock_cookie; /* interrupt block cookie */
kmutex_t sbbc_intr_mutex; /* lock for interrupts */
sbbc_child_intr_t *child_intr[MAX_SBBC_DEVICES]; /* intr per device */
boolean_t suspended; /* TRUE if driver suspended */
kmutex_t umutex; /* lock for this structure */
} sbbcsoft_t;
#define TRUE 1
#define FALSE 0
#if defined(DEBUG)
#define SBBC_DBG_ATTACH 0x1
#define SBBC_DBG_DETACH 0x2
#define SBBC_DBG_CTLOPS 0x4
#define SBBC_DBG_INITCHILD 0x8
#define SBBC_DBG_UNINITCHILD 0x10
#define SBBC_DBG_BUSMAP 0x20
#define SBBC_DBG_INTR 0x40
#define SBBC_DBG_PCICONF 0x80
#define SBBC_DBG_MAPRANGES 0x100
#define SBBC_DBG_PROPERTIES 0x200
#define SBBC_DBG_OPEN 0x400
#define SBBC_DBG_CLOSE 0x800
#define SBBC_DBG_IOCTL 0x1000
#define SBBC_DBG_INTROPS 0x2000
#define SBBC_DBG0(flag, dip, fmt) \
sbbc_dbg(flag, dip, fmt, 0, 0, 0, 0, 0);
#define SBBC_DBG1(flag, dip, fmt, a1) \
sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
#define SBBC_DBG2(flag, dip, fmt, a1, a2) \
sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
#define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) \
sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
(uintptr_t)(a3), 0, 0);
#define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) \
sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
(uintptr_t)(a3), (uintptr_t)(a4), 0);
#define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \
sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
(uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5));
#else /* DEBUG */
#define SBBC_DBG0(flag, dip, fmt)
#define SBBC_DBG1(flag, dip, fmt, a1)
#define SBBC_DBG2(flag, dip, fmt, a1, a2)
#define SBBC_DBG3(flag, dip, fmt, a1, a2, a3)
#define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4)
#define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)
#endif /* DEBUG */
/* debugging flags */
/*
* To enable tracing, uncomment this line:
* #define SBBC_TRACE 1
*/
#if defined(SBBC_TRACE)
#ifndef NSBBCTRACE
#define NSBBCTRACE 1024
#endif
struct sbbctrace {
int count;
int function; /* address of function */
int trace_action; /* descriptive 4 characters */
int object; /* object operated on */
};
/*
* For debugging, allocate space for the trace buffer
*/
extern struct sbbctrace sbbctrace_buffer[];
extern struct sbbctrace *sbbctrace_ptr;
extern int sbbctrace_count;
#define SBBCTRACEINIT() { \
if (sbbctrace_ptr == NULL) \
sbbctrace_ptr = sbbctrace_buffer; \
}
#define LOCK_TRACE() (uint_t)ddi_enter_critical()
#define UNLOCK_TRACE(x) ddi_exit_critical((uint_t)x)
#define SBBCTRACE(func, act, obj) { \
int __s = LOCK_TRACE(); \
int *_p = &sbbctrace_ptr->count; \
*_p++ = ++sbbctrace_count; \
*_p++ = (int)(func); \
*_p++ = (int)(act); \
*_p++ = (int)(obj); \
if ((struct sbbctrace *)(void *)_p >= &sbbctrace_buffer[NSBBCTRACE])\
sbbctrace_ptr = sbbctrace_buffer; \
else \
sbbctrace_ptr = (struct sbbctrace *)(void *)_p; \
UNLOCK_TRACE(__s); \
}
#else /* !SBBC_TRACE */
/* If no tracing, define no-ops */
#define SBBCTRACEINIT()
#define SBBCTRACE(a, b, c)
#endif /* !SBBC_TRACE */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SBBCVAR_H */
|