Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/dktp/dcdev/gda.c
+++ new/usr/src/uts/intel/io/dktp/dcdev/gda.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #include <sys/scsi/scsi.h>
28 28
29 29 #include <sys/dktp/dadev.h>
30 30 #include <sys/dktp/gda.h>
31 31
32 32 /*
33 33 * Generic Direct Attached Device
34 34 */
35 35
36 36 static char *gda_name(uchar_t cmd, char **cmdvec);
37 37
38 38 #ifdef GDA_DEBUG
39 39 #define DENT 0x0001
40 40 #define DPKT 0x0002
41 41 #define DERR 0x0004
42 42 static int gda_debug = DERR|DENT|DPKT;
43 43
44 44 #endif /* GDA_DEBUG */
45 45
46 46 /*
47 47 * Local static data
48 48 */
49 49
50 50 /*
51 51 * global data
52 52 */
53 53
54 54 /*
55 55 * This is the loadable module wrapper
56 56 */
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
57 57 #include <sys/modctl.h>
58 58
59 59 extern struct mod_ops mod_miscops;
60 60
61 61 static struct modlmisc modlmisc = {
62 62 &mod_miscops, /* Type of module */
63 63 "Generic Direct Attached Device Utilities"
64 64 };
65 65
66 66 static struct modlinkage modlinkage = {
67 - MODREV_1, (void *)&modlmisc, NULL
67 + MODREV_1, { (void *)&modlmisc, NULL }
68 68 };
69 69
70 70 int
71 71 _init(void)
72 72 {
73 73 return (mod_install(&modlinkage));
74 74 }
75 75
76 76 int
77 77 _fini(void)
78 78 {
79 79 #ifdef GDA_DEBUG
80 80 if (gda_debug & DENT)
81 81 PRF("gda_fini: call\n");
82 82 #endif
83 83 return (mod_remove(&modlinkage));
84 84 }
85 85
86 86 int
87 87 _info(struct modinfo *modinfop)
88 88 {
89 89 return (mod_info(&modlinkage, modinfop));
90 90 }
91 91
92 92
93 93 void
94 94 gda_inqfill(char *p, int l, char *s)
95 95 {
96 96 register unsigned i = 0, c;
97 97
98 98 if (!p)
99 99 return;
100 100 while (i++ < l) {
101 101 /* clean strings of non-printing chars */
102 102 if ((c = *p++) < ' ' || c > 0176) {
103 103 c = ' ';
104 104 }
105 105 *s++ = (char)c;
106 106 }
107 107 *s++ = 0;
108 108 }
109 109
110 110 static char *
111 111 gda_name(uchar_t cmd, char **cmdvec)
112 112 {
113 113 while (*cmdvec != NULL) {
114 114 if (cmd == **cmdvec) {
115 115 return (*cmdvec + 1);
116 116 }
117 117 cmdvec++;
118 118 }
119 119 return ("<undecoded cmd>");
120 120 }
121 121
122 122
123 123 struct cmpkt *
124 124 gda_pktprep(opaque_t objp, struct cmpkt *in_pktp, opaque_t dmatoken,
125 125 int (*callback)(caddr_t), caddr_t arg)
126 126 {
127 127 register struct cmpkt *pktp;
128 128 register struct buf *bp = (struct buf *)dmatoken;
129 129
130 130 if (in_pktp) {
131 131 pktp = in_pktp;
132 132 } else {
133 133 pktp = CTL_PKTALLOC(objp, callback, arg);
134 134 if (pktp == NULL)
135 135 return (NULL);
136 136 }
137 137
138 138 if (bp) {
139 139 if (bp->b_bcount) {
140 140 if (CTL_MEMSETUP(objp, pktp, bp, callback, arg) ==
141 141 NULL) {
142 142 if (!in_pktp)
143 143 CTL_PKTFREE(objp, pktp);
144 144 return (NULL);
145 145 }
146 146 }
147 147 bp->av_back = (struct buf *)pktp;
148 148 pktp->cp_bp = bp;
149 149 }
150 150 pktp->cp_retry = 0;
151 151 pktp->cp_objp = objp;
152 152
153 153
154 154 #ifdef GDA_DEBUG
155 155 if (gda_debug & DPKT)
156 156 PRF("gda_pktprep: pktp=0x%x \n", pktp);
157 157 #endif
158 158 return (pktp);
159 159 }
160 160
161 161 void
162 162 gda_free(opaque_t objp, struct cmpkt *pktp, struct buf *bp)
163 163 {
164 164 if (pktp) {
165 165 CTL_MEMFREE(objp, pktp);
166 166 CTL_PKTFREE(objp, pktp);
167 167 }
168 168
169 169 if (bp) {
170 170 if (bp->b_un.b_addr)
171 171 i_ddi_mem_free((caddr_t)bp->b_un.b_addr, NULL);
172 172 freerbuf(bp);
173 173 }
174 174 }
175 175
176 176 void
177 177 gda_log(dev_info_t *dev, char *label, uint_t level, const char *fmt, ...)
178 178 {
179 179 auto char name[256];
180 180 auto char buf [256];
181 181 va_list ap;
182 182 int log_only = 0;
183 183 int boot_only = 0;
184 184 int console_only = 0;
185 185
186 186 switch (*fmt) {
187 187 case '!':
188 188 log_only = 1;
189 189 fmt++;
190 190 break;
191 191 case '?':
192 192 boot_only = 1;
193 193 fmt++;
194 194 break;
195 195 case '^':
196 196 console_only = 1;
197 197 fmt++;
198 198 break;
199 199 }
200 200
201 201
202 202 if (dev) {
203 203 if (level == CE_PANIC || level == CE_WARN) {
204 204 (void) sprintf(name, "%s (%s%d):\n",
205 205 ddi_pathname(dev, buf), label,
206 206 ddi_get_instance(dev));
207 207 } else if (level == CE_NOTE ||
208 208 level >= (uint_t)SCSI_DEBUG) {
209 209 (void) sprintf(name,
210 210 "%s%d:", label, ddi_get_instance(dev));
211 211 } else if (level == CE_CONT) {
212 212 name[0] = '\0';
213 213 }
214 214 } else {
215 215 (void) sprintf(name, "%s:", label);
216 216 }
217 217
218 218 va_start(ap, fmt);
219 219 (void) vsprintf(buf, fmt, ap);
220 220 va_end(ap);
221 221
222 222 switch (level) {
223 223 case CE_NOTE:
224 224 level = CE_CONT;
225 225 /* FALLTHROUGH */
226 226 case CE_CONT:
227 227 case CE_WARN:
228 228 case CE_PANIC:
229 229 if (boot_only) {
230 230 cmn_err(level, "?%s\t%s", name, buf);
231 231 } else if (console_only) {
232 232 cmn_err(level, "^%s\t%s", name, buf);
233 233 } else if (log_only) {
234 234 cmn_err(level, "!%s\t%s", name, buf);
235 235 } else {
236 236 cmn_err(level, "%s\t%s", name, buf);
237 237 }
238 238 break;
239 239 default:
240 240 cmn_err(CE_CONT, "^DEBUG: %s\t%s", name, buf);
241 241 break;
242 242 }
243 243 }
244 244
245 245 void
246 246 gda_errmsg(struct scsi_device *devp, struct cmpkt *pktp, char *label,
247 247 int severity, daddr_t blkno, daddr_t err_blkno,
248 248 char **cmdvec, char **senvec)
249 249 {
250 250 auto char buf[256];
251 251 dev_info_t *dev = devp->sd_dev;
252 252 static char *error_classes[] = {
253 253 "All", "Unknown", "Informational",
254 254 "Recovered", "Retryable", "Fatal"
255 255 };
256 256
257 257 bzero((caddr_t)buf, 256);
258 258 (void) sprintf(buf, "Error for command '%s'\tError Level: %s",
259 259 gda_name(*(uchar_t *)pktp->cp_cdbp, cmdvec),
260 260 error_classes[severity]);
261 261 gda_log(dev, label, CE_WARN, buf);
262 262
263 263 bzero((caddr_t)buf, 256);
264 264 if ((blkno != -1) && (err_blkno != -1)) {
265 265 (void) sprintf(buf, "Requested Block %ld, Error Block: %ld\n",
266 266 blkno, err_blkno);
267 267 gda_log(dev, label, CE_CONT, buf);
268 268 }
269 269
270 270 bzero((caddr_t)buf, 256);
271 271 (void) sprintf(buf, "Sense Key: %s\n",
272 272 gda_name(*(uchar_t *)pktp->cp_scbp, senvec));
273 273
274 274 gda_log(dev, label, CE_CONT, buf);
275 275 bzero((caddr_t)buf, 256);
276 276 (void) strcpy(buf, "Vendor '");
277 277 gda_inqfill(devp->sd_inq->inq_vid, 8, &buf[strlen(buf)]);
278 278 (void) sprintf(&buf[strlen(buf)],
279 279 "' error code: 0x%x",
280 280 *(uchar_t *)pktp->cp_scbp);
281 281 gda_log(dev, label, CE_CONT, "%s\n", buf);
282 282 }
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX