xref: /titanic_51/usr/src/uts/sun4/io/px/px_debug.c (revision 06e1a7147edd272b7296f208141627a5b1191731)
1 /*
2  * CDDL HEADER START
3  *
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.
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 2006 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 "px_debug.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",
50 	/*  6 */ "intx-rem",
51 	/*  7 */ "intx-intr",
52 
53 	/*  8 */ "msiq",
54 	/*  9 */ "msiq-intr",
55 	/* 10 */ "msg",
56 	/* 11 */ "msg-intr",
57 
58 	/* 12 */ "msix-add",
59 	/* 13 */ "msix-rem",
60 	/* 14 */ "msix-intr",
61 	/* 15 */ "err",
62 
63 	/* 16 */ "dma-alloc",
64 	/* 17 */ "dma-free",
65 	/* 18 */ "dma-bind",
66 	/* 19 */ "dma-unbind",
67 
68 	/* 20 */ "chk-dma-mode",
69 	/* 21 */ "bypass-dma",
70 	/* 22 */ "fast-dvma",
71 	/* 23 */ "init_child",
72 
73 	/* 24 */ "dma-map",
74 	/* 25 */ "dma-win",
75 	/* 26 */ "map-win",
76 	/* 27 */ "unmap-win",
77 
78 	/* 28 */ "dma-ctl",
79 	/* 29 */ "dma-sync",
80 	/* 30 */ NULL,
81 	/* 31 */ NULL,
82 
83 	/* 32 */ "ib",
84 	/* 33 */ "cb",
85 	/* 34 */ "dmc",
86 	/* 35 */ "pec",
87 
88 	/* 36 */ "ilu",
89 	/* 37 */ "tlu",
90 	/* 38 */ "lpu",
91 	/* 39 */ "mmu",
92 
93 	/* 40 */ "open",
94 	/* 41 */ "close",
95 	/* 42 */ "ioctl",
96 	/* 43 */ "pwr",
97 
98 	/* 44 */ "lib-cfg",
99 	/* 45 */ "lib-intr",
100 	/* 46 */ "lib-dma",
101 	/* 47 */ "lib-msiq",
102 
103 	/* 48 */ "lib-msi",
104 	/* 49 */ "lib-msg",
105 	/* 50 */ "NULL",
106 	/* 51 */ "NULL",
107 
108 	/* 52 */ "tools",
109 	/* 53 */ "phys_acc",
110 
111 	/* 54 */ "hotplug",
112 	/* LAST */ "unknown"
113 };
114 
115 void
116 px_dbg(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...)
117 {
118 	int cont = bit >> DBG_BITS;
119 	va_list ap;
120 
121 	bit &= DBG_MASK;
122 	if (bit >= sizeof (px_debug_sym) / sizeof (char *))
123 		return;
124 	if (!(1ull << bit & px_debug_flags))
125 		return;
126 	if (cont)
127 		goto body;
128 
129 	if (dip)
130 		prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
131 		    ddi_get_instance(dip), px_debug_sym[bit]);
132 	else
133 		prom_printf("px: %s: ", px_debug_sym[bit]);
134 body:
135 	va_start(ap, fmt);
136 	prom_vprintf(fmt, ap);
137 	va_end(ap);
138 }
139 #endif	/* DEBUG */
140