xref: /illumos-gate/usr/src/uts/common/io/cxgbe/t4nex/t4_ioctl.c (revision 5cc82207c6bb1a6b9b4a68cc33698dd1e4a61e28)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source. A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * This file is part of the Chelsio T4 support code.
14  *
15  * Copyright (C) 2011-2013 Chelsio Communications.  All rights reserved.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE.  See the LICENSE file included in this
20  * release for licensing terms and conditions.
21  */
22 
23 #include <sys/ddi.h>
24 #include <sys/sunddi.h>
25 #include <sys/queue.h>
26 
27 #include "t4nex.h"
28 #include "common/common.h"
29 #include "common/t4_regs.h"
30 #include "cudbg.h"
31 
32 /* helpers */
33 static int pci_rw(struct adapter *sc, void *data, int flags, int write);
34 static int reg_rw(struct adapter *sc, void *data, int flags, int write);
35 static void reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
36     unsigned int end);
37 static int regdump(struct adapter *sc, void *data, int flags);
38 static int get_devlog(struct adapter *sc, void *data, int flags);
39 static int flash_fw(struct adapter *, void *, int);
40 static int get_cudbg(struct adapter *, void *, int);
41 
42 int
t4_ioctl(struct adapter * sc,int cmd,void * data,int mode)43 t4_ioctl(struct adapter *sc, int cmd, void *data, int mode)
44 {
45 	int rc = ENOTSUP;
46 
47 	switch (cmd) {
48 	case T4_IOCTL_PCIGET32:
49 	case T4_IOCTL_PCIPUT32:
50 		rc = pci_rw(sc, data, mode, cmd == T4_IOCTL_PCIPUT32);
51 		break;
52 	case T4_IOCTL_GET32:
53 	case T4_IOCTL_PUT32:
54 		rc = reg_rw(sc, data, mode, cmd == T4_IOCTL_PUT32);
55 		break;
56 	case T4_IOCTL_REGDUMP:
57 		rc = regdump(sc, data, mode);
58 		break;
59 	case T4_IOCTL_DEVLOG:
60 		rc = get_devlog(sc, data, mode);
61 		break;
62 	case T4_IOCTL_LOAD_FW:
63 		rc = flash_fw(sc, data, mode);
64 		break;
65 	case T4_IOCTL_GET_CUDBG:
66 		rc = get_cudbg(sc, data, mode);
67 		break;
68 	default:
69 		return (EINVAL);
70 	}
71 
72 	return (rc);
73 }
74 
75 static int
pci_rw(struct adapter * sc,void * data,int flags,int write)76 pci_rw(struct adapter *sc, void *data, int flags, int write)
77 {
78 	struct t4_reg32_cmd r;
79 
80 	if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
81 		return (EFAULT);
82 
83 	/* address must be 32 bit aligned */
84 	r.reg &= ~0x3;
85 
86 	if (write != 0)
87 		t4_os_pci_write_cfg4(sc, r.reg, r.value);
88 	else {
89 		t4_os_pci_read_cfg4(sc, r.reg, &r.value);
90 		if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
91 			return (EFAULT);
92 	}
93 
94 	return (0);
95 }
96 
97 static int
reg_rw(struct adapter * sc,void * data,int flags,int write)98 reg_rw(struct adapter *sc, void *data, int flags, int write)
99 {
100 	struct t4_reg32_cmd r;
101 
102 	if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
103 		return (EFAULT);
104 
105 	/* Register address must be 32 bit aligned */
106 	r.reg &= ~0x3;
107 
108 	if (write != 0)
109 		t4_write_reg(sc, r.reg, r.value);
110 	else {
111 		r.value = t4_read_reg(sc, r.reg);
112 		if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
113 			return (EFAULT);
114 	}
115 
116 	return (0);
117 }
118 
119 static void
reg_block_dump(struct adapter * sc,uint8_t * buf,unsigned int start,unsigned int end)120 reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
121     unsigned int end)
122 {
123 	/* LINTED: E_BAD_PTR_CAST_ALIGN */
124 	uint32_t *p = (uint32_t *)(buf + start);
125 
126 	for (/* */; start <= end; start += sizeof (uint32_t))
127 		*p++ = t4_read_reg(sc, start);
128 }
129 
130 /*
131  * Return a version number to identify the type of adapter.  The scheme is:
132  * - bits 0..9: chip version
133  * - bits 10..15: chip revision
134  * - bits 16..23: register dump version
135  */
136 static inline unsigned int
mk_adap_vers(const struct adapter * sc)137 mk_adap_vers(const struct adapter *sc)
138 {
139 	return (CHELSIO_CHIP_VERSION(sc->params.chip) |
140 	    (CHELSIO_CHIP_RELEASE(sc->params.chip) << 10) | (1 << 16));
141 }
142 
143 static int
regdump(struct adapter * sc,void * data,int flags)144 regdump(struct adapter *sc, void *data, int flags)
145 {
146 	struct t4_regdump r;
147 	uint8_t *buf;
148 	static const unsigned int *reg_ranges;
149 	int rc = 0, arr_size = 0, buf_size = 0, i;
150 	static const unsigned int t4_reg_ranges[] = {
151 		0x1008, 0x1108,
152 		0x1180, 0x11b4,
153 		0x11fc, 0x123c,
154 		0x1300, 0x173c,
155 		0x1800, 0x18fc,
156 		0x3000, 0x30d8,
157 		0x30e0, 0x5924,
158 		0x5960, 0x59d4,
159 		0x5a00, 0x5af8,
160 		0x6000, 0x6098,
161 		0x6100, 0x6150,
162 		0x6200, 0x6208,
163 		0x6240, 0x6248,
164 		0x6280, 0x6338,
165 		0x6370, 0x638c,
166 		0x6400, 0x643c,
167 		0x6500, 0x6524,
168 		0x6a00, 0x6a38,
169 		0x6a60, 0x6a78,
170 		0x6b00, 0x6b84,
171 		0x6bf0, 0x6c84,
172 		0x6cf0, 0x6d84,
173 		0x6df0, 0x6e84,
174 		0x6ef0, 0x6f84,
175 		0x6ff0, 0x7084,
176 		0x70f0, 0x7184,
177 		0x71f0, 0x7284,
178 		0x72f0, 0x7384,
179 		0x73f0, 0x7450,
180 		0x7500, 0x7530,
181 		0x7600, 0x761c,
182 		0x7680, 0x76cc,
183 		0x7700, 0x7798,
184 		0x77c0, 0x77fc,
185 		0x7900, 0x79fc,
186 		0x7b00, 0x7c38,
187 		0x7d00, 0x7efc,
188 		0x8dc0, 0x8e1c,
189 		0x8e30, 0x8e78,
190 		0x8ea0, 0x8f6c,
191 		0x8fc0, 0x9074,
192 		0x90fc, 0x90fc,
193 		0x9400, 0x9458,
194 		0x9600, 0x96bc,
195 		0x9800, 0x9808,
196 		0x9820, 0x983c,
197 		0x9850, 0x9864,
198 		0x9c00, 0x9c6c,
199 		0x9c80, 0x9cec,
200 		0x9d00, 0x9d6c,
201 		0x9d80, 0x9dec,
202 		0x9e00, 0x9e6c,
203 		0x9e80, 0x9eec,
204 		0x9f00, 0x9f6c,
205 		0x9f80, 0x9fec,
206 		0xd004, 0xd03c,
207 		0xdfc0, 0xdfe0,
208 		0xe000, 0xea7c,
209 		0xf000, 0x11190,
210 		0x19040, 0x19124,
211 		0x19150, 0x191b0,
212 		0x191d0, 0x191e8,
213 		0x19238, 0x1924c,
214 		0x193f8, 0x19474,
215 		0x19490, 0x194f8,
216 		0x19800, 0x19f30,
217 		0x1a000, 0x1a06c,
218 		0x1a0b0, 0x1a120,
219 		0x1a128, 0x1a138,
220 		0x1a190, 0x1a1c4,
221 		0x1a1fc, 0x1a1fc,
222 		0x1e040, 0x1e04c,
223 		0x1e240, 0x1e28c,
224 		0x1e2c0, 0x1e2c0,
225 		0x1e2e0, 0x1e2e0,
226 		0x1e300, 0x1e384,
227 		0x1e3c0, 0x1e3c8,
228 		0x1e440, 0x1e44c,
229 		0x1e640, 0x1e68c,
230 		0x1e6c0, 0x1e6c0,
231 		0x1e6e0, 0x1e6e0,
232 		0x1e700, 0x1e784,
233 		0x1e7c0, 0x1e7c8,
234 		0x1e840, 0x1e84c,
235 		0x1ea40, 0x1ea8c,
236 		0x1eac0, 0x1eac0,
237 		0x1eae0, 0x1eae0,
238 		0x1eb00, 0x1eb84,
239 		0x1ebc0, 0x1ebc8,
240 		0x1ec40, 0x1ec4c,
241 		0x1ee40, 0x1ee8c,
242 		0x1eec0, 0x1eec0,
243 		0x1eee0, 0x1eee0,
244 		0x1ef00, 0x1ef84,
245 		0x1efc0, 0x1efc8,
246 		0x1f040, 0x1f04c,
247 		0x1f240, 0x1f28c,
248 		0x1f2c0, 0x1f2c0,
249 		0x1f2e0, 0x1f2e0,
250 		0x1f300, 0x1f384,
251 		0x1f3c0, 0x1f3c8,
252 		0x1f440, 0x1f44c,
253 		0x1f640, 0x1f68c,
254 		0x1f6c0, 0x1f6c0,
255 		0x1f6e0, 0x1f6e0,
256 		0x1f700, 0x1f784,
257 		0x1f7c0, 0x1f7c8,
258 		0x1f840, 0x1f84c,
259 		0x1fa40, 0x1fa8c,
260 		0x1fac0, 0x1fac0,
261 		0x1fae0, 0x1fae0,
262 		0x1fb00, 0x1fb84,
263 		0x1fbc0, 0x1fbc8,
264 		0x1fc40, 0x1fc4c,
265 		0x1fe40, 0x1fe8c,
266 		0x1fec0, 0x1fec0,
267 		0x1fee0, 0x1fee0,
268 		0x1ff00, 0x1ff84,
269 		0x1ffc0, 0x1ffc8,
270 		0x20000, 0x2002c,
271 		0x20100, 0x2013c,
272 		0x20190, 0x201c8,
273 		0x20200, 0x20318,
274 		0x20400, 0x20528,
275 		0x20540, 0x20614,
276 		0x21000, 0x21040,
277 		0x2104c, 0x21060,
278 		0x210c0, 0x210ec,
279 		0x21200, 0x21268,
280 		0x21270, 0x21284,
281 		0x212fc, 0x21388,
282 		0x21400, 0x21404,
283 		0x21500, 0x21518,
284 		0x2152c, 0x2153c,
285 		0x21550, 0x21554,
286 		0x21600, 0x21600,
287 		0x21608, 0x21628,
288 		0x21630, 0x2163c,
289 		0x21700, 0x2171c,
290 		0x21780, 0x2178c,
291 		0x21800, 0x21c38,
292 		0x21c80, 0x21d7c,
293 		0x21e00, 0x21e04,
294 		0x22000, 0x2202c,
295 		0x22100, 0x2213c,
296 		0x22190, 0x221c8,
297 		0x22200, 0x22318,
298 		0x22400, 0x22528,
299 		0x22540, 0x22614,
300 		0x23000, 0x23040,
301 		0x2304c, 0x23060,
302 		0x230c0, 0x230ec,
303 		0x23200, 0x23268,
304 		0x23270, 0x23284,
305 		0x232fc, 0x23388,
306 		0x23400, 0x23404,
307 		0x23500, 0x23518,
308 		0x2352c, 0x2353c,
309 		0x23550, 0x23554,
310 		0x23600, 0x23600,
311 		0x23608, 0x23628,
312 		0x23630, 0x2363c,
313 		0x23700, 0x2371c,
314 		0x23780, 0x2378c,
315 		0x23800, 0x23c38,
316 		0x23c80, 0x23d7c,
317 		0x23e00, 0x23e04,
318 		0x24000, 0x2402c,
319 		0x24100, 0x2413c,
320 		0x24190, 0x241c8,
321 		0x24200, 0x24318,
322 		0x24400, 0x24528,
323 		0x24540, 0x24614,
324 		0x25000, 0x25040,
325 		0x2504c, 0x25060,
326 		0x250c0, 0x250ec,
327 		0x25200, 0x25268,
328 		0x25270, 0x25284,
329 		0x252fc, 0x25388,
330 		0x25400, 0x25404,
331 		0x25500, 0x25518,
332 		0x2552c, 0x2553c,
333 		0x25550, 0x25554,
334 		0x25600, 0x25600,
335 		0x25608, 0x25628,
336 		0x25630, 0x2563c,
337 		0x25700, 0x2571c,
338 		0x25780, 0x2578c,
339 		0x25800, 0x25c38,
340 		0x25c80, 0x25d7c,
341 		0x25e00, 0x25e04,
342 		0x26000, 0x2602c,
343 		0x26100, 0x2613c,
344 		0x26190, 0x261c8,
345 		0x26200, 0x26318,
346 		0x26400, 0x26528,
347 		0x26540, 0x26614,
348 		0x27000, 0x27040,
349 		0x2704c, 0x27060,
350 		0x270c0, 0x270ec,
351 		0x27200, 0x27268,
352 		0x27270, 0x27284,
353 		0x272fc, 0x27388,
354 		0x27400, 0x27404,
355 		0x27500, 0x27518,
356 		0x2752c, 0x2753c,
357 		0x27550, 0x27554,
358 		0x27600, 0x27600,
359 		0x27608, 0x27628,
360 		0x27630, 0x2763c,
361 		0x27700, 0x2771c,
362 		0x27780, 0x2778c,
363 		0x27800, 0x27c38,
364 		0x27c80, 0x27d7c,
365 		0x27e00, 0x27e04,
366 	};
367 
368 	static const unsigned int t5_reg_ranges[] = {
369 		0x1008, 0x10c0,
370 		0x10cc, 0x10f8,
371 		0x1100, 0x1100,
372 		0x110c, 0x1148,
373 		0x1180, 0x1184,
374 		0x1190, 0x1194,
375 		0x11a0, 0x11a4,
376 		0x11b0, 0x11b4,
377 		0x11fc, 0x123c,
378 		0x1280, 0x173c,
379 		0x1800, 0x18fc,
380 		0x3000, 0x3028,
381 		0x3060, 0x30b0,
382 		0x30b8, 0x30d8,
383 		0x30e0, 0x30fc,
384 		0x3140, 0x357c,
385 		0x35a8, 0x35cc,
386 		0x35ec, 0x35ec,
387 		0x3600, 0x5624,
388 		0x56cc, 0x56ec,
389 		0x56f4, 0x5720,
390 		0x5728, 0x575c,
391 		0x580c, 0x5814,
392 		0x5890, 0x589c,
393 		0x58a4, 0x58ac,
394 		0x58b8, 0x58bc,
395 		0x5940, 0x59c8,
396 		0x59d0, 0x59dc,
397 		0x59fc, 0x5a18,
398 		0x5a60, 0x5a70,
399 		0x5a80, 0x5a9c,
400 		0x5b94, 0x5bfc,
401 		0x6000, 0x6020,
402 		0x6028, 0x6040,
403 		0x6058, 0x609c,
404 		0x60a8, 0x614c,
405 		0x7700, 0x7798,
406 		0x77c0, 0x78fc,
407 		0x7b00, 0x7b58,
408 		0x7b60, 0x7b84,
409 		0x7b8c, 0x7c54,
410 		0x7d00, 0x7d38,
411 		0x7d40, 0x7d80,
412 		0x7d8c, 0x7ddc,
413 		0x7de4, 0x7e04,
414 		0x7e10, 0x7e1c,
415 		0x7e24, 0x7e38,
416 		0x7e40, 0x7e44,
417 		0x7e4c, 0x7e78,
418 		0x7e80, 0x7edc,
419 		0x7ee8, 0x7efc,
420 		0x8dc0, 0x8de0,
421 		0x8df8, 0x8e04,
422 		0x8e10, 0x8e84,
423 		0x8ea0, 0x8f84,
424 		0x8fc0, 0x9058,
425 		0x9060, 0x9060,
426 		0x9068, 0x90f8,
427 		0x9400, 0x9408,
428 		0x9410, 0x9470,
429 		0x9600, 0x9600,
430 		0x9608, 0x9638,
431 		0x9640, 0x96f4,
432 		0x9800, 0x9808,
433 		0x9820, 0x983c,
434 		0x9850, 0x9864,
435 		0x9c00, 0x9c6c,
436 		0x9c80, 0x9cec,
437 		0x9d00, 0x9d6c,
438 		0x9d80, 0x9dec,
439 		0x9e00, 0x9e6c,
440 		0x9e80, 0x9eec,
441 		0x9f00, 0x9f6c,
442 		0x9f80, 0xa020,
443 		0xd004, 0xd004,
444 		0xd010, 0xd03c,
445 		0xdfc0, 0xdfe0,
446 		0xe000, 0x1106c,
447 		0x11074, 0x11088,
448 		0x1109c, 0x1117c,
449 		0x11190, 0x11204,
450 		0x19040, 0x1906c,
451 		0x19078, 0x19080,
452 		0x1908c, 0x190e8,
453 		0x190f0, 0x190f8,
454 		0x19100, 0x19110,
455 		0x19120, 0x19124,
456 		0x19150, 0x19194,
457 		0x1919c, 0x191b0,
458 		0x191d0, 0x191e8,
459 		0x19238, 0x19290,
460 		0x193f8, 0x19428,
461 		0x19430, 0x19444,
462 		0x1944c, 0x1946c,
463 		0x19474, 0x19474,
464 		0x19490, 0x194cc,
465 		0x194f0, 0x194f8,
466 		0x19c00, 0x19c08,
467 		0x19c10, 0x19c60,
468 		0x19c94, 0x19ce4,
469 		0x19cf0, 0x19d40,
470 		0x19d50, 0x19d94,
471 		0x19da0, 0x19de8,
472 		0x19df0, 0x19e10,
473 		0x19e50, 0x19e90,
474 		0x19ea0, 0x19f24,
475 		0x19f34, 0x19f34,
476 		0x19f40, 0x19f50,
477 		0x19f90, 0x19fb4,
478 		0x19fc4, 0x19fe4,
479 		0x1a000, 0x1a004,
480 		0x1a010, 0x1a06c,
481 		0x1a0b0, 0x1a0e4,
482 		0x1a0ec, 0x1a0f8,
483 		0x1a100, 0x1a108,
484 		0x1a114, 0x1a120,
485 		0x1a128, 0x1a130,
486 		0x1a138, 0x1a138,
487 		0x1a190, 0x1a1c4,
488 		0x1a1fc, 0x1a1fc,
489 		0x1e008, 0x1e00c,
490 		0x1e040, 0x1e044,
491 		0x1e04c, 0x1e04c,
492 		0x1e284, 0x1e290,
493 		0x1e2c0, 0x1e2c0,
494 		0x1e2e0, 0x1e2e0,
495 		0x1e300, 0x1e384,
496 		0x1e3c0, 0x1e3c8,
497 		0x1e408, 0x1e40c,
498 		0x1e440, 0x1e444,
499 		0x1e44c, 0x1e44c,
500 		0x1e684, 0x1e690,
501 		0x1e6c0, 0x1e6c0,
502 		0x1e6e0, 0x1e6e0,
503 		0x1e700, 0x1e784,
504 		0x1e7c0, 0x1e7c8,
505 		0x1e808, 0x1e80c,
506 		0x1e840, 0x1e844,
507 		0x1e84c, 0x1e84c,
508 		0x1ea84, 0x1ea90,
509 		0x1eac0, 0x1eac0,
510 		0x1eae0, 0x1eae0,
511 		0x1eb00, 0x1eb84,
512 		0x1ebc0, 0x1ebc8,
513 		0x1ec08, 0x1ec0c,
514 		0x1ec40, 0x1ec44,
515 		0x1ec4c, 0x1ec4c,
516 		0x1ee84, 0x1ee90,
517 		0x1eec0, 0x1eec0,
518 		0x1eee0, 0x1eee0,
519 		0x1ef00, 0x1ef84,
520 		0x1efc0, 0x1efc8,
521 		0x1f008, 0x1f00c,
522 		0x1f040, 0x1f044,
523 		0x1f04c, 0x1f04c,
524 		0x1f284, 0x1f290,
525 		0x1f2c0, 0x1f2c0,
526 		0x1f2e0, 0x1f2e0,
527 		0x1f300, 0x1f384,
528 		0x1f3c0, 0x1f3c8,
529 		0x1f408, 0x1f40c,
530 		0x1f440, 0x1f444,
531 		0x1f44c, 0x1f44c,
532 		0x1f684, 0x1f690,
533 		0x1f6c0, 0x1f6c0,
534 		0x1f6e0, 0x1f6e0,
535 		0x1f700, 0x1f784,
536 		0x1f7c0, 0x1f7c8,
537 		0x1f808, 0x1f80c,
538 		0x1f840, 0x1f844,
539 		0x1f84c, 0x1f84c,
540 		0x1fa84, 0x1fa90,
541 		0x1fac0, 0x1fac0,
542 		0x1fae0, 0x1fae0,
543 		0x1fb00, 0x1fb84,
544 		0x1fbc0, 0x1fbc8,
545 		0x1fc08, 0x1fc0c,
546 		0x1fc40, 0x1fc44,
547 		0x1fc4c, 0x1fc4c,
548 		0x1fe84, 0x1fe90,
549 		0x1fec0, 0x1fec0,
550 		0x1fee0, 0x1fee0,
551 		0x1ff00, 0x1ff84,
552 		0x1ffc0, 0x1ffc8,
553 		0x30000, 0x30030,
554 		0x30038, 0x30038,
555 		0x30040, 0x30040,
556 		0x30100, 0x30144,
557 		0x30190, 0x301a0,
558 		0x301a8, 0x301b8,
559 		0x301c4, 0x301c8,
560 		0x301d0, 0x301d0,
561 		0x30200, 0x30318,
562 		0x30400, 0x304b4,
563 		0x304c0, 0x3052c,
564 		0x30540, 0x3061c,
565 		0x30800, 0x30828,
566 		0x30834, 0x30834,
567 		0x308c0, 0x30908,
568 		0x30910, 0x309ac,
569 		0x30a00, 0x30a14,
570 		0x30a1c, 0x30a2c,
571 		0x30a44, 0x30a50,
572 		0x30a74, 0x30a74,
573 		0x30a7c, 0x30afc,
574 		0x30b08, 0x30c24,
575 		0x30d00, 0x30d00,
576 		0x30d08, 0x30d14,
577 		0x30d1c, 0x30d20,
578 		0x30d3c, 0x30d3c,
579 		0x30d48, 0x30d50,
580 		0x31200, 0x3120c,
581 		0x31220, 0x31220,
582 		0x31240, 0x31240,
583 		0x31600, 0x3160c,
584 		0x31a00, 0x31a1c,
585 		0x31e00, 0x31e20,
586 		0x31e38, 0x31e3c,
587 		0x31e80, 0x31e80,
588 		0x31e88, 0x31ea8,
589 		0x31eb0, 0x31eb4,
590 		0x31ec8, 0x31ed4,
591 		0x31fb8, 0x32004,
592 		0x32200, 0x32200,
593 		0x32208, 0x32240,
594 		0x32248, 0x32280,
595 		0x32288, 0x322c0,
596 		0x322c8, 0x322fc,
597 		0x32600, 0x32630,
598 		0x32a00, 0x32abc,
599 		0x32b00, 0x32b10,
600 		0x32b20, 0x32b30,
601 		0x32b40, 0x32b50,
602 		0x32b60, 0x32b70,
603 		0x33000, 0x33028,
604 		0x33030, 0x33048,
605 		0x33060, 0x33068,
606 		0x33070, 0x3309c,
607 		0x330f0, 0x33128,
608 		0x33130, 0x33148,
609 		0x33160, 0x33168,
610 		0x33170, 0x3319c,
611 		0x331f0, 0x33238,
612 		0x33240, 0x33240,
613 		0x33248, 0x33250,
614 		0x3325c, 0x33264,
615 		0x33270, 0x332b8,
616 		0x332c0, 0x332e4,
617 		0x332f8, 0x33338,
618 		0x33340, 0x33340,
619 		0x33348, 0x33350,
620 		0x3335c, 0x33364,
621 		0x33370, 0x333b8,
622 		0x333c0, 0x333e4,
623 		0x333f8, 0x33428,
624 		0x33430, 0x33448,
625 		0x33460, 0x33468,
626 		0x33470, 0x3349c,
627 		0x334f0, 0x33528,
628 		0x33530, 0x33548,
629 		0x33560, 0x33568,
630 		0x33570, 0x3359c,
631 		0x335f0, 0x33638,
632 		0x33640, 0x33640,
633 		0x33648, 0x33650,
634 		0x3365c, 0x33664,
635 		0x33670, 0x336b8,
636 		0x336c0, 0x336e4,
637 		0x336f8, 0x33738,
638 		0x33740, 0x33740,
639 		0x33748, 0x33750,
640 		0x3375c, 0x33764,
641 		0x33770, 0x337b8,
642 		0x337c0, 0x337e4,
643 		0x337f8, 0x337fc,
644 		0x33814, 0x33814,
645 		0x3382c, 0x3382c,
646 		0x33880, 0x3388c,
647 		0x338e8, 0x338ec,
648 		0x33900, 0x33928,
649 		0x33930, 0x33948,
650 		0x33960, 0x33968,
651 		0x33970, 0x3399c,
652 		0x339f0, 0x33a38,
653 		0x33a40, 0x33a40,
654 		0x33a48, 0x33a50,
655 		0x33a5c, 0x33a64,
656 		0x33a70, 0x33ab8,
657 		0x33ac0, 0x33ae4,
658 		0x33af8, 0x33b10,
659 		0x33b28, 0x33b28,
660 		0x33b3c, 0x33b50,
661 		0x33bf0, 0x33c10,
662 		0x33c28, 0x33c28,
663 		0x33c3c, 0x33c50,
664 		0x33cf0, 0x33cfc,
665 		0x34000, 0x34030,
666 		0x34038, 0x34038,
667 		0x34040, 0x34040,
668 		0x34100, 0x34144,
669 		0x34190, 0x341a0,
670 		0x341a8, 0x341b8,
671 		0x341c4, 0x341c8,
672 		0x341d0, 0x341d0,
673 		0x34200, 0x34318,
674 		0x34400, 0x344b4,
675 		0x344c0, 0x3452c,
676 		0x34540, 0x3461c,
677 		0x34800, 0x34828,
678 		0x34834, 0x34834,
679 		0x348c0, 0x34908,
680 		0x34910, 0x349ac,
681 		0x34a00, 0x34a14,
682 		0x34a1c, 0x34a2c,
683 		0x34a44, 0x34a50,
684 		0x34a74, 0x34a74,
685 		0x34a7c, 0x34afc,
686 		0x34b08, 0x34c24,
687 		0x34d00, 0x34d00,
688 		0x34d08, 0x34d14,
689 		0x34d1c, 0x34d20,
690 		0x34d3c, 0x34d3c,
691 		0x34d48, 0x34d50,
692 		0x35200, 0x3520c,
693 		0x35220, 0x35220,
694 		0x35240, 0x35240,
695 		0x35600, 0x3560c,
696 		0x35a00, 0x35a1c,
697 		0x35e00, 0x35e20,
698 		0x35e38, 0x35e3c,
699 		0x35e80, 0x35e80,
700 		0x35e88, 0x35ea8,
701 		0x35eb0, 0x35eb4,
702 		0x35ec8, 0x35ed4,
703 		0x35fb8, 0x36004,
704 		0x36200, 0x36200,
705 		0x36208, 0x36240,
706 		0x36248, 0x36280,
707 		0x36288, 0x362c0,
708 		0x362c8, 0x362fc,
709 		0x36600, 0x36630,
710 		0x36a00, 0x36abc,
711 		0x36b00, 0x36b10,
712 		0x36b20, 0x36b30,
713 		0x36b40, 0x36b50,
714 		0x36b60, 0x36b70,
715 		0x37000, 0x37028,
716 		0x37030, 0x37048,
717 		0x37060, 0x37068,
718 		0x37070, 0x3709c,
719 		0x370f0, 0x37128,
720 		0x37130, 0x37148,
721 		0x37160, 0x37168,
722 		0x37170, 0x3719c,
723 		0x371f0, 0x37238,
724 		0x37240, 0x37240,
725 		0x37248, 0x37250,
726 		0x3725c, 0x37264,
727 		0x37270, 0x372b8,
728 		0x372c0, 0x372e4,
729 		0x372f8, 0x37338,
730 		0x37340, 0x37340,
731 		0x37348, 0x37350,
732 		0x3735c, 0x37364,
733 		0x37370, 0x373b8,
734 		0x373c0, 0x373e4,
735 		0x373f8, 0x37428,
736 		0x37430, 0x37448,
737 		0x37460, 0x37468,
738 		0x37470, 0x3749c,
739 		0x374f0, 0x37528,
740 		0x37530, 0x37548,
741 		0x37560, 0x37568,
742 		0x37570, 0x3759c,
743 		0x375f0, 0x37638,
744 		0x37640, 0x37640,
745 		0x37648, 0x37650,
746 		0x3765c, 0x37664,
747 		0x37670, 0x376b8,
748 		0x376c0, 0x376e4,
749 		0x376f8, 0x37738,
750 		0x37740, 0x37740,
751 		0x37748, 0x37750,
752 		0x3775c, 0x37764,
753 		0x37770, 0x377b8,
754 		0x377c0, 0x377e4,
755 		0x377f8, 0x377fc,
756 		0x37814, 0x37814,
757 		0x3782c, 0x3782c,
758 		0x37880, 0x3788c,
759 		0x378e8, 0x378ec,
760 		0x37900, 0x37928,
761 		0x37930, 0x37948,
762 		0x37960, 0x37968,
763 		0x37970, 0x3799c,
764 		0x379f0, 0x37a38,
765 		0x37a40, 0x37a40,
766 		0x37a48, 0x37a50,
767 		0x37a5c, 0x37a64,
768 		0x37a70, 0x37ab8,
769 		0x37ac0, 0x37ae4,
770 		0x37af8, 0x37b10,
771 		0x37b28, 0x37b28,
772 		0x37b3c, 0x37b50,
773 		0x37bf0, 0x37c10,
774 		0x37c28, 0x37c28,
775 		0x37c3c, 0x37c50,
776 		0x37cf0, 0x37cfc,
777 		0x38000, 0x38030,
778 		0x38038, 0x38038,
779 		0x38040, 0x38040,
780 		0x38100, 0x38144,
781 		0x38190, 0x381a0,
782 		0x381a8, 0x381b8,
783 		0x381c4, 0x381c8,
784 		0x381d0, 0x381d0,
785 		0x38200, 0x38318,
786 		0x38400, 0x384b4,
787 		0x384c0, 0x3852c,
788 		0x38540, 0x3861c,
789 		0x38800, 0x38828,
790 		0x38834, 0x38834,
791 		0x388c0, 0x38908,
792 		0x38910, 0x389ac,
793 		0x38a00, 0x38a14,
794 		0x38a1c, 0x38a2c,
795 		0x38a44, 0x38a50,
796 		0x38a74, 0x38a74,
797 		0x38a7c, 0x38afc,
798 		0x38b08, 0x38c24,
799 		0x38d00, 0x38d00,
800 		0x38d08, 0x38d14,
801 		0x38d1c, 0x38d20,
802 		0x38d3c, 0x38d3c,
803 		0x38d48, 0x38d50,
804 		0x39200, 0x3920c,
805 		0x39220, 0x39220,
806 		0x39240, 0x39240,
807 		0x39600, 0x3960c,
808 		0x39a00, 0x39a1c,
809 		0x39e00, 0x39e20,
810 		0x39e38, 0x39e3c,
811 		0x39e80, 0x39e80,
812 		0x39e88, 0x39ea8,
813 		0x39eb0, 0x39eb4,
814 		0x39ec8, 0x39ed4,
815 		0x39fb8, 0x3a004,
816 		0x3a200, 0x3a200,
817 		0x3a208, 0x3a240,
818 		0x3a248, 0x3a280,
819 		0x3a288, 0x3a2c0,
820 		0x3a2c8, 0x3a2fc,
821 		0x3a600, 0x3a630,
822 		0x3aa00, 0x3aabc,
823 		0x3ab00, 0x3ab10,
824 		0x3ab20, 0x3ab30,
825 		0x3ab40, 0x3ab50,
826 		0x3ab60, 0x3ab70,
827 		0x3b000, 0x3b028,
828 		0x3b030, 0x3b048,
829 		0x3b060, 0x3b068,
830 		0x3b070, 0x3b09c,
831 		0x3b0f0, 0x3b128,
832 		0x3b130, 0x3b148,
833 		0x3b160, 0x3b168,
834 		0x3b170, 0x3b19c,
835 		0x3b1f0, 0x3b238,
836 		0x3b240, 0x3b240,
837 		0x3b248, 0x3b250,
838 		0x3b25c, 0x3b264,
839 		0x3b270, 0x3b2b8,
840 		0x3b2c0, 0x3b2e4,
841 		0x3b2f8, 0x3b338,
842 		0x3b340, 0x3b340,
843 		0x3b348, 0x3b350,
844 		0x3b35c, 0x3b364,
845 		0x3b370, 0x3b3b8,
846 		0x3b3c0, 0x3b3e4,
847 		0x3b3f8, 0x3b428,
848 		0x3b430, 0x3b448,
849 		0x3b460, 0x3b468,
850 		0x3b470, 0x3b49c,
851 		0x3b4f0, 0x3b528,
852 		0x3b530, 0x3b548,
853 		0x3b560, 0x3b568,
854 		0x3b570, 0x3b59c,
855 		0x3b5f0, 0x3b638,
856 		0x3b640, 0x3b640,
857 		0x3b648, 0x3b650,
858 		0x3b65c, 0x3b664,
859 		0x3b670, 0x3b6b8,
860 		0x3b6c0, 0x3b6e4,
861 		0x3b6f8, 0x3b738,
862 		0x3b740, 0x3b740,
863 		0x3b748, 0x3b750,
864 		0x3b75c, 0x3b764,
865 		0x3b770, 0x3b7b8,
866 		0x3b7c0, 0x3b7e4,
867 		0x3b7f8, 0x3b7fc,
868 		0x3b814, 0x3b814,
869 		0x3b82c, 0x3b82c,
870 		0x3b880, 0x3b88c,
871 		0x3b8e8, 0x3b8ec,
872 		0x3b900, 0x3b928,
873 		0x3b930, 0x3b948,
874 		0x3b960, 0x3b968,
875 		0x3b970, 0x3b99c,
876 		0x3b9f0, 0x3ba38,
877 		0x3ba40, 0x3ba40,
878 		0x3ba48, 0x3ba50,
879 		0x3ba5c, 0x3ba64,
880 		0x3ba70, 0x3bab8,
881 		0x3bac0, 0x3bae4,
882 		0x3baf8, 0x3bb10,
883 		0x3bb28, 0x3bb28,
884 		0x3bb3c, 0x3bb50,
885 		0x3bbf0, 0x3bc10,
886 		0x3bc28, 0x3bc28,
887 		0x3bc3c, 0x3bc50,
888 		0x3bcf0, 0x3bcfc,
889 		0x3c000, 0x3c030,
890 		0x3c038, 0x3c038,
891 		0x3c040, 0x3c040,
892 		0x3c100, 0x3c144,
893 		0x3c190, 0x3c1a0,
894 		0x3c1a8, 0x3c1b8,
895 		0x3c1c4, 0x3c1c8,
896 		0x3c1d0, 0x3c1d0,
897 		0x3c200, 0x3c318,
898 		0x3c400, 0x3c4b4,
899 		0x3c4c0, 0x3c52c,
900 		0x3c540, 0x3c61c,
901 		0x3c800, 0x3c828,
902 		0x3c834, 0x3c834,
903 		0x3c8c0, 0x3c908,
904 		0x3c910, 0x3c9ac,
905 		0x3ca00, 0x3ca14,
906 		0x3ca1c, 0x3ca2c,
907 		0x3ca44, 0x3ca50,
908 		0x3ca74, 0x3ca74,
909 		0x3ca7c, 0x3cafc,
910 		0x3cb08, 0x3cc24,
911 		0x3cd00, 0x3cd00,
912 		0x3cd08, 0x3cd14,
913 		0x3cd1c, 0x3cd20,
914 		0x3cd3c, 0x3cd3c,
915 		0x3cd48, 0x3cd50,
916 		0x3d200, 0x3d20c,
917 		0x3d220, 0x3d220,
918 		0x3d240, 0x3d240,
919 		0x3d600, 0x3d60c,
920 		0x3da00, 0x3da1c,
921 		0x3de00, 0x3de20,
922 		0x3de38, 0x3de3c,
923 		0x3de80, 0x3de80,
924 		0x3de88, 0x3dea8,
925 		0x3deb0, 0x3deb4,
926 		0x3dec8, 0x3ded4,
927 		0x3dfb8, 0x3e004,
928 		0x3e200, 0x3e200,
929 		0x3e208, 0x3e240,
930 		0x3e248, 0x3e280,
931 		0x3e288, 0x3e2c0,
932 		0x3e2c8, 0x3e2fc,
933 		0x3e600, 0x3e630,
934 		0x3ea00, 0x3eabc,
935 		0x3eb00, 0x3eb10,
936 		0x3eb20, 0x3eb30,
937 		0x3eb40, 0x3eb50,
938 		0x3eb60, 0x3eb70,
939 		0x3f000, 0x3f028,
940 		0x3f030, 0x3f048,
941 		0x3f060, 0x3f068,
942 		0x3f070, 0x3f09c,
943 		0x3f0f0, 0x3f128,
944 		0x3f130, 0x3f148,
945 		0x3f160, 0x3f168,
946 		0x3f170, 0x3f19c,
947 		0x3f1f0, 0x3f238,
948 		0x3f240, 0x3f240,
949 		0x3f248, 0x3f250,
950 		0x3f25c, 0x3f264,
951 		0x3f270, 0x3f2b8,
952 		0x3f2c0, 0x3f2e4,
953 		0x3f2f8, 0x3f338,
954 		0x3f340, 0x3f340,
955 		0x3f348, 0x3f350,
956 		0x3f35c, 0x3f364,
957 		0x3f370, 0x3f3b8,
958 		0x3f3c0, 0x3f3e4,
959 		0x3f3f8, 0x3f428,
960 		0x3f430, 0x3f448,
961 		0x3f460, 0x3f468,
962 		0x3f470, 0x3f49c,
963 		0x3f4f0, 0x3f528,
964 		0x3f530, 0x3f548,
965 		0x3f560, 0x3f568,
966 		0x3f570, 0x3f59c,
967 		0x3f5f0, 0x3f638,
968 		0x3f640, 0x3f640,
969 		0x3f648, 0x3f650,
970 		0x3f65c, 0x3f664,
971 		0x3f670, 0x3f6b8,
972 		0x3f6c0, 0x3f6e4,
973 		0x3f6f8, 0x3f738,
974 		0x3f740, 0x3f740,
975 		0x3f748, 0x3f750,
976 		0x3f75c, 0x3f764,
977 		0x3f770, 0x3f7b8,
978 		0x3f7c0, 0x3f7e4,
979 		0x3f7f8, 0x3f7fc,
980 		0x3f814, 0x3f814,
981 		0x3f82c, 0x3f82c,
982 		0x3f880, 0x3f88c,
983 		0x3f8e8, 0x3f8ec,
984 		0x3f900, 0x3f928,
985 		0x3f930, 0x3f948,
986 		0x3f960, 0x3f968,
987 		0x3f970, 0x3f99c,
988 		0x3f9f0, 0x3fa38,
989 		0x3fa40, 0x3fa40,
990 		0x3fa48, 0x3fa50,
991 		0x3fa5c, 0x3fa64,
992 		0x3fa70, 0x3fab8,
993 		0x3fac0, 0x3fae4,
994 		0x3faf8, 0x3fb10,
995 		0x3fb28, 0x3fb28,
996 		0x3fb3c, 0x3fb50,
997 		0x3fbf0, 0x3fc10,
998 		0x3fc28, 0x3fc28,
999 		0x3fc3c, 0x3fc50,
1000 		0x3fcf0, 0x3fcfc,
1001 		0x40000, 0x4000c,
1002 		0x40040, 0x40050,
1003 		0x40060, 0x40068,
1004 		0x4007c, 0x4008c,
1005 		0x40094, 0x400b0,
1006 		0x400c0, 0x40144,
1007 		0x40180, 0x4018c,
1008 		0x40200, 0x40254,
1009 		0x40260, 0x40264,
1010 		0x40270, 0x40288,
1011 		0x40290, 0x40298,
1012 		0x402ac, 0x402c8,
1013 		0x402d0, 0x402e0,
1014 		0x402f0, 0x402f0,
1015 		0x40300, 0x4033c,
1016 		0x403f8, 0x403fc,
1017 		0x41304, 0x413c4,
1018 		0x41400, 0x4140c,
1019 		0x41414, 0x4141c,
1020 		0x41480, 0x414d0,
1021 		0x44000, 0x44054,
1022 		0x4405c, 0x44078,
1023 		0x440c0, 0x44174,
1024 		0x44180, 0x441ac,
1025 		0x441b4, 0x441b8,
1026 		0x441c0, 0x44254,
1027 		0x4425c, 0x44278,
1028 		0x442c0, 0x44374,
1029 		0x44380, 0x443ac,
1030 		0x443b4, 0x443b8,
1031 		0x443c0, 0x44454,
1032 		0x4445c, 0x44478,
1033 		0x444c0, 0x44574,
1034 		0x44580, 0x445ac,
1035 		0x445b4, 0x445b8,
1036 		0x445c0, 0x44654,
1037 		0x4465c, 0x44678,
1038 		0x446c0, 0x44774,
1039 		0x44780, 0x447ac,
1040 		0x447b4, 0x447b8,
1041 		0x447c0, 0x44854,
1042 		0x4485c, 0x44878,
1043 		0x448c0, 0x44974,
1044 		0x44980, 0x449ac,
1045 		0x449b4, 0x449b8,
1046 		0x449c0, 0x449fc,
1047 		0x45000, 0x45004,
1048 		0x45010, 0x45030,
1049 		0x45040, 0x45060,
1050 		0x45068, 0x45068,
1051 		0x45080, 0x45084,
1052 		0x450a0, 0x450b0,
1053 		0x45200, 0x45204,
1054 		0x45210, 0x45230,
1055 		0x45240, 0x45260,
1056 		0x45268, 0x45268,
1057 		0x45280, 0x45284,
1058 		0x452a0, 0x452b0,
1059 		0x460c0, 0x460e4,
1060 		0x47000, 0x4703c,
1061 		0x47044, 0x4708c,
1062 		0x47200, 0x47250,
1063 		0x47400, 0x47408,
1064 		0x47414, 0x47420,
1065 		0x47600, 0x47618,
1066 		0x47800, 0x47814,
1067 		0x48000, 0x4800c,
1068 		0x48040, 0x48050,
1069 		0x48060, 0x48068,
1070 		0x4807c, 0x4808c,
1071 		0x48094, 0x480b0,
1072 		0x480c0, 0x48144,
1073 		0x48180, 0x4818c,
1074 		0x48200, 0x48254,
1075 		0x48260, 0x48264,
1076 		0x48270, 0x48288,
1077 		0x48290, 0x48298,
1078 		0x482ac, 0x482c8,
1079 		0x482d0, 0x482e0,
1080 		0x482f0, 0x482f0,
1081 		0x48300, 0x4833c,
1082 		0x483f8, 0x483fc,
1083 		0x49304, 0x493c4,
1084 		0x49400, 0x4940c,
1085 		0x49414, 0x4941c,
1086 		0x49480, 0x494d0,
1087 		0x4c000, 0x4c054,
1088 		0x4c05c, 0x4c078,
1089 		0x4c0c0, 0x4c174,
1090 		0x4c180, 0x4c1ac,
1091 		0x4c1b4, 0x4c1b8,
1092 		0x4c1c0, 0x4c254,
1093 		0x4c25c, 0x4c278,
1094 		0x4c2c0, 0x4c374,
1095 		0x4c380, 0x4c3ac,
1096 		0x4c3b4, 0x4c3b8,
1097 		0x4c3c0, 0x4c454,
1098 		0x4c45c, 0x4c478,
1099 		0x4c4c0, 0x4c574,
1100 		0x4c580, 0x4c5ac,
1101 		0x4c5b4, 0x4c5b8,
1102 		0x4c5c0, 0x4c654,
1103 		0x4c65c, 0x4c678,
1104 		0x4c6c0, 0x4c774,
1105 		0x4c780, 0x4c7ac,
1106 		0x4c7b4, 0x4c7b8,
1107 		0x4c7c0, 0x4c854,
1108 		0x4c85c, 0x4c878,
1109 		0x4c8c0, 0x4c974,
1110 		0x4c980, 0x4c9ac,
1111 		0x4c9b4, 0x4c9b8,
1112 		0x4c9c0, 0x4c9fc,
1113 		0x4d000, 0x4d004,
1114 		0x4d010, 0x4d030,
1115 		0x4d040, 0x4d060,
1116 		0x4d068, 0x4d068,
1117 		0x4d080, 0x4d084,
1118 		0x4d0a0, 0x4d0b0,
1119 		0x4d200, 0x4d204,
1120 		0x4d210, 0x4d230,
1121 		0x4d240, 0x4d260,
1122 		0x4d268, 0x4d268,
1123 		0x4d280, 0x4d284,
1124 		0x4d2a0, 0x4d2b0,
1125 		0x4e0c0, 0x4e0e4,
1126 		0x4f000, 0x4f03c,
1127 		0x4f044, 0x4f08c,
1128 		0x4f200, 0x4f250,
1129 		0x4f400, 0x4f408,
1130 		0x4f414, 0x4f420,
1131 		0x4f600, 0x4f618,
1132 		0x4f800, 0x4f814,
1133 		0x50000, 0x50084,
1134 		0x50090, 0x500cc,
1135 		0x50400, 0x50400,
1136 		0x50800, 0x50884,
1137 		0x50890, 0x508cc,
1138 		0x50c00, 0x50c00,
1139 		0x51000, 0x5101c,
1140 		0x51300, 0x51308,
1141 	};
1142 
1143 	static const unsigned int t6_reg_ranges[] = {
1144 		0x1008, 0x101c,
1145 		0x1024, 0x10a8,
1146 		0x10b4, 0x10f8,
1147 		0x1100, 0x1114,
1148 		0x111c, 0x112c,
1149 		0x1138, 0x113c,
1150 		0x1144, 0x114c,
1151 		0x1180, 0x1184,
1152 		0x1190, 0x1194,
1153 		0x11a0, 0x11a4,
1154 		0x11b0, 0x11c4,
1155 		0x11fc, 0x123c,
1156 		0x1254, 0x1274,
1157 		0x1280, 0x133c,
1158 		0x1800, 0x18fc,
1159 		0x3000, 0x302c,
1160 		0x3060, 0x30b0,
1161 		0x30b8, 0x30d8,
1162 		0x30e0, 0x30fc,
1163 		0x3140, 0x357c,
1164 		0x35a8, 0x35cc,
1165 		0x35ec, 0x35ec,
1166 		0x3600, 0x5624,
1167 		0x56cc, 0x56ec,
1168 		0x56f4, 0x5720,
1169 		0x5728, 0x575c,
1170 		0x580c, 0x5814,
1171 		0x5890, 0x589c,
1172 		0x58a4, 0x58ac,
1173 		0x58b8, 0x58bc,
1174 		0x5940, 0x595c,
1175 		0x5980, 0x598c,
1176 		0x59b0, 0x59c8,
1177 		0x59d0, 0x59dc,
1178 		0x59fc, 0x5a18,
1179 		0x5a60, 0x5a6c,
1180 		0x5a80, 0x5a8c,
1181 		0x5a94, 0x5a9c,
1182 		0x5b94, 0x5bfc,
1183 		0x5c10, 0x5e48,
1184 		0x5e50, 0x5e94,
1185 		0x5ea0, 0x5eb0,
1186 		0x5ec0, 0x5ec0,
1187 		0x5ec8, 0x5ed0,
1188 		0x5ee0, 0x5ee0,
1189 		0x5ef0, 0x5ef0,
1190 		0x5f00, 0x5f00,
1191 		0x6000, 0x6020,
1192 		0x6028, 0x6040,
1193 		0x6058, 0x609c,
1194 		0x60a8, 0x619c,
1195 		0x7700, 0x7798,
1196 		0x77c0, 0x7880,
1197 		0x78cc, 0x78fc,
1198 		0x7b00, 0x7b58,
1199 		0x7b60, 0x7b84,
1200 		0x7b8c, 0x7c54,
1201 		0x7d00, 0x7d38,
1202 		0x7d40, 0x7d84,
1203 		0x7d8c, 0x7ddc,
1204 		0x7de4, 0x7e04,
1205 		0x7e10, 0x7e1c,
1206 		0x7e24, 0x7e38,
1207 		0x7e40, 0x7e44,
1208 		0x7e4c, 0x7e78,
1209 		0x7e80, 0x7edc,
1210 		0x7ee8, 0x7efc,
1211 		0x8dc0, 0x8de0,
1212 		0x8df8, 0x8e04,
1213 		0x8e10, 0x8e84,
1214 		0x8ea0, 0x8f88,
1215 		0x8fb8, 0x9058,
1216 		0x9060, 0x9060,
1217 		0x9068, 0x90f8,
1218 		0x9100, 0x9124,
1219 		0x9400, 0x9470,
1220 		0x9600, 0x9600,
1221 		0x9608, 0x9638,
1222 		0x9640, 0x9704,
1223 		0x9710, 0x971c,
1224 		0x9800, 0x9808,
1225 		0x9810, 0x9864,
1226 		0x9c00, 0x9c6c,
1227 		0x9c80, 0x9cec,
1228 		0x9d00, 0x9d6c,
1229 		0x9d80, 0x9dec,
1230 		0x9e00, 0x9e6c,
1231 		0x9e80, 0x9eec,
1232 		0x9f00, 0x9f6c,
1233 		0x9f80, 0xa020,
1234 		0xd000, 0xd03c,
1235 		0xd100, 0xd118,
1236 		0xd200, 0xd214,
1237 		0xd220, 0xd234,
1238 		0xd240, 0xd254,
1239 		0xd260, 0xd274,
1240 		0xd280, 0xd294,
1241 		0xd2a0, 0xd2b4,
1242 		0xd2c0, 0xd2d4,
1243 		0xd2e0, 0xd2f4,
1244 		0xd300, 0xd31c,
1245 		0xdfc0, 0xdfe0,
1246 		0xe000, 0xf008,
1247 		0xf010, 0xf018,
1248 		0xf020, 0xf028,
1249 		0x11000, 0x11014,
1250 		0x11048, 0x1106c,
1251 		0x11074, 0x11088,
1252 		0x11098, 0x11120,
1253 		0x1112c, 0x1117c,
1254 		0x11190, 0x112e0,
1255 		0x11300, 0x1130c,
1256 		0x12000, 0x1206c,
1257 		0x19040, 0x1906c,
1258 		0x19078, 0x19080,
1259 		0x1908c, 0x190e8,
1260 		0x190f0, 0x190f8,
1261 		0x19100, 0x19110,
1262 		0x19120, 0x19124,
1263 		0x19150, 0x19194,
1264 		0x1919c, 0x191b0,
1265 		0x191d0, 0x191e8,
1266 		0x19238, 0x19290,
1267 		0x192a4, 0x192b0,
1268 		0x19348, 0x1934c,
1269 		0x193f8, 0x19418,
1270 		0x19420, 0x19428,
1271 		0x19430, 0x19444,
1272 		0x1944c, 0x1946c,
1273 		0x19474, 0x19474,
1274 		0x19490, 0x194cc,
1275 		0x194f0, 0x194f8,
1276 		0x19c00, 0x19c48,
1277 		0x19c50, 0x19c80,
1278 		0x19c94, 0x19c98,
1279 		0x19ca0, 0x19cbc,
1280 		0x19ce4, 0x19ce4,
1281 		0x19cf0, 0x19cf8,
1282 		0x19d00, 0x19d28,
1283 		0x19d50, 0x19d78,
1284 		0x19d94, 0x19d98,
1285 		0x19da0, 0x19de0,
1286 		0x19df0, 0x19e10,
1287 		0x19e50, 0x19e6c,
1288 		0x19ea0, 0x19ebc,
1289 		0x19ec4, 0x19ef4,
1290 		0x19f04, 0x19f2c,
1291 		0x19f34, 0x19f34,
1292 		0x19f40, 0x19f50,
1293 		0x19f90, 0x19fac,
1294 		0x19fc4, 0x19fc8,
1295 		0x19fd0, 0x19fe4,
1296 		0x1a000, 0x1a004,
1297 		0x1a010, 0x1a06c,
1298 		0x1a0b0, 0x1a0e4,
1299 		0x1a0ec, 0x1a0f8,
1300 		0x1a100, 0x1a108,
1301 		0x1a114, 0x1a130,
1302 		0x1a138, 0x1a1c4,
1303 		0x1a1fc, 0x1a1fc,
1304 		0x1e008, 0x1e00c,
1305 		0x1e040, 0x1e044,
1306 		0x1e04c, 0x1e04c,
1307 		0x1e284, 0x1e290,
1308 		0x1e2c0, 0x1e2c0,
1309 		0x1e2e0, 0x1e2e0,
1310 		0x1e300, 0x1e384,
1311 		0x1e3c0, 0x1e3c8,
1312 		0x1e408, 0x1e40c,
1313 		0x1e440, 0x1e444,
1314 		0x1e44c, 0x1e44c,
1315 		0x1e684, 0x1e690,
1316 		0x1e6c0, 0x1e6c0,
1317 		0x1e6e0, 0x1e6e0,
1318 		0x1e700, 0x1e784,
1319 		0x1e7c0, 0x1e7c8,
1320 		0x1e808, 0x1e80c,
1321 		0x1e840, 0x1e844,
1322 		0x1e84c, 0x1e84c,
1323 		0x1ea84, 0x1ea90,
1324 		0x1eac0, 0x1eac0,
1325 		0x1eae0, 0x1eae0,
1326 		0x1eb00, 0x1eb84,
1327 		0x1ebc0, 0x1ebc8,
1328 		0x1ec08, 0x1ec0c,
1329 		0x1ec40, 0x1ec44,
1330 		0x1ec4c, 0x1ec4c,
1331 		0x1ee84, 0x1ee90,
1332 		0x1eec0, 0x1eec0,
1333 		0x1eee0, 0x1eee0,
1334 		0x1ef00, 0x1ef84,
1335 		0x1efc0, 0x1efc8,
1336 		0x1f008, 0x1f00c,
1337 		0x1f040, 0x1f044,
1338 		0x1f04c, 0x1f04c,
1339 		0x1f284, 0x1f290,
1340 		0x1f2c0, 0x1f2c0,
1341 		0x1f2e0, 0x1f2e0,
1342 		0x1f300, 0x1f384,
1343 		0x1f3c0, 0x1f3c8,
1344 		0x1f408, 0x1f40c,
1345 		0x1f440, 0x1f444,
1346 		0x1f44c, 0x1f44c,
1347 		0x1f684, 0x1f690,
1348 		0x1f6c0, 0x1f6c0,
1349 		0x1f6e0, 0x1f6e0,
1350 		0x1f700, 0x1f784,
1351 		0x1f7c0, 0x1f7c8,
1352 		0x1f808, 0x1f80c,
1353 		0x1f840, 0x1f844,
1354 		0x1f84c, 0x1f84c,
1355 		0x1fa84, 0x1fa90,
1356 		0x1fac0, 0x1fac0,
1357 		0x1fae0, 0x1fae0,
1358 		0x1fb00, 0x1fb84,
1359 		0x1fbc0, 0x1fbc8,
1360 		0x1fc08, 0x1fc0c,
1361 		0x1fc40, 0x1fc44,
1362 		0x1fc4c, 0x1fc4c,
1363 		0x1fe84, 0x1fe90,
1364 		0x1fec0, 0x1fec0,
1365 		0x1fee0, 0x1fee0,
1366 		0x1ff00, 0x1ff84,
1367 		0x1ffc0, 0x1ffc8,
1368 		0x30000, 0x30030,
1369 		0x30100, 0x30168,
1370 		0x30190, 0x301a0,
1371 		0x301a8, 0x301b8,
1372 		0x301c4, 0x301c8,
1373 		0x301d0, 0x301d0,
1374 		0x30200, 0x30320,
1375 		0x30400, 0x304b4,
1376 		0x304c0, 0x3052c,
1377 		0x30540, 0x3061c,
1378 		0x30800, 0x308a0,
1379 		0x308c0, 0x30908,
1380 		0x30910, 0x309b8,
1381 		0x30a00, 0x30a04,
1382 		0x30a0c, 0x30a14,
1383 		0x30a1c, 0x30a2c,
1384 		0x30a44, 0x30a50,
1385 		0x30a74, 0x30a74,
1386 		0x30a7c, 0x30afc,
1387 		0x30b08, 0x30c24,
1388 		0x30d00, 0x30d14,
1389 		0x30d1c, 0x30d3c,
1390 		0x30d44, 0x30d4c,
1391 		0x30d54, 0x30d74,
1392 		0x30d7c, 0x30d7c,
1393 		0x30de0, 0x30de0,
1394 		0x30e00, 0x30ed4,
1395 		0x30f00, 0x30fa4,
1396 		0x30fc0, 0x30fc4,
1397 		0x31000, 0x31004,
1398 		0x31080, 0x310fc,
1399 		0x31208, 0x31220,
1400 		0x3123c, 0x31254,
1401 		0x31300, 0x31300,
1402 		0x31308, 0x3131c,
1403 		0x31338, 0x3133c,
1404 		0x31380, 0x31380,
1405 		0x31388, 0x313a8,
1406 		0x313b4, 0x313b4,
1407 		0x31400, 0x31420,
1408 		0x31438, 0x3143c,
1409 		0x31480, 0x31480,
1410 		0x314a8, 0x314a8,
1411 		0x314b0, 0x314b4,
1412 		0x314c8, 0x314d4,
1413 		0x31a40, 0x31a4c,
1414 		0x31af0, 0x31b20,
1415 		0x31b38, 0x31b3c,
1416 		0x31b80, 0x31b80,
1417 		0x31ba8, 0x31ba8,
1418 		0x31bb0, 0x31bb4,
1419 		0x31bc8, 0x31bd4,
1420 		0x32140, 0x3218c,
1421 		0x321f0, 0x321f4,
1422 		0x32200, 0x32200,
1423 		0x32218, 0x32218,
1424 		0x32400, 0x32400,
1425 		0x32408, 0x3241c,
1426 		0x32618, 0x32620,
1427 		0x32664, 0x32664,
1428 		0x326a8, 0x326a8,
1429 		0x326ec, 0x326ec,
1430 		0x32a00, 0x32abc,
1431 		0x32b00, 0x32b18,
1432 		0x32b20, 0x32b38,
1433 		0x32b40, 0x32b58,
1434 		0x32b60, 0x32b78,
1435 		0x32c00, 0x32c00,
1436 		0x32c08, 0x32c3c,
1437 		0x33000, 0x3302c,
1438 		0x33034, 0x33050,
1439 		0x33058, 0x33058,
1440 		0x33060, 0x3308c,
1441 		0x3309c, 0x330ac,
1442 		0x330c0, 0x330c0,
1443 		0x330c8, 0x330d0,
1444 		0x330d8, 0x330e0,
1445 		0x330ec, 0x3312c,
1446 		0x33134, 0x33150,
1447 		0x33158, 0x33158,
1448 		0x33160, 0x3318c,
1449 		0x3319c, 0x331ac,
1450 		0x331c0, 0x331c0,
1451 		0x331c8, 0x331d0,
1452 		0x331d8, 0x331e0,
1453 		0x331ec, 0x33290,
1454 		0x33298, 0x332c4,
1455 		0x332e4, 0x33390,
1456 		0x33398, 0x333c4,
1457 		0x333e4, 0x3342c,
1458 		0x33434, 0x33450,
1459 		0x33458, 0x33458,
1460 		0x33460, 0x3348c,
1461 		0x3349c, 0x334ac,
1462 		0x334c0, 0x334c0,
1463 		0x334c8, 0x334d0,
1464 		0x334d8, 0x334e0,
1465 		0x334ec, 0x3352c,
1466 		0x33534, 0x33550,
1467 		0x33558, 0x33558,
1468 		0x33560, 0x3358c,
1469 		0x3359c, 0x335ac,
1470 		0x335c0, 0x335c0,
1471 		0x335c8, 0x335d0,
1472 		0x335d8, 0x335e0,
1473 		0x335ec, 0x33690,
1474 		0x33698, 0x336c4,
1475 		0x336e4, 0x33790,
1476 		0x33798, 0x337c4,
1477 		0x337e4, 0x337fc,
1478 		0x33814, 0x33814,
1479 		0x33854, 0x33868,
1480 		0x33880, 0x3388c,
1481 		0x338c0, 0x338d0,
1482 		0x338e8, 0x338ec,
1483 		0x33900, 0x3392c,
1484 		0x33934, 0x33950,
1485 		0x33958, 0x33958,
1486 		0x33960, 0x3398c,
1487 		0x3399c, 0x339ac,
1488 		0x339c0, 0x339c0,
1489 		0x339c8, 0x339d0,
1490 		0x339d8, 0x339e0,
1491 		0x339ec, 0x33a90,
1492 		0x33a98, 0x33ac4,
1493 		0x33ae4, 0x33b10,
1494 		0x33b24, 0x33b28,
1495 		0x33b38, 0x33b50,
1496 		0x33bf0, 0x33c10,
1497 		0x33c24, 0x33c28,
1498 		0x33c38, 0x33c50,
1499 		0x33cf0, 0x33cfc,
1500 		0x34000, 0x34030,
1501 		0x34100, 0x34168,
1502 		0x34190, 0x341a0,
1503 		0x341a8, 0x341b8,
1504 		0x341c4, 0x341c8,
1505 		0x341d0, 0x341d0,
1506 		0x34200, 0x34320,
1507 		0x34400, 0x344b4,
1508 		0x344c0, 0x3452c,
1509 		0x34540, 0x3461c,
1510 		0x34800, 0x348a0,
1511 		0x348c0, 0x34908,
1512 		0x34910, 0x349b8,
1513 		0x34a00, 0x34a04,
1514 		0x34a0c, 0x34a14,
1515 		0x34a1c, 0x34a2c,
1516 		0x34a44, 0x34a50,
1517 		0x34a74, 0x34a74,
1518 		0x34a7c, 0x34afc,
1519 		0x34b08, 0x34c24,
1520 		0x34d00, 0x34d14,
1521 		0x34d1c, 0x34d3c,
1522 		0x34d44, 0x34d4c,
1523 		0x34d54, 0x34d74,
1524 		0x34d7c, 0x34d7c,
1525 		0x34de0, 0x34de0,
1526 		0x34e00, 0x34ed4,
1527 		0x34f00, 0x34fa4,
1528 		0x34fc0, 0x34fc4,
1529 		0x35000, 0x35004,
1530 		0x35080, 0x350fc,
1531 		0x35208, 0x35220,
1532 		0x3523c, 0x35254,
1533 		0x35300, 0x35300,
1534 		0x35308, 0x3531c,
1535 		0x35338, 0x3533c,
1536 		0x35380, 0x35380,
1537 		0x35388, 0x353a8,
1538 		0x353b4, 0x353b4,
1539 		0x35400, 0x35420,
1540 		0x35438, 0x3543c,
1541 		0x35480, 0x35480,
1542 		0x354a8, 0x354a8,
1543 		0x354b0, 0x354b4,
1544 		0x354c8, 0x354d4,
1545 		0x35a40, 0x35a4c,
1546 		0x35af0, 0x35b20,
1547 		0x35b38, 0x35b3c,
1548 		0x35b80, 0x35b80,
1549 		0x35ba8, 0x35ba8,
1550 		0x35bb0, 0x35bb4,
1551 		0x35bc8, 0x35bd4,
1552 		0x36140, 0x3618c,
1553 		0x361f0, 0x361f4,
1554 		0x36200, 0x36200,
1555 		0x36218, 0x36218,
1556 		0x36400, 0x36400,
1557 		0x36408, 0x3641c,
1558 		0x36618, 0x36620,
1559 		0x36664, 0x36664,
1560 		0x366a8, 0x366a8,
1561 		0x366ec, 0x366ec,
1562 		0x36a00, 0x36abc,
1563 		0x36b00, 0x36b18,
1564 		0x36b20, 0x36b38,
1565 		0x36b40, 0x36b58,
1566 		0x36b60, 0x36b78,
1567 		0x36c00, 0x36c00,
1568 		0x36c08, 0x36c3c,
1569 		0x37000, 0x3702c,
1570 		0x37034, 0x37050,
1571 		0x37058, 0x37058,
1572 		0x37060, 0x3708c,
1573 		0x3709c, 0x370ac,
1574 		0x370c0, 0x370c0,
1575 		0x370c8, 0x370d0,
1576 		0x370d8, 0x370e0,
1577 		0x370ec, 0x3712c,
1578 		0x37134, 0x37150,
1579 		0x37158, 0x37158,
1580 		0x37160, 0x3718c,
1581 		0x3719c, 0x371ac,
1582 		0x371c0, 0x371c0,
1583 		0x371c8, 0x371d0,
1584 		0x371d8, 0x371e0,
1585 		0x371ec, 0x37290,
1586 		0x37298, 0x372c4,
1587 		0x372e4, 0x37390,
1588 		0x37398, 0x373c4,
1589 		0x373e4, 0x3742c,
1590 		0x37434, 0x37450,
1591 		0x37458, 0x37458,
1592 		0x37460, 0x3748c,
1593 		0x3749c, 0x374ac,
1594 		0x374c0, 0x374c0,
1595 		0x374c8, 0x374d0,
1596 		0x374d8, 0x374e0,
1597 		0x374ec, 0x3752c,
1598 		0x37534, 0x37550,
1599 		0x37558, 0x37558,
1600 		0x37560, 0x3758c,
1601 		0x3759c, 0x375ac,
1602 		0x375c0, 0x375c0,
1603 		0x375c8, 0x375d0,
1604 		0x375d8, 0x375e0,
1605 		0x375ec, 0x37690,
1606 		0x37698, 0x376c4,
1607 		0x376e4, 0x37790,
1608 		0x37798, 0x377c4,
1609 		0x377e4, 0x377fc,
1610 		0x37814, 0x37814,
1611 		0x37854, 0x37868,
1612 		0x37880, 0x3788c,
1613 		0x378c0, 0x378d0,
1614 		0x378e8, 0x378ec,
1615 		0x37900, 0x3792c,
1616 		0x37934, 0x37950,
1617 		0x37958, 0x37958,
1618 		0x37960, 0x3798c,
1619 		0x3799c, 0x379ac,
1620 		0x379c0, 0x379c0,
1621 		0x379c8, 0x379d0,
1622 		0x379d8, 0x379e0,
1623 		0x379ec, 0x37a90,
1624 		0x37a98, 0x37ac4,
1625 		0x37ae4, 0x37b10,
1626 		0x37b24, 0x37b28,
1627 		0x37b38, 0x37b50,
1628 		0x37bf0, 0x37c10,
1629 		0x37c24, 0x37c28,
1630 		0x37c38, 0x37c50,
1631 		0x37cf0, 0x37cfc,
1632 		0x40040, 0x40040,
1633 		0x40080, 0x40084,
1634 		0x40100, 0x40100,
1635 		0x40140, 0x401bc,
1636 		0x40200, 0x40214,
1637 		0x40228, 0x40228,
1638 		0x40240, 0x40258,
1639 		0x40280, 0x40280,
1640 		0x40304, 0x40304,
1641 		0x40330, 0x4033c,
1642 		0x41304, 0x413c8,
1643 		0x413d0, 0x413dc,
1644 		0x413f0, 0x413f0,
1645 		0x41400, 0x4140c,
1646 		0x41414, 0x4141c,
1647 		0x41480, 0x414d0,
1648 		0x44000, 0x4407c,
1649 		0x440c0, 0x441ac,
1650 		0x441b4, 0x4427c,
1651 		0x442c0, 0x443ac,
1652 		0x443b4, 0x4447c,
1653 		0x444c0, 0x445ac,
1654 		0x445b4, 0x4467c,
1655 		0x446c0, 0x447ac,
1656 		0x447b4, 0x4487c,
1657 		0x448c0, 0x449ac,
1658 		0x449b4, 0x44a7c,
1659 		0x44ac0, 0x44bac,
1660 		0x44bb4, 0x44c7c,
1661 		0x44cc0, 0x44dac,
1662 		0x44db4, 0x44e7c,
1663 		0x44ec0, 0x44fac,
1664 		0x44fb4, 0x4507c,
1665 		0x450c0, 0x451ac,
1666 		0x451b4, 0x451fc,
1667 		0x45800, 0x45804,
1668 		0x45810, 0x45830,
1669 		0x45840, 0x45860,
1670 		0x45868, 0x45868,
1671 		0x45880, 0x45884,
1672 		0x458a0, 0x458b0,
1673 		0x45a00, 0x45a04,
1674 		0x45a10, 0x45a30,
1675 		0x45a40, 0x45a60,
1676 		0x45a68, 0x45a68,
1677 		0x45a80, 0x45a84,
1678 		0x45aa0, 0x45ab0,
1679 		0x460c0, 0x460e4,
1680 		0x47000, 0x4703c,
1681 		0x47044, 0x4708c,
1682 		0x47200, 0x47250,
1683 		0x47400, 0x47408,
1684 		0x47414, 0x47420,
1685 		0x47600, 0x47618,
1686 		0x47800, 0x47814,
1687 		0x47820, 0x4782c,
1688 		0x50000, 0x50084,
1689 		0x50090, 0x500cc,
1690 		0x50300, 0x50384,
1691 		0x50400, 0x50400,
1692 		0x50800, 0x50884,
1693 		0x50890, 0x508cc,
1694 		0x50b00, 0x50b84,
1695 		0x50c00, 0x50c00,
1696 		0x51000, 0x51020,
1697 		0x51028, 0x510b0,
1698 		0x51300, 0x51324,
1699 	};
1700 
1701 	if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
1702 		return (EFAULT);
1703 
1704 	if (is_t4(sc->params.chip)) {
1705 		if (r.len > T4_REGDUMP_SIZE)
1706 			r.len = T4_REGDUMP_SIZE;
1707 		else if (r.len < T4_REGDUMP_SIZE)
1708 			return (ENOBUFS);
1709 	} else {
1710 		/* Regdump size is same for both T5 and T6 */
1711 		if (r.len > T5_REGDUMP_SIZE)
1712 			r.len = T5_REGDUMP_SIZE;
1713 		else if (r.len < T5_REGDUMP_SIZE)
1714 			return (ENOBUFS);
1715 	}
1716 
1717 	r.version = mk_adap_vers(sc);
1718 
1719 	if (is_t4(sc->params.chip)) {
1720 		reg_ranges = &t4_reg_ranges[0];
1721 		arr_size = ARRAY_SIZE(t4_reg_ranges);
1722 		buf_size = T4_REGDUMP_SIZE;
1723 	} else if (is_t5(sc->params.chip)) {
1724 		reg_ranges = &t5_reg_ranges[0];
1725 		arr_size = ARRAY_SIZE(t5_reg_ranges);
1726 		buf_size = T5_REGDUMP_SIZE;
1727 	} else {
1728 		reg_ranges = &t6_reg_ranges[0];
1729 		arr_size = ARRAY_SIZE(t6_reg_ranges);
1730 		buf_size = T6_REGDUMP_SIZE;
1731 	}
1732 
1733 	buf = kmem_zalloc(buf_size, KM_SLEEP);
1734 	if (buf == NULL)
1735 		return (ENOMEM);
1736 
1737 	for (i = 0; i < arr_size; i += 2)
1738 		reg_block_dump(sc, buf, reg_ranges[i], reg_ranges[i + 1]);
1739 
1740 	/* Copyout device log buffer and then carrier buffer */
1741 	if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof (r)), r.len,
1742 	    flags) < 0) {
1743 		rc = EFAULT;
1744 		goto free;
1745 	}
1746 
1747 	if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
1748 		rc = EFAULT;
1749 free:
1750 	kmem_free(buf, buf_size);
1751 	return (rc);
1752 }
1753 
1754 static int
get_devlog(struct adapter * sc,void * data,int flags)1755 get_devlog(struct adapter *sc, void *data, int flags)
1756 {
1757 	struct devlog_params *dparams = &sc->params.devlog;
1758 	struct fw_devlog_e *buf;
1759 	struct t4_devlog dl;
1760 	int rc = 0;
1761 
1762 	if (ddi_copyin(data, &dl, sizeof (dl), flags) < 0) {
1763 		rc = EFAULT;
1764 		goto done;
1765 	}
1766 
1767 	if (dparams->start == 0) {
1768 		dparams->memtype = 0;
1769 		dparams->start = 0x84000;
1770 		dparams->size = 32768;
1771 	}
1772 
1773 	if (dl.len < dparams->size) {
1774 		dl.len = dparams->size;
1775 		rc = ddi_copyout(&dl, data, sizeof (dl), flags);
1776 		/*
1777 		 * rc = 0 indicates copyout was successful, then return ENOBUFS
1778 		 * to indicate that the buffer size was not enough. Return of
1779 		 * EFAULT indicates that the copyout was not successful.
1780 		 */
1781 		rc = (rc == 0) ? ENOBUFS : EFAULT;
1782 		goto done;
1783 	}
1784 
1785 	buf = kmem_zalloc(dparams->size, KM_NOSLEEP);
1786 	if (buf == NULL) {
1787 		rc = ENOMEM;
1788 		goto done;
1789 	}
1790 
1791 	rc = -t4_memory_rw(sc, sc->params.drv_memwin, dparams->memtype,
1792 	    dparams->start, dparams->size, (void *)buf, T4_MEMORY_READ);
1793 	if (rc != 0)
1794 		goto done1;
1795 
1796 	/* Copyout device log buffer and then carrier buffer */
1797 	if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof (dl)), dl.len,
1798 	    flags) < 0)
1799 		rc = EFAULT;
1800 
1801 	if (ddi_copyout(&dl, data, sizeof (dl), flags) < 0)
1802 		rc = EFAULT;
1803 
1804 done1:
1805 	kmem_free(buf, dparams->size);
1806 
1807 done:
1808 	return (rc);
1809 }
1810 
1811 static int
flash_fw(struct adapter * sc,void * data,int flags)1812 flash_fw(struct adapter *sc, void *data, int flags)
1813 {
1814 	unsigned int mbox = M_PCIE_FW_MASTER + 1;
1815 	struct t4_ldfw fw;
1816 	u8 *ptr = NULL;
1817 	int rc = 0;
1818 
1819 	if (ddi_copyin(data, &fw, sizeof (struct t4_ldfw), flags) < 0)
1820 		return (EFAULT);
1821 
1822 	if (!fw.len)
1823 		return (EINVAL);
1824 
1825 	ptr = (u8 *)kmem_zalloc(fw.len, KM_NOSLEEP);
1826 	if (ptr == NULL)
1827 		return (ENOMEM);
1828 
1829 	if (ddi_copyin((void *)((uintptr_t)data + sizeof (fw)), ptr, fw.len,
1830 	    flags) < 0) {
1831 		kmem_free(ptr, fw.len);
1832 		return (EFAULT);
1833 	}
1834 
1835 	if (sc->flags & TAF_INIT_DONE)
1836 		mbox = sc->mbox;
1837 
1838 	rc = -t4_fw_upgrade(sc, mbox, ptr, fw.len, true);
1839 	ddi_ufm_update(sc->ufm_hdl);
1840 
1841 	kmem_free(ptr, fw.len);
1842 
1843 	return (rc);
1844 }
1845 
1846 static int
get_cudbg(struct adapter * sc,void * data,int flags)1847 get_cudbg(struct adapter *sc, void *data, int flags)
1848 {
1849 	struct t4_cudbg_dump dump;
1850 	struct cudbg_init *cudbg;
1851 	void *handle, *buf;
1852 	int size;
1853 	int rc = 0;
1854 
1855 	if (ddi_copyin(data, &dump, sizeof (struct t4_cudbg_dump), flags) < 0)
1856 		return (EFAULT);
1857 
1858 	size = dump.len;
1859 	buf = (u8 *)kmem_zalloc(dump.len, KM_NOSLEEP);
1860 	if (buf == NULL)
1861 		return (ENOMEM);
1862 
1863 	handle = cudbg_alloc_handle();
1864 	if (handle == NULL) {
1865 		rc = ENOMEM;
1866 		goto free;
1867 	}
1868 
1869 	cudbg = cudbg_get_init(handle);
1870 	cudbg->adap = sc;
1871 	cudbg->print = cxgb_printf;
1872 
1873 	memcpy(cudbg->dbg_bitmap, dump.bitmap, sizeof (cudbg->dbg_bitmap));
1874 
1875 	rc = cudbg_collect(handle, buf, &dump.len);
1876 	if (rc != 0) {
1877 		cxgb_printf(sc->dip, CE_WARN, "cudbg collect failed\n");
1878 		goto exit;
1879 	}
1880 
1881 	if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof (dump)),
1882 	    dump.len, flags) < 0) {
1883 		rc = EFAULT;
1884 	}
1885 
1886 	if (ddi_copyout(&dump, data, sizeof (dump), flags) < 0) {
1887 		rc = EFAULT;
1888 	}
1889 exit:
1890 	cudbg_free_handle(handle);
1891 free:
1892 	kmem_free(buf, size);
1893 
1894 	return (rc);
1895 }
1896