6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /*
29 * PCI nexus driver general debug support
30 */
31 #include <sys/async.h>
32 #include <sys/sunddi.h> /* dev_info_t */
33 #include <sys/ddi_impldefs.h>
34 #include <sys/disp.h>
35 #include <sys/archsystm.h> /* getpil() */
36 #include "px_obj.h"
37
38 /*LINTLIBRARY*/
39
40 #ifdef DEBUG
41 uint64_t px_debug_flags = 0;
42
43 static char *px_debug_sym [] = { /* same sequence as px_debug_bit */
44 /* 0 */ "attach",
45 /* 1 */ "detach",
46 /* 2 */ "map",
47 /* 3 */ "nex-ctlops",
48
49 /* 4 */ "introps",
50 /* 5 */ "intx-add",
239 if (!(1ull << bit & px_debug_flags))
240 return;
241
242 va_start(ap, fmt);
243 if (getpil() > LOCK_LEVEL)
244 px_dbg_queue(bit, dip, fmt, ap);
245 else
246 px_dbg_print(bit, dip, fmt, ap);
247 va_end(ap);
248 }
249 #endif /* DEBUG */
250
251 void
252 px_dbg_attach(dev_info_t *dip, ddi_softint_handle_t *dbg_hdl)
253 {
254 #ifdef DEBUG
255 if (px_dbg_reference++ == 0) {
256 int size = px_dbg_msg_size;
257
258 /* Check if px_dbg_msg_size is ^2 */
259 size = (size & (size - 1)) ? ((size | ~size) + 1) : size;
260 px_dbg_msg_size = size;
261 px_dbg_qmask = size - 1;
262 px_dbg_msgq = kmem_zalloc(sizeof (px_dbg_msg_t) * size,
263 KM_SLEEP);
264
265 mutex_init(&px_dbg_mutex, NULL, MUTEX_DRIVER, NULL);
266 }
267
268 if (ddi_intr_add_softint(dip, dbg_hdl,
269 DDI_INTR_SOFTPRI_MAX, px_dbg_drain, NULL) != DDI_SUCCESS) {
270 DBG(DBG_ATTACH, dip,
271 "Unable to allocate soft int for DBG printing.\n");
272 dbg_hdl = NULL;
273 }
274 #endif /* DEBUG */
275 }
276
277 /* ARGSUSED */
278 void
279 px_dbg_detach(dev_info_t *dip, ddi_softint_handle_t *dbg_hdl)
|
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * PCI nexus driver general debug support
28 */
29 #include <sys/sysmacros.h>
30 #include <sys/async.h>
31 #include <sys/sunddi.h> /* dev_info_t */
32 #include <sys/ddi_impldefs.h>
33 #include <sys/disp.h>
34 #include <sys/archsystm.h> /* getpil() */
35 #include "px_obj.h"
36
37 /*LINTLIBRARY*/
38
39 #ifdef DEBUG
40 uint64_t px_debug_flags = 0;
41
42 static char *px_debug_sym [] = { /* same sequence as px_debug_bit */
43 /* 0 */ "attach",
44 /* 1 */ "detach",
45 /* 2 */ "map",
46 /* 3 */ "nex-ctlops",
47
48 /* 4 */ "introps",
49 /* 5 */ "intx-add",
238 if (!(1ull << bit & px_debug_flags))
239 return;
240
241 va_start(ap, fmt);
242 if (getpil() > LOCK_LEVEL)
243 px_dbg_queue(bit, dip, fmt, ap);
244 else
245 px_dbg_print(bit, dip, fmt, ap);
246 va_end(ap);
247 }
248 #endif /* DEBUG */
249
250 void
251 px_dbg_attach(dev_info_t *dip, ddi_softint_handle_t *dbg_hdl)
252 {
253 #ifdef DEBUG
254 if (px_dbg_reference++ == 0) {
255 int size = px_dbg_msg_size;
256
257 /* Check if px_dbg_msg_size is ^2 */
258 size = !ISP2(size) ? ((size | ~size) + 1) : size;
259 px_dbg_msg_size = size;
260 px_dbg_qmask = size - 1;
261 px_dbg_msgq = kmem_zalloc(sizeof (px_dbg_msg_t) * size,
262 KM_SLEEP);
263
264 mutex_init(&px_dbg_mutex, NULL, MUTEX_DRIVER, NULL);
265 }
266
267 if (ddi_intr_add_softint(dip, dbg_hdl,
268 DDI_INTR_SOFTPRI_MAX, px_dbg_drain, NULL) != DDI_SUCCESS) {
269 DBG(DBG_ATTACH, dip,
270 "Unable to allocate soft int for DBG printing.\n");
271 dbg_hdl = NULL;
272 }
273 #endif /* DEBUG */
274 }
275
276 /* ARGSUSED */
277 void
278 px_dbg_detach(dev_info_t *dip, ddi_softint_handle_t *dbg_hdl)
|