]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/ray/if_raydbg.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / ray / if_raydbg.h
1 /*-
2  * Copyright (C) 2000
3  * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the author nor the names of any co-contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL DUNCAN BARCLAY OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $FreeBSD$
32  *
33  */
34
35 /*
36  * Debugging odds and odds
37  */
38
39 /*
40  * RAY_DEBUG settings
41  *
42  *      AUTH            Authentication
43  *      SUBR            Subroutine entry
44  *      BOOTPARAM       Startup CM dump
45  *      STARTJOIN       State transitions for start/join
46  *      CCS             CCS info
47  *      IOCTL           IOCTL calls
48  *      MBUF            MBUFs dumped - needs one of TX, RX, MGT, or CTL
49  *      RX              packet types reported
50  *      CM              common memory re-mapping
51  *      COM             new command sleep/wakeup
52  *      STOP            driver detaching
53  *      CTL             CTL packets
54  *      MGT             MGT packets
55  *      TX              TX routine info
56  *      DCOM            dump comq entries
57  */
58 #define RAY_DBG_AUTH            0x0001
59 #define RAY_DBG_SUBR            0x0002
60 #define RAY_DBG_BOOTPARAM       0x0004
61 #define RAY_DBG_STARTJOIN       0x0008
62 #define RAY_DBG_CCS             0x0010
63 #define RAY_DBG_IOCTL           0x0020
64 #define RAY_DBG_MBUF            0x0080
65 #define RAY_DBG_RX              0x0100
66 #define RAY_DBG_CM              0x0200
67 #define RAY_DBG_COM             0x0400
68 #define RAY_DBG_STOP            0x0800
69 #define RAY_DBG_CTL             0x1000
70 #define RAY_DBG_MGT             0x2000
71 #define RAY_DBG_TX              0x4000
72 #define RAY_DBG_DCOM            0x8000
73 /* Cut and paste this into a kernel configuration file */
74 #if 0
75 #define RAY_DEBUG       (                               \
76                         /* RAY_DBG_SUBR         | */    \
77                         /* RAY_DBG_BOOTPARAM    | */    \
78                         /* RAY_DBG_STARTJOIN    | */    \
79                         /* RAY_DBG_CCS          | */    \
80                         /* RAY_DBG_IOCTL        | */    \
81                         /* RAY_DBG_MBUF         | */    \
82                         /* RAY_DBG_RX           | */    \
83                         /* RAY_DBG_CM           | */    \
84                         /* RAY_DBG_COM          | */    \
85                         /* RAY_DBG_STOP         | */    \
86                         /* RAY_DBG_CTL          | */    \
87                         /* RAY_DBG_MGT          | */    \
88                         /* RAY_DBG_TX           | */    \
89                         /* RAY_DBG_DCOM         | */    \
90                         0                               \
91                         )
92 #endif
93
94 #if RAY_DEBUG
95
96 #define RAY_DPRINTF(sc, mask, fmt, args...) do {if (RAY_DEBUG & (mask)) {\
97     device_printf((sc)->dev, "%s(%d) " fmt "\n",                        \
98         __func__ , __LINE__ , ##args);                                  \
99 } } while (0)
100
101 /* This macro assumes that common memory is mapped into kernel space */
102 #define RAY_DHEX8(sc, mask, off, len, s) do { if (RAY_DEBUG & (mask)) { \
103     int i, j;                                                           \
104     device_printf((sc)->dev, "%s(%d) %s\n",                             \
105         __func__ , __LINE__ , (s));                                     \
106     for (i = (off); i < (off)+(len); i += 8) {                          \
107             printf(".  0x%04x ", i);                                    \
108             for (j = 0; j < 8; j++)                                     \
109                     printf("%02x ", SRAM_READ_1((sc), i+j));            \
110             printf("\n");                                               \
111     }                                                                   \
112 } } while (0)
113
114 #define RAY_DCOM(sc, mask, com, s) do { if (RAY_DEBUG & (mask)) {       \
115     device_printf((sc)->dev, "%s(%d) %s com entry 0x%p\n",              \
116         __func__ , __LINE__ , (s) , (com));                             \
117     printf(".  c_mesg %s\n", (com)->c_mesg);                            \
118     printf(".  c_flags 0x%b\n", (com)->c_flags, RAY_COM_FLAGS_PRINTFB); \
119     printf(".  c_retval 0x%x\n", (com)->c_retval);                      \
120     printf(".  c_ccs 0x%0x index 0x%02x\n",                             \
121         (com)->c_ccs, RAY_CCS_INDEX((com)->c_ccs));                     \
122 } } while (0)
123
124 #else
125 #define RAY_DPRINTF(sc, mask, fmt, args...)
126 #define RAY_DHEX8(sc, mask, off, len, s)
127 #define RAY_DCOM(sc, mask, com, s)
128 #endif /* RAY_DEBUG > 0 */
129
130 /*
131  * These override macros defined in if_ray.c to turn them into
132  * debugging ones.
133  */
134 #if RAY_DEBUG
135 #define RAY_RECERR(sc, fmt, args...) do {                               \
136     device_printf((sc)->dev, "%s(%d) " fmt "\n",                        \
137         __func__ , __LINE__ , ##args);                                  \
138 } while (0)
139 #endif /* RAY_DEBUG */
140
141 #if RAY_DEBUG & RAY_DBG_COM
142 #define RAY_COM_CHECK(sc, com) do { if (RAY_DEBUG & RAY_DBG_COM) {      \
143     ray_com_ecf_check((sc), (com), __func__ );                          \
144 } } while (0)
145 #endif /* RAY_DEBUG & RAY_DBG_COM */
146
147 #if RAY_DEBUG & RAY_DBG_MBUF
148 #define RAY_MBUF_DUMP(sc, mask, m, s)   do { if (RAY_DEBUG & (mask)) {  \
149     ray_dump_mbuf((sc), (m), (s));                                      \
150 } } while (0)
151 #endif /* RAY_DEBUG & RAY_DBG_MBUF */