xref: /titanic_50/usr/src/uts/sun4/io/px/px_debug.c (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * PCI nexus driver general debug support
31  */
32 #include <sys/async.h>
33 #include <sys/sunddi.h>		/* dev_info_t */
34 #include <sys/ddi_impldefs.h>
35 #include <sys/disp.h>
36 #include "px_debug.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",
51 	/*  6 */ "intx-rem",
52 	/*  7 */ "intx-intr",
53 
54 	/*  8 */ "msiq",
55 	/*  9 */ "msiq-intr",
56 	/* 10 */ "msg",
57 	/* 11 */ "msg-intr",
58 
59 	/* 12 */ "msix-add",
60 	/* 13 */ "msix-rem",
61 	/* 14 */ "msix-intr",
62 	/* 15 */ "err",
63 
64 	/* 16 */ "dma-alloc",
65 	/* 17 */ "dma-free",
66 	/* 18 */ "dma-bind",
67 	/* 19 */ "dma-unbind",
68 
69 	/* 20 */ "chk-dma-mode",
70 	/* 21 */ "bypass-dma",
71 	/* 22 */ "fast-dvma",
72 	/* 23 */ "init_child",
73 
74 	/* 24 */ "dma-map",
75 	/* 25 */ "dma-win",
76 	/* 26 */ "map-win",
77 	/* 27 */ "unmap-win",
78 
79 	/* 28 */ "dma-ctl",
80 	/* 29 */ "dma-sync",
81 	/* 30 */ NULL,
82 	/* 31 */ NULL,
83 
84 	/* 32 */ "ib",
85 	/* 33 */ "cb",
86 	/* 34 */ "dmc",
87 	/* 35 */ "pec",
88 
89 	/* 36 */ "ilu",
90 	/* 37 */ "tlu",
91 	/* 38 */ "lpu",
92 	/* 39 */ NULL,
93 
94 	/* 40 */ "open",
95 	/* 41 */ "close",
96 	/* 42 */ "ioctl",
97 	/* 43 */ "pwr",
98 
99 	/* 44 */ "lib-cfg",
100 	/* 45 */ "lib-intr",
101 	/* 46 */ "lib-dma",
102 	/* 47 */ "lib-msiq",
103 
104 	/* 48 */ "lib-msi",
105 	/* 49 */ "lib-msg",
106 	/* 50 */ "NULL",
107 	/* 51 */ "NULL",
108 
109 	/* 52 */ "tools",
110 	/* 53 */ "phys_acc",
111 	/* LAST */ "unknown"
112 };
113 
114 void
115 px_dbg(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...)
116 {
117 	int cont = bit >> DBG_BITS;
118 	va_list ap;
119 
120 	bit &= DBG_MASK;
121 	if (bit >= sizeof (px_debug_sym) / sizeof (char *))
122 		return;
123 	if (!(1ull << bit & px_debug_flags))
124 		return;
125 	if (cont)
126 		goto body;
127 
128 	if (dip)
129 		prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
130 		    ddi_get_instance(dip), px_debug_sym[bit]);
131 	else
132 		prom_printf("px: %s: ", px_debug_sym[bit]);
133 body:
134 	va_start(ap, fmt);
135 	prom_vprintf(fmt, ap);
136 	va_end(ap);
137 }
138 #endif	/* DEBUG */
139