1 /* BEGIN CSTYLED */
2
3 /*
4 * Copyright (c) 2009, Intel Corporation.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 *
26 * Authors:
27 * Keith Packard <keithp@keithp.com>
28 *
29 */
30
31 /*
32 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
33 * Use is subject to license terms.
34 */
35
36 #include "drmP.h"
37 #include "drm.h"
38 #include "i915_drm.h"
39 #include "i915_drv.h"
40
41 #define BUFFER_FAIL(_count, _len, _name) { \
42 DRM_ERROR("Buffer size too small in %s (%d < %d)\n", \
43 (_name), (_count), (_len)); \
44 (*failures)++; \
45 return count; \
46 }
47
48
49 static uint32_t saved_s2 = 0, saved_s4 = 0;
50 static char saved_s2_set = 0, saved_s4_set = 0;
51
52 static float
int_as_float(uint32_t intval)53 int_as_float(uint32_t intval)
54 {
55 union intfloat {
56 uint32_t i;
57 float f;
58 } uval;
59
60 uval.i = intval;
61 return uval.f;
62 }
63
64 static void
instr_out(uint32_t * data,uint32_t hw_offset,unsigned int index,const char * fmt,...)65 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
66 const char *fmt, ...)
67 {
68
69 DRM_ERROR("0x%08x: 0x%08x:%s ", hw_offset + index * 4, data[index],
70 index == 0 ? "" : " ");
71 va_list ap;
72
73 va_start(ap, fmt);
74 vcmn_err(CE_WARN, fmt, ap);
75 va_end(ap);
76
77 }
78
79 static int
decode_mi(uint32_t * data,int count,uint32_t hw_offset,int * failures)80 decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures)
81 {
82 unsigned int opcode;
83
84 struct {
85 uint32_t opcode;
86 int min_len;
87 int max_len;
88 char *name;
89 } opcodes_mi[] = {
90 { 0x08, 1, 1, "MI_ARB_ON_OFF" },
91 { 0x0a, 1, 1, "MI_BATCH_BUFFER_END" },
92 { 0x31, 2, 2, "MI_BATCH_BUFFER_START" },
93 { 0x14, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
94 { 0x04, 1, 1, "MI_FLUSH" },
95 { 0x22, 3, 3, "MI_LOAD_REGISTER_IMM" },
96 { 0x13, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
97 { 0x12, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
98 { 0x00, 1, 1, "MI_NOOP" },
99 { 0x11, 2, 2, "MI_OVERLAY_FLIP" },
100 { 0x07, 1, 1, "MI_REPORT_HEAD" },
101 { 0x18, 2, 2, "MI_SET_CONTEXT" },
102 { 0x20, 3, 4, "MI_STORE_DATA_IMM" },
103 { 0x21, 3, 4, "MI_STORE_DATA_INDEX" },
104 { 0x24, 3, 3, "MI_STORE_REGISTER_MEM" },
105 { 0x02, 1, 1, "MI_USER_INTERRUPT" },
106 { 0x03, 1, 1, "MI_WAIT_FOR_EVENT" },
107 };
108
109
110 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
111 opcode++) {
112 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
113 unsigned int len = 1, i;
114
115 instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name);
116 if (opcodes_mi[opcode].max_len > 1) {
117 len = (data[0] & 0x000000ff) + 2;
118 if (len < opcodes_mi[opcode].min_len ||
119 len > opcodes_mi[opcode].max_len)
120 {
121 DRM_ERROR("Bad length in %s\n",
122 opcodes_mi[opcode].name);
123 }
124 }
125
126 for (i = 1; i < len; i++) {
127 if (i >= count)
128 BUFFER_FAIL(count, len, opcodes_mi[opcode].name);
129 instr_out(data, hw_offset, i, "dword %d\n", i);
130 }
131
132 return len;
133 }
134 }
135
136 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
137 (*failures)++;
138 return 1;
139 }
140
141 static int
decode_2d(uint32_t * data,int count,uint32_t hw_offset,int * failures)142 decode_2d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
143 {
144 unsigned int opcode, len;
145 char *format = NULL;
146
147 struct {
148 uint32_t opcode;
149 int min_len;
150 int max_len;
151 char *name;
152 } opcodes_2d[] = {
153 { 0x40, 5, 5, "COLOR_BLT" },
154 { 0x43, 6, 6, "SRC_COPY_BLT" },
155 { 0x01, 8, 8, "XY_SETUP_BLT" },
156 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
157 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
158 { 0x24, 2, 2, "XY_PIXEL_BLT" },
159 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
160 { 0x26, 4, 4, "Y_TEXT_BLT" },
161 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
162 { 0x50, 6, 6, "XY_COLOR_BLT" },
163 { 0x51, 6, 6, "XY_PAT_BLT" },
164 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
165 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
166 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
167 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
168 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
169 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
170 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
171 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
172 { 0x55, 9, 9, "XY_FULL_BLT" },
173 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
174 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
175 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
176 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
177 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT" },
178 };
179
180 switch ((data[0] & 0x1fc00000) >> 22) {
181 case 0x50:
182 instr_out(data, hw_offset, 0,
183 "XY_COLOR_BLT (rgb %sabled, alpha %sabled, dst tile %d)\n",
184 (data[0] & (1 << 20)) ? "en" : "dis",
185 (data[0] & (1 << 21)) ? "en" : "dis",
186 (data[0] >> 11) & 1);
187
188 len = (data[0] & 0x000000ff) + 2;
189 if (len != 6)
190 DRM_ERROR("Bad count in XY_COLOR_BLT\n");
191 if (count < 6)
192 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
193
194 switch ((data[1] >> 24) & 0x3) {
195 case 0:
196 format="8";
197 break;
198 case 1:
199 format="565";
200 break;
201 case 2:
202 format="1555";
203 break;
204 case 3:
205 format="8888";
206 break;
207 }
208
209 instr_out(data, hw_offset, 1, "format %s, pitch %d, "
210 "clipping %sabled\n", format,
211 (short)(data[1] & 0xffff),
212 data[1] & (1 << 30) ? "en" : "dis");
213 instr_out(data, hw_offset, 2, "(%d,%d)\n",
214 data[2] & 0xffff, data[2] >> 16);
215 instr_out(data, hw_offset, 3, "(%d,%d)\n",
216 data[3] & 0xffff, data[3] >> 16);
217 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
218 instr_out(data, hw_offset, 5, "color\n");
219 return len;
220 case 0x53:
221 instr_out(data, hw_offset, 0,
222 "XY_SRC_COPY_BLT (rgb %sabled, alpha %sabled, "
223 "src tile %d, dst tile %d)\n",
224 (data[0] & (1 << 20)) ? "en" : "dis",
225 (data[0] & (1 << 21)) ? "en" : "dis",
226 (data[0] >> 15) & 1,
227 (data[0] >> 11) & 1);
228
229 len = (data[0] & 0x000000ff) + 2;
230 if (len != 8)
231 DRM_ERROR("Bad count in XY_SRC_COPY_BLT\n");
232 if (count < 8)
233 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
234
235 switch ((data[1] >> 24) & 0x3) {
236 case 0:
237 format="8";
238 break;
239 case 1:
240 format="565";
241 break;
242 case 2:
243 format="1555";
244 break;
245 case 3:
246 format="8888";
247 break;
248 }
249
250 instr_out(data, hw_offset, 1, "format %s, dst pitch %d, "
251 "clipping %sabled\n", format,
252 (short)(data[1] & 0xffff),
253 data[1] & (1 << 30) ? "en" : "dis");
254 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
255 data[2] & 0xffff, data[2] >> 16);
256 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
257 data[3] & 0xffff, data[3] >> 16);
258 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
259 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
260 data[5] & 0xffff, data[5] >> 16);
261 instr_out(data, hw_offset, 6, "src pitch %d\n",
262 (short)(data[6] & 0xffff));
263 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
264 return len;
265 }
266
267 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
268 opcode++) {
269 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
270 unsigned int i;
271
272 len = 1;
273 instr_out(data, hw_offset, 0, "%s\n", opcodes_2d[opcode].name);
274 if (opcodes_2d[opcode].max_len > 1) {
275 len = (data[0] & 0x000000ff) + 2;
276 if (len < opcodes_2d[opcode].min_len ||
277 len > opcodes_2d[opcode].max_len)
278 {
279 DRM_ERROR("Bad count in %s\n", opcodes_2d[opcode].name);
280 }
281 }
282
283 for (i = 1; i < len; i++) {
284 if (i >= count)
285 BUFFER_FAIL(count, len, opcodes_2d[opcode].name);
286 instr_out(data, hw_offset, i, "dword %d\n", i);
287 }
288
289 return len;
290 }
291 }
292
293 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
294 (*failures)++;
295 return 1;
296 }
297
298 /*ARGSUSED*/
299 static int
decode_3d_1c(uint32_t * data,int count,uint32_t hw_offset,int * failures)300 decode_3d_1c(uint32_t *data, int count, uint32_t hw_offset, int *failures)
301 {
302 switch ((data[0] & 0x00f80000) >> 19) {
303 case 0x11:
304 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\n");
305 return 1;
306 case 0x10:
307 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n");
308 return 1;
309 case 0x01:
310 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
311 return 1;
312 case 0x0a:
313 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
314 return 1;
315 case 0x05:
316 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
317 return 1;
318 }
319
320 instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
321 (*failures)++;
322 return 1;
323 }
324
325 static int
decode_3d_1d(uint32_t * data,int count,uint32_t hw_offset,int * failures,int i830)326 decode_3d_1d(uint32_t *data, int count, uint32_t hw_offset, int *failures, int i830)
327 {
328 unsigned int len, i, c, opcode, word, map, sampler, instr;
329
330 struct {
331 uint32_t opcode;
332 int i830_only;
333 int min_len;
334 int max_len;
335 char *name;
336 } opcodes_3d_1d[] = {
337 { 0x8e, 0, 3, 3, "3DSTATE_BUFFER_INFO" },
338 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
339 { 0x9c, 0, 1, 1, "3DSTATE_CLEAR_PARAMETERS" },
340 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
341 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
342 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
343 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
344 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
345 { 0x85, 0, 2, 2, "3DSTATE_DEST_BUFFER_VARIABLES" },
346 { 0x80, 0, 5, 5, "3DSTATE_DRAWING_RECTANGLE" },
347 { 0x8e, 0, 3, 3, "3DSTATE_BUFFER_INFO" },
348 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
349 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
350 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
351 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
352 { 0x81, 0, 3, 3, "3DSTATE_SCISSOR_RECTANGLE" },
353 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
354 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
355 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
356 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
357 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
358 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830" },
359 };
360
361 switch ((data[0] & 0x00ff0000) >> 16) {
362 case 0x07:
363 /* This instruction is unusual. A 0 length means just 1 DWORD instead of
364 * 2. The 0 length is specified in one place to be unsupported, but
365 * stated to be required in another, and 0 length LOAD_INDIRECTs appear
366 * to cause no harm at least.
367 */
368 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
369 len = (data[0] & 0x000000ff) + 1;
370 i = 1;
371 if (data[0] & (0x01 << 8)) {
372 if (i + 2 >= count)
373 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
374 instr_out(data, hw_offset, i++, "SIS.0\n");
375 instr_out(data, hw_offset, i++, "SIS.1\n");
376 }
377 if (data[0] & (0x02 << 8)) {
378 if (i + 1 >= count)
379 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
380 instr_out(data, hw_offset, i++, "DIS.0\n");
381 }
382 if (data[0] & (0x04 << 8)) {
383 if (i + 2 >= count)
384 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
385 instr_out(data, hw_offset, i++, "SSB.0\n");
386 instr_out(data, hw_offset, i++, "SSB.1\n");
387 }
388 if (data[0] & (0x08 << 8)) {
389 if (i + 2 >= count)
390 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
391 instr_out(data, hw_offset, i++, "MSB.0\n");
392 instr_out(data, hw_offset, i++, "MSB.1\n");
393 }
394 if (data[0] & (0x10 << 8)) {
395 if (i + 2 >= count)
396 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
397 instr_out(data, hw_offset, i++, "PSP.0\n");
398 instr_out(data, hw_offset, i++, "PSP.1\n");
399 }
400 if (data[0] & (0x20 << 8)) {
401 if (i + 2 >= count)
402 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
403 instr_out(data, hw_offset, i++, "PSC.0\n");
404 instr_out(data, hw_offset, i++, "PSC.1\n");
405 }
406 if (len != i) {
407 DRM_ERROR("Bad count in 3DSTATE_LOAD_INDIRECT\n");
408 (*failures)++;
409 return len;
410 }
411 return len;
412 case 0x04:
413 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
414 len = (data[0] & 0x0000000f) + 2;
415 i = 1;
416 for (word = 0; word <= 7; word++) {
417 if (data[0] & (1 << (4 + word))) {
418 if (i >= count)
419 BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_1");
420
421 /* save vertex state for decode */
422 if (word == 2) {
423 saved_s2_set = 1;
424 saved_s2 = data[i];
425 }
426 if (word == 4) {
427 saved_s4_set = 1;
428 saved_s4 = data[i];
429 }
430
431 instr_out(data, hw_offset, i++, "S%d\n", word);
432 }
433 }
434 if (len != i) {
435 DRM_ERROR("Bad count in 3DSTATE_LOAD_INDIRECT\n");
436 (*failures)++;
437 }
438 return len;
439 case 0x00:
440 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
441 len = (data[0] & 0x0000003f) + 2;
442
443 i = 1;
444 for (map = 0; map <= 15; map++) {
445 if (data[1] & (1 << map)) {
446 if (i + 3 >= count)
447 BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
448 instr_out(data, hw_offset, i++, "map %d MS2\n", map);
449 instr_out(data, hw_offset, i++, "map %d MS3\n", map);
450 instr_out(data, hw_offset, i++, "map %d MS4\n", map);
451 }
452 }
453 if (len != i) {
454 DRM_ERROR("Bad count in 3DSTATE_MAP_STATE\n");
455 (*failures)++;
456 return len;
457 }
458 return len;
459 case 0x06:
460 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
461 len = (data[0] & 0x000000ff) + 2;
462
463 i = 1;
464 for (c = 0; c <= 31; c++) {
465 if (data[1] & (1 << c)) {
466 if (i + 4 >= count)
467 BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_CONSTANTS");
468 instr_out(data, hw_offset, i, "C%d.X = %f\n",
469 c, int_as_float(data[i]));
470 i++;
471 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
472 c, int_as_float(data[i]));
473 i++;
474 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
475 c, int_as_float(data[i]));
476 i++;
477 instr_out(data, hw_offset, i, "C%d.W = %f\n",
478 c, int_as_float(data[i]));
479 i++;
480 }
481 }
482 if (len != i) {
483 DRM_ERROR("Bad count in 3DSTATE_MAP_STATE\n");
484 (*failures)++;
485 }
486 return len;
487 case 0x05:
488 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
489 len = (data[0] & 0x000000ff) + 2;
490 if ((len - 1) % 3 != 0 || len > 370) {
491 DRM_ERROR("Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
492 (*failures)++;
493 }
494 i = 1;
495 for (instr = 0; instr < (len - 1) / 3; instr++) {
496 if (i + 3 >= count)
497 BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
498 instr_out(data, hw_offset, i++, "PS%03x\n", instr);
499 instr_out(data, hw_offset, i++, "PS%03x\n", instr);
500 instr_out(data, hw_offset, i++, "PS%03x\n", instr);
501 }
502 return len;
503 case 0x01:
504 if (i830)
505 break;
506 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
507 len = (data[0] & 0x0000003f) + 2;
508 i = 1;
509 for (sampler = 0; sampler <= 15; sampler++) {
510 if (data[1] & (1 << sampler)) {
511 if (i + 3 >= count)
512 BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE");
513 instr_out(data, hw_offset, i++, "sampler %d SS2\n",
514 sampler);
515 instr_out(data, hw_offset, i++, "sampler %d SS3\n",
516 sampler);
517 instr_out(data, hw_offset, i++, "sampler %d SS4\n",
518 sampler);
519 }
520 }
521 if (len != i) {
522 DRM_ERROR("Bad count in 3DSTATE_SAMPLER_STATE\n");
523 (*failures)++;
524 }
525 return len;
526 }
527
528 for (opcode = 0; opcode < sizeof(opcodes_3d_1d) / sizeof(opcodes_3d_1d[0]);
529 opcode++)
530 {
531 if (opcodes_3d_1d[opcode].i830_only && !i830)
532 continue;
533
534 if (((data[0] & 0x00ff0000) >> 16) == opcodes_3d_1d[opcode].opcode) {
535 len = 1;
536
537 instr_out(data, hw_offset, 0, "%s\n", opcodes_3d_1d[opcode].name);
538 if (opcodes_3d_1d[opcode].max_len > 1) {
539 len = (data[0] & 0x0000ffff) + 2;
540 if (len < opcodes_3d_1d[opcode].min_len ||
541 len > opcodes_3d_1d[opcode].max_len)
542 {
543 DRM_ERROR("Bad count in %s\n",
544 opcodes_3d_1d[opcode].name);
545 (*failures)++;
546 }
547 }
548
549 for (i = 1; i < len; i++) {
550 if (i >= count)
551 BUFFER_FAIL(count, len, opcodes_3d_1d[opcode].name);
552 instr_out(data, hw_offset, i, "dword %d\n", i);
553 }
554
555 return len;
556 }
557 }
558
559 instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
560 (*failures)++;
561 return 1;
562 }
563
564 static int
decode_3d_primitive(uint32_t * data,int count,uint32_t hw_offset,int * failures)565 decode_3d_primitive(uint32_t *data, int count, uint32_t hw_offset,
566 int *failures)
567 {
568 char immediate = (data[0] & (1 << 23)) == 0;
569 unsigned int len, i;
570 char *primtype;
571
572 switch ((data[0] >> 18) & 0xf) {
573 case 0x0: primtype = "TRILIST"; break;
574 case 0x1: primtype = "TRISTRIP"; break;
575 case 0x2: primtype = "TRISTRIP_REVERSE"; break;
576 case 0x3: primtype = "TRIFAN"; break;
577 case 0x4: primtype = "POLYGON"; break;
578 case 0x5: primtype = "LINELIST"; break;
579 case 0x6: primtype = "LINESTRIP"; break;
580 case 0x7: primtype = "RECTLIST"; break;
581 case 0x8: primtype = "POINTLIST"; break;
582 case 0x9: primtype = "DIB"; break;
583 case 0xa: primtype = "CLEAR_RECT"; break;
584 default: primtype = "unknown"; break;
585 }
586
587 /* XXX: 3DPRIM_DIB not supported */
588 if (immediate) {
589 len = (data[0] & 0x0003ffff) + 2;
590 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n", primtype);
591 if (count < len)
592 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
593 if (!saved_s2_set || !saved_s4_set) {
594 DRM_ERROR("unknown vertex format\n");
595 for (i = 1; i < len; i++) {
596 instr_out(data, hw_offset, i,
597 " vertex data (%f float)\n",
598 int_as_float(data[i]));
599 }
600 } else {
601 unsigned int vertex = 0;
602 for (i = 1; i < len;) {
603 unsigned int tc;
604
605 #define VERTEX_OUT(fmt, ...) { \
606 if (i < len) \
607 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
608 else \
609 DRM_ERROR(" missing data in V%d\n", vertex); \
610 i++; \
611 }
612
613 VERTEX_OUT("X = %f", int_as_float(data[i]));
614 VERTEX_OUT("Y = %f", int_as_float(data[i]));
615 switch (saved_s4 >> 6 & 0x7) {
616 case 0x1:
617 VERTEX_OUT("Z = %f", int_as_float(data[i]));
618 break;
619 case 0x2:
620 VERTEX_OUT("Z = %f", int_as_float(data[i]));
621 VERTEX_OUT("W = %f", int_as_float(data[i]));
622 break;
623 case 0x3:
624 break;
625 case 0x4:
626 VERTEX_OUT("W = %f", int_as_float(data[i]));
627 break;
628 default:
629 DRM_ERROR("bad S4 position mask\n");
630 }
631
632 if (saved_s4 & (1 << 10)) {
633 VERTEX_OUT("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
634 "B=0x%02x)",
635 data[i] >> 24,
636 (data[i] >> 16) & 0xff,
637 (data[i] >> 8) & 0xff,
638 data[i] & 0xff);
639 }
640 if (saved_s4 & (1 << 11)) {
641 VERTEX_OUT("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
642 "B=0x%02x)",
643 data[i] >> 24,
644 (data[i] >> 16) & 0xff,
645 (data[i] >> 8) & 0xff,
646 data[i] & 0xff);
647 }
648 if (saved_s4 & (1 << 12))
649 VERTEX_OUT("width = 0x%08x)", data[i]);
650
651 for (tc = 0; tc <= 7; tc++) {
652 switch ((saved_s2 >> (tc * 4)) & 0xf) {
653 case 0x0:
654 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
655 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
656 break;
657 case 0x1:
658 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
659 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
660 VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
661 break;
662 case 0x2:
663 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
664 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
665 VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
666 VERTEX_OUT("T%d.W = %f", tc, int_as_float(data[i]));
667 break;
668 case 0x3:
669 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
670 break;
671 case 0x4:
672 VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
673 break;
674 case 0x5:
675 VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
676 VERTEX_OUT("T%d.ZW = 0x%08x half-float", tc, data[i]);
677 break;
678 case 0xf:
679 break;
680 default:
681 DRM_ERROR("bad S2.T%d format\n", tc);
682 }
683 }
684 vertex++;
685 }
686 }
687 } else {
688 /* indirect vertices */
689 len = data[0] & 0x0000ffff; /* index count */
690 if (data[0] & (1 << 17)) {
691 /* random vertex access */
692 if (count < (len + 1) / 2 + 1)
693 BUFFER_FAIL(count, (len + 1) / 2 + 1, "3DPRIMITIVE random indirect");
694 instr_out(data, hw_offset, 0,
695 "3DPRIMITIVE random indirect %s (%d)\n", primtype, len);
696 if (len == 0) {
697 /* vertex indices continue until 0xffff is found */
698 for (i = 1; i < count; i++) {
699 if ((data[i] & 0xffff) == 0xffff) {
700 instr_out(data, hw_offset, i,
701 " indices: (terminator)\n");
702 return i;
703 } else if ((data[i] >> 16) == 0xffff) {
704 instr_out(data, hw_offset, i,
705 " indices: 0x%04x, "
706 "(terminator)\n",
707 data[i] & 0xffff);
708 return i;
709 } else {
710 instr_out(data, hw_offset, i,
711 " indices: 0x%04x, 0x%04x\n",
712 data[i] & 0xffff, data[i] >> 16);
713 }
714 }
715 DRM_ERROR("3DPRIMITIVE: no terminator found in index buffer\n");
716 (*failures)++;
717 return count;
718 } else {
719 /* fixed size vertex index buffer */
720 for (i = 0; i < len; i += 2) {
721 if (i * 2 == len - 1) {
722 instr_out(data, hw_offset, i,
723 " indices: 0x%04x\n",
724 data[i] & 0xffff);
725 } else {
726 instr_out(data, hw_offset, i,
727 " indices: 0x%04x, 0x%04x\n",
728 data[i] & 0xffff, data[i] >> 16);
729 }
730 }
731 }
732 return (len + 1) / 2 + 1;
733 } else {
734 /* sequential vertex access */
735 if (count < 2)
736 BUFFER_FAIL(count, 2, "3DPRIMITIVE seq indirect");
737 instr_out(data, hw_offset, 0,
738 "3DPRIMITIVE sequential indirect %s, %d starting from "
739 "%d\n", primtype, len, data[1] & 0xffff);
740 instr_out(data, hw_offset, 1, " start\n");
741 return 2;
742 }
743 }
744
745 return len;
746 }
747
748 static int
decode_3d(uint32_t * data,int count,uint32_t hw_offset,int * failures)749 decode_3d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
750 {
751 unsigned int opcode;
752
753 struct {
754 uint32_t opcode;
755 int min_len;
756 int max_len;
757 char *name;
758 } opcodes_3d[] = {
759 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
760 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
761 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
762 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
763 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
764 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
765 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
766 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
767 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
768 };
769
770 switch ((data[0] & 0x1f000000) >> 24) {
771 case 0x1f:
772 return decode_3d_primitive(data, count, hw_offset, failures);
773 case 0x1d:
774 return decode_3d_1d(data, count, hw_offset, failures, 0);
775 case 0x1c:
776 return decode_3d_1c(data, count, hw_offset, failures);
777 }
778
779 for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
780 opcode++) {
781 if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) {
782 unsigned int len = 1, i;
783
784 instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
785 if (opcodes_3d[opcode].max_len > 1) {
786 len = (data[0] & 0xff) + 2;
787 if (len < opcodes_3d[opcode].min_len ||
788 len > opcodes_3d[opcode].max_len)
789 {
790 DRM_ERROR("Bad count in %s\n", opcodes_3d[opcode].name);
791 }
792 }
793
794 for (i = 1; i < len; i++) {
795 if (i >= count)
796 BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
797 instr_out(data, hw_offset, i, "dword %d\n", i);
798 }
799 return len;
800 }
801 }
802
803 instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
804 (*failures)++;
805 return 1;
806 }
807
808 static const char *
get_965_surfacetype(unsigned int surfacetype)809 get_965_surfacetype(unsigned int surfacetype)
810 {
811 switch (surfacetype) {
812 case 0: return "1D";
813 case 1: return "2D";
814 case 2: return "3D";
815 case 3: return "CUBE";
816 case 4: return "BUFFER";
817 case 7: return "NULL";
818 default: return "unknown";
819 }
820 }
821
822 static const char *
get_965_depthformat(unsigned int depthformat)823 get_965_depthformat(unsigned int depthformat)
824 {
825 switch (depthformat) {
826 case 0: return "s8_z24float";
827 case 1: return "z32float";
828 case 2: return "z24s8";
829 case 5: return "z16";
830 default: return "unknown";
831 }
832 }
833
834 static int
decode_3d_965(uint32_t * data,int count,uint32_t hw_offset,int * failures)835 decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, int *failures)
836 {
837 unsigned int opcode, len;
838
839 struct {
840 uint32_t opcode;
841 int min_len;
842 int max_len;
843 char *name;
844 } opcodes_3d[] = {
845 { 0x6000, 3, 3, "URB_FENCE" },
846 { 0x6001, 2, 2, "CS_URB_STATE" },
847 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
848 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
849 { 0x6102, 2, 2 , "STATE_SIP" },
850 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
851 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
852 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
853 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
854 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
855 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
856 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
857 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
858 /* 0x7808: 3DSTATE_VERTEX_BUFFERS */
859 /* 0x7809: 3DSTATE_VERTEX_ELEMENTS */
860 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
861 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
862 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
863 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
864 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
865 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
866 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
867 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
868 { 0x7b00, 6, 6, "3DPRIMITIVE" },
869 };
870
871 len = (data[0] & 0x0000ffff) + 2;
872
873 switch ((data[0] & 0xffff0000) >> 16) {
874 case 0x6101:
875 if (len != 6)
876 DRM_ERROR("Bad count in STATE_BASE_ADDRESS\n");
877 if (count < 6)
878 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
879
880 instr_out(data, hw_offset, 0,
881 "STATE_BASE_ADDRESS\n");
882
883 if (data[1] & 1) {
884 instr_out(data, hw_offset, 1, "General state at 0x%08x\n",
885 data[1] & ~1);
886 } else
887 instr_out(data, hw_offset, 1, "General state not updated\n");
888
889 if (data[2] & 1) {
890 instr_out(data, hw_offset, 2, "Surface state at 0x%08x\n",
891 data[2] & ~1);
892 } else
893 instr_out(data, hw_offset, 2, "Surface state not updated\n");
894
895 if (data[3] & 1) {
896 instr_out(data, hw_offset, 3, "Indirect state at 0x%08x\n",
897 data[3] & ~1);
898 } else
899 instr_out(data, hw_offset, 3, "Indirect state not updated\n");
900
901 if (data[4] & 1) {
902 instr_out(data, hw_offset, 4, "General state upper bound 0x%08x\n",
903 data[4] & ~1);
904 } else
905 instr_out(data, hw_offset, 4, "General state not updated\n");
906
907 if (data[5] & 1) {
908 instr_out(data, hw_offset, 5, "Indirect state upper bound 0x%08x\n",
909 data[5] & ~1);
910 } else
911 instr_out(data, hw_offset, 5, "Indirect state not updated\n");
912
913 return len;
914 case 0x7800:
915 if (len != 7)
916 DRM_ERROR("Bad count in 3DSTATE_PIPELINED_POINTERS\n");
917 if (count < 7)
918 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
919
920 instr_out(data, hw_offset, 0,
921 "3DSTATE_PIPELINED_POINTERS\n");
922 instr_out(data, hw_offset, 1, "VS state\n");
923 instr_out(data, hw_offset, 2, "GS state\n");
924 instr_out(data, hw_offset, 3, "Clip state\n");
925 instr_out(data, hw_offset, 4, "SF state\n");
926 instr_out(data, hw_offset, 5, "WM state\n");
927 instr_out(data, hw_offset, 6, "CC state\n");
928 return len;
929 case 0x7801:
930 if (len != 6)
931 DRM_ERROR("Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
932 if (count < 6)
933 BUFFER_FAIL(count, len, "3DSTATE_BINDING_TABLE_POINTERS");
934
935 instr_out(data, hw_offset, 0,
936 "3DSTATE_BINDING_TABLE_POINTERS\n");
937 instr_out(data, hw_offset, 1, "VS binding table\n");
938 instr_out(data, hw_offset, 2, "GS binding table\n");
939 instr_out(data, hw_offset, 3, "Clip binding table\n");
940 instr_out(data, hw_offset, 4, "SF binding table\n");
941 instr_out(data, hw_offset, 5, "WM binding table\n");
942
943 return len;
944
945 case 0x7900:
946 if (len != 4)
947 DRM_ERROR("Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
948 if (count < 4)
949 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
950
951 instr_out(data, hw_offset, 0,
952 "3DSTATE_DRAWING_RECTANGLE\n");
953 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
954 data[1] & 0xffff,
955 (data[1] >> 16) & 0xffff);
956 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
957 data[2] & 0xffff,
958 (data[2] >> 16) & 0xffff);
959 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
960 (int)data[3] & 0xffff,
961 ((int)data[3] >> 16) & 0xffff);
962
963 return len;
964
965 case 0x7905:
966 if (len != 5)
967 DRM_ERROR("Bad count in 3DSTATE_DEPTH_BUFFER\n");
968 if (count < 5)
969 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
970
971 instr_out(data, hw_offset, 0,
972 "3DSTATE_DEPTH_BUFFER\n");
973 instr_out(data, hw_offset, 1, "%s, %s, pitch = %d bytes, %stiled\n",
974 get_965_surfacetype(data[1] >> 29),
975 get_965_depthformat((data[1] >> 18) & 0x7),
976 (data[1] & 0x0001ffff) + 1,
977 data[1] & (1 << 27) ? "" : "not ");
978 instr_out(data, hw_offset, 2, "depth offset\n");
979 instr_out(data, hw_offset, 3, "%dx%d\n",
980 ((data[3] & 0x0007ffc0) >> 6) + 1,
981 ((data[3] & 0xfff80000) >> 19) + 1);
982 instr_out(data, hw_offset, 4, "volume depth\n");
983
984 return len;
985 }
986
987 for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
988 opcode++) {
989 if ((data[0] & 0xffff0000) >> 16 == opcodes_3d[opcode].opcode) {
990 unsigned int i;
991 len = 1;
992
993 instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
994 if (opcodes_3d[opcode].max_len > 1) {
995 len = (data[0] & 0xff) + 2;
996 if (len < opcodes_3d[opcode].min_len ||
997 len > opcodes_3d[opcode].max_len)
998 {
999 DRM_ERROR("Bad count in %s\n", opcodes_3d[opcode].name);
1000 }
1001 }
1002
1003 for (i = 1; i < len; i++) {
1004 if (i >= count)
1005 BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
1006 instr_out(data, hw_offset, i, "dword %d\n", i);
1007 }
1008 return len;
1009 }
1010 }
1011
1012 instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
1013 (*failures)++;
1014 return 1;
1015 }
1016
1017
1018 static int
decode_3d_i830(uint32_t * data,int count,uint32_t hw_offset,int * failures)1019 decode_3d_i830(uint32_t *data, int count, uint32_t hw_offset, int *failures)
1020 {
1021 unsigned int opcode;
1022
1023 struct {
1024 uint32_t opcode;
1025 int min_len;
1026 int max_len;
1027 char *name;
1028 } opcodes_3d[] = {
1029 { 0x02, 1, 1, "3DSTATE_MODES_3" },
1030 { 0x03, 1, 1, "3DSTATE_ENABLES_1"},
1031 { 0x04, 1, 1, "3DSTATE_ENABLES_2"},
1032 { 0x05, 1, 1, "3DSTATE_VFT0"},
1033 { 0x06, 1, 1, "3DSTATE_AA"},
1034 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
1035 { 0x08, 1, 1, "3DSTATE_MODES_1" },
1036 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
1037 { 0x0a, 1, 1, "3DSTATE_VFT1"},
1038 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
1039 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
1040 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
1041 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
1042 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
1043 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
1044 { 0x16, 1, 1, "3DSTATE_MODES_4" },
1045 };
1046
1047 switch ((data[0] & 0x1f000000) >> 24) {
1048 case 0x1f:
1049 return decode_3d_primitive(data, count, hw_offset, failures);
1050 case 0x1d:
1051 return decode_3d_1d(data, count, hw_offset, failures, 1);
1052 case 0x1c:
1053 return decode_3d_1c(data, count, hw_offset, failures);
1054 }
1055
1056 for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
1057 opcode++) {
1058 if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) {
1059 unsigned int len = 1, i;
1060
1061 instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
1062 if (opcodes_3d[opcode].max_len > 1) {
1063 len = (data[0] & 0xff) + 2;
1064 if (len < opcodes_3d[opcode].min_len ||
1065 len > opcodes_3d[opcode].max_len)
1066 {
1067 DRM_ERROR("Bad count in %s\n", opcodes_3d[opcode].name);
1068 }
1069 }
1070
1071 for (i = 1; i < len; i++) {
1072 if (i >= count)
1073 BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
1074 instr_out(data, hw_offset, i, "dword %d\n", i);
1075 }
1076 return len;
1077 }
1078 }
1079
1080 instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
1081 (*failures)++;
1082 return 1;
1083 }
1084
i915_gem_command_decode(uint32_t * data,int count,uint32_t hw_offset,struct drm_device * dev)1085 void i915_gem_command_decode(uint32_t *data, int count, uint32_t hw_offset, struct drm_device *dev)
1086 {
1087 int index = 0;
1088 int failures = 0;
1089
1090 while (index < count) {
1091 switch ((data[index] & 0xe0000000) >> 29) {
1092 case 0x0:
1093 index += decode_mi(data + index, count - index,
1094 hw_offset + index * 4, &failures);
1095 break;
1096 case 0x2:
1097 index += decode_2d(data + index, count - index,
1098 hw_offset + index * 4, &failures);
1099 break;
1100 case 0x3:
1101 if (IS_I965G(dev)) {
1102 index += decode_3d_965(data + index, count - index,
1103 hw_offset + index * 4, &failures);
1104 } else if (IS_I9XX(dev)) {
1105 index += decode_3d(data + index, count - index,
1106 hw_offset + index * 4, &failures);
1107 } else {
1108 index += decode_3d_i830(data + index, count - index,
1109 hw_offset + index * 4, &failures);
1110 }
1111 break;
1112 default:
1113 instr_out(data, hw_offset, index, "UNKNOWN\n");
1114 failures++;
1115 index++;
1116 break;
1117 }
1118 }
1119 }
1120
1121