xref: /onnv-gate/usr/src/uts/sun4/io/px/px_debug.c (revision 1772:78cca3d2cc4b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1772Sjl139090  * Common Development and Distribution License (the "License").
6*1772Sjl139090  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1772Sjl139090  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * PCI nexus driver general debug support
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate #include <sys/async.h>
320Sstevel@tonic-gate #include <sys/sunddi.h>		/* dev_info_t */
330Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
340Sstevel@tonic-gate #include <sys/disp.h>
350Sstevel@tonic-gate #include "px_debug.h"
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /*LINTLIBRARY*/
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef	DEBUG
40332Sjchu uint64_t px_debug_flags = 0;
410Sstevel@tonic-gate 
420Sstevel@tonic-gate static char *px_debug_sym [] = {	/* same sequence as px_debug_bit */
430Sstevel@tonic-gate 	/*  0 */ "attach",
440Sstevel@tonic-gate 	/*  1 */ "detach",
450Sstevel@tonic-gate 	/*  2 */ "map",
460Sstevel@tonic-gate 	/*  3 */ "nex-ctlops",
470Sstevel@tonic-gate 
480Sstevel@tonic-gate 	/*  4 */ "introps",
490Sstevel@tonic-gate 	/*  5 */ "intx-add",
500Sstevel@tonic-gate 	/*  6 */ "intx-rem",
510Sstevel@tonic-gate 	/*  7 */ "intx-intr",
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 	/*  8 */ "msiq",
540Sstevel@tonic-gate 	/*  9 */ "msiq-intr",
550Sstevel@tonic-gate 	/* 10 */ "msg",
560Sstevel@tonic-gate 	/* 11 */ "msg-intr",
570Sstevel@tonic-gate 
580Sstevel@tonic-gate 	/* 12 */ "msix-add",
590Sstevel@tonic-gate 	/* 13 */ "msix-rem",
600Sstevel@tonic-gate 	/* 14 */ "msix-intr",
610Sstevel@tonic-gate 	/* 15 */ "err",
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	/* 16 */ "dma-alloc",
640Sstevel@tonic-gate 	/* 17 */ "dma-free",
650Sstevel@tonic-gate 	/* 18 */ "dma-bind",
660Sstevel@tonic-gate 	/* 19 */ "dma-unbind",
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/* 20 */ "chk-dma-mode",
690Sstevel@tonic-gate 	/* 21 */ "bypass-dma",
700Sstevel@tonic-gate 	/* 22 */ "fast-dvma",
710Sstevel@tonic-gate 	/* 23 */ "init_child",
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 	/* 24 */ "dma-map",
740Sstevel@tonic-gate 	/* 25 */ "dma-win",
750Sstevel@tonic-gate 	/* 26 */ "map-win",
760Sstevel@tonic-gate 	/* 27 */ "unmap-win",
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	/* 28 */ "dma-ctl",
790Sstevel@tonic-gate 	/* 29 */ "dma-sync",
800Sstevel@tonic-gate 	/* 30 */ NULL,
810Sstevel@tonic-gate 	/* 31 */ NULL,
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	/* 32 */ "ib",
840Sstevel@tonic-gate 	/* 33 */ "cb",
850Sstevel@tonic-gate 	/* 34 */ "dmc",
860Sstevel@tonic-gate 	/* 35 */ "pec",
870Sstevel@tonic-gate 
880Sstevel@tonic-gate 	/* 36 */ "ilu",
890Sstevel@tonic-gate 	/* 37 */ "tlu",
900Sstevel@tonic-gate 	/* 38 */ "lpu",
91*1772Sjl139090 	/* 39 */ "mmu",
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 	/* 40 */ "open",
940Sstevel@tonic-gate 	/* 41 */ "close",
950Sstevel@tonic-gate 	/* 42 */ "ioctl",
960Sstevel@tonic-gate 	/* 43 */ "pwr",
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	/* 44 */ "lib-cfg",
990Sstevel@tonic-gate 	/* 45 */ "lib-intr",
1000Sstevel@tonic-gate 	/* 46 */ "lib-dma",
1010Sstevel@tonic-gate 	/* 47 */ "lib-msiq",
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate 	/* 48 */ "lib-msi",
1040Sstevel@tonic-gate 	/* 49 */ "lib-msg",
1050Sstevel@tonic-gate 	/* 50 */ "NULL",
1060Sstevel@tonic-gate 	/* 51 */ "NULL",
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate 	/* 52 */ "tools",
1090Sstevel@tonic-gate 	/* 53 */ "phys_acc",
1100Sstevel@tonic-gate 	/* LAST */ "unknown"
1110Sstevel@tonic-gate };
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate void
1140Sstevel@tonic-gate px_dbg(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...)
1150Sstevel@tonic-gate {
1160Sstevel@tonic-gate 	int cont = bit >> DBG_BITS;
1170Sstevel@tonic-gate 	va_list ap;
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate 	bit &= DBG_MASK;
1200Sstevel@tonic-gate 	if (bit >= sizeof (px_debug_sym) / sizeof (char *))
1210Sstevel@tonic-gate 		return;
1220Sstevel@tonic-gate 	if (!(1ull << bit & px_debug_flags))
1230Sstevel@tonic-gate 		return;
1240Sstevel@tonic-gate 	if (cont)
1250Sstevel@tonic-gate 		goto body;
126332Sjchu 
127332Sjchu 	if (dip)
128332Sjchu 		prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
129332Sjchu 		    ddi_get_instance(dip), px_debug_sym[bit]);
130332Sjchu 	else
131332Sjchu 		prom_printf("px: %s: ", px_debug_sym[bit]);
1320Sstevel@tonic-gate body:
1330Sstevel@tonic-gate 	va_start(ap, fmt);
134332Sjchu 	prom_vprintf(fmt, ap);
1350Sstevel@tonic-gate 	va_end(ap);
1360Sstevel@tonic-gate }
1370Sstevel@tonic-gate #endif	/* DEBUG */
138