xref: /titanic_50/usr/src/uts/sun4u/sys/pci/db21554_debug.h (revision 880d797826457b77414b37d531cc3e1aa166ecbe)
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 #ifndef	_SYS_DB21554_DEBUG_H
28 #define	_SYS_DB21554_DEBUG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #if defined(DEBUG)
37 
38 /* driver modload functions */
39 #define	DB_INIT			0x10
40 #define	DB_FINI			0x11
41 #define	DB_INFO			0x12
42 #define	DB_GETINFO		0x13
43 /* driver initialization functions */
44 #define	DB_INIT_FUNCS		0x100
45 #define	DB_ATTACH		0x100
46 #define	DB_DETACH		0x101
47 
48 /* driver child initialization functions */
49 #define	DB_CTLOPS		0x1000
50 #define	DB_INITCHILD		0x1001
51 #define	DB_REMOVECHILD		0x1002
52 #define	DB_INTR_OPS		0x1003
53 
54 /* child driver services invoked during runtime */
55 #define	DB_PCI_MAP		0x10000
56 
57 /* CPR functions */
58 #define	DB_SAVE_CONF_REGS	0x100000
59 #define	DB_REST_CONF_REGS	0x100001
60 
61 /* interrupt function */
62 #define	DB_INTR			0x1000000
63 
64 /* application call functions */
65 #define	DB_OPEN			0x10000000
66 #define	DB_CLOSE		0x10000001
67 #define	DB_IOCTL		0x10000002
68 
69 /* DVMA functions */
70 #define	DB_DVMA			0x100000000
71 
72 /* Function types, to be assigned to db_debug_funcs variable below. */
73 #define	DB_MODLOAD_FUNCS	0x10
74 #define	DB_CHILD_FUNCS		0x1000
75 #define	DB_PCI_MEM_FUNCS	0x10000
76 #define	DB_CPR_FUNCS		0x100000
77 #define	DB_INTR_FUNCS		0x1000000
78 #define	DB_APPL_FUNCS		0x10000000
79 #define	DB_DVMA_FUNCS		0x100000000
80 
81 /*
82  * db_debug_funcs indicates the function types from which the debug messages
83  * are to be displayed.
84  * For example: Set db_debug_funcs = DB_CHILD_FUNCS | DB_PCI_MEM_FUNCS;
85  * to display debug statements in memory map function (DB_PCI_MEM_FUNCS) and
86  * child driver initialization function (DB_CHILD_FUNCS).
87  *
88  * See above for a list of all function types that can be assigned.
89  */
90 static uint64_t	db_debug_funcs = 0;
91 
92 /*
93  * the following flag can be used to the first argument of db_debug
94  * when dip information need not be displayed along with the actual
95  * function debug message. By default it is always displayed.
96  */
97 #define	DB_DONT_DISPLAY_DIP	0x1000000000000000
98 
99 #define	DB_DEBUG0(func_id, dip, fmt)	\
100 	db_debug(func_id, dip, fmt, 0, 0, 0, 0, 0);
101 #define	DB_DEBUG1(func_id, dip, fmt, a1)	\
102 	db_debug(func_id, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
103 #define	DB_DEBUG2(func_id, dip, fmt, a1, a2)	\
104 	db_debug(func_id, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
105 #define	DB_DEBUG3(func_id, dip, fmt, a1, a2, a3)	\
106 	db_debug(func_id, dip, fmt, (uintptr_t)(a1),	\
107 		(uintptr_t)(a2), (uintptr_t)(a3), 0, 0);
108 #define	DB_DEBUG4(func_id, dip, fmt, a1, a2, a3, a4)	\
109 	db_debug(func_id, dip, fmt, (uintptr_t)(a1),	\
110 		(uintptr_t)(a2), (uintptr_t)(a3), \
111 		(uintptr_t)(a4), 0);
112 #define	DB_DEBUG5(func_id, dip, fmt, a1, a2, a3, a4, a5)	\
113 	db_debug(func_id, dip, fmt, (uintptr_t)(a1),	\
114 		(uintptr_t)(a2), (uintptr_t)(a3), \
115 		(uintptr_t)(a4), (uintptr_t)(a5));
116 
117 #else
118 
119 #define	DB_DEBUG0(func_id, dip, fmt)
120 #define	DB_DEBUG1(func_id, dip, fmt, a1)
121 #define	DB_DEBUG2(func_id, dip, fmt, a1, a2)
122 #define	DB_DEBUG3(func_id, dip, fmt, a1, a2, a3)
123 #define	DB_DEBUG4(func_id, dip, fmt, a1, a2, a3, a4)
124 #define	DB_DEBUG5(func_id, dip, fmt, a1, a2, a3, a4, a5)
125 #endif
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif	/* _SYS_DB21554_DEBUG_H */
132