uint64_t instruction_base;
uint64_t instruction_bound;
+FILE *outfile;
+
static inline uint32_t
field(uint32_t value, int start, int end)
{
const int dword = f->start / 32;
if (*dword_num != dword) {
- printf("0x%08"PRIx64": 0x%08x : Dword %d\n",
- offset + 4 * dword, iter->p[dword], dword);
+ fprintf(outfile, "0x%08"PRIx64": 0x%08x : Dword %d\n",
+ offset + 4 * dword, iter->p[dword], dword);
*dword_num = dword;
}
}
char *token = NULL;
if (strstr(iter->value, "struct") == NULL) {
if (strlen(iter->description) > 0) {
- printf(" %s: %s (%s)\n",
+ fprintf(outfile, " %s: %s (%s)\n",
iter->name, iter->value, iter->description);
} else {
- printf(" %s: %s\n", iter->name, iter->value);
+ fprintf(outfile, " %s: %s\n", iter->name, iter->value);
}
} else {
token = strtok(iter->value, " ");
} else {
token = NULL;
}
- printf(" %s:<struct %s>\n", iter->name, token);
+ fprintf(outfile, " %s:<struct %s>\n", iter->name, token);
}
return token;
}
if (dword_num >= starting_dword)
token = print_iterator_values(&iter, &idx);
if (token != NULL) {
- printf("0x%08"PRIx64": 0x%08x : Dword %d\n",
- offset + 4 * idx, p[idx], idx);
+ fprintf(outfile, "0x%08"PRIx64": 0x%08x : Dword %d\n",
+ offset + 4 * idx, p[idx], idx);
struct gen_group *struct_val = gen_spec_find_struct(spec, token);
decode_group(spec, struct_val, &p[idx], 0, false);
token = NULL;
surface_state = gen_spec_find_struct(spec, "RENDER_SURFACE_STATE");
if (surface_state == NULL) {
- printf("did not find RENDER_SURFACE_STATE info\n");
+ fprintf(outfile, "did not find RENDER_SURFACE_STATE info\n");
return;
}
continue;
start = pointers[i] + surface_state_base;
if (!valid_offset(start)) {
- printf("pointer %u: %08x <not valid>\n",
- i, pointers[i]);
+ fprintf(outfile, "pointer %u: %08x <not valid>\n",
+ i, pointers[i]);
continue;
} else {
- printf("pointer %u: %08x\n", i, pointers[i]);
+ fprintf(outfile, "pointer %u: %08x\n", i, pointers[i]);
}
decode_structure(spec, surface_state, gtt + start);
if (length > 10)
length = 10;
- printf("\t");
+ fprintf(outfile, "\t");
for (i = 0; i < length; i++) {
switch (type) {
case 0:
- printf("%3d ", ((uint8_t *)start)[i]);
+ fprintf(outfile, "%3d ", ((uint8_t *)start)[i]);
break;
case 1:
- printf("%3d ", ((uint16_t *)start)[i]);
+ fprintf(outfile, "%3d ", ((uint16_t *)start)[i]);
break;
case 2:
- printf("%3d ", ((uint32_t *)start)[i]);
+ fprintf(outfile, "%3d ", ((uint32_t *)start)[i]);
break;
}
}
if (length < p[4] / size)
- printf("...\n");
+ fprintf(outfile, "...\n");
else
- printf("\n");
+ fprintf(outfile, "\n");
}
static inline uint64_t
start = dynamic_state_base + offset;
for (i = 0; i < 4; i++) {
- printf("sampler state %d\n", i);
+ fprintf(outfile, "sampler state %d\n", i);
decode_structure(spec, sampler_state, gtt + start + i * 16);
}
}
descriptor_structure =
gen_spec_find_struct(spec, "INTERFACE_DESCRIPTOR_DATA");
if (descriptor_structure == NULL) {
- printf("did not find INTERFACE_DESCRIPTOR_DATA info\n");
+ fprintf(outfile, "did not find INTERFACE_DESCRIPTOR_DATA info\n");
return;
}
start = dynamic_state_base + p[3];
descriptors = gtt + start;
for (i = 0; i < length; i++, descriptors += 8) {
- printf("descriptor %u: %08x\n", i, *descriptors);
+ fprintf(outfile, "descriptor %u: %08x\n", i, *descriptors);
decode_structure(spec, descriptor_structure, descriptors);
start = instruction_base + descriptors[0];
if (!valid_offset(start)) {
- printf("kernel: %08"PRIx64" <not valid>\n", start);
+ fprintf(outfile, "kernel: %08"PRIx64" <not valid>\n", start);
continue;
} else {
- printf("kernel: %08"PRIx64"\n", start);
+ fprintf(outfile, "kernel: %08"PRIx64"\n", start);
}
insns = (struct brw_instruction *) (gtt + start);
stride = field(s[0], 0, 11);
count = 0;
- printf("vertex buffer %d, size %d\n", n, s[3]);
+ fprintf(outfile, "vertex buffer %d, size %d\n", n, s[3]);
for (dw = gtt + offset, i = 0; dw < dwend && i < 256; dw++) {
if (count == 0 && count % (8 * 4) == 0)
- printf(" ");
+ fprintf(outfile, " ");
if (probably_float(*dw))
- printf(" %8.2f", *(float *) dw);
+ fprintf(outfile, " %8.2f", *(float *) dw);
else
- printf(" 0x%08x", *dw);
+ fprintf(outfile, " 0x%08x", *dw);
i++;
count += 4;
if (count == stride) {
- printf("\n");
+ fprintf(outfile, "\n");
count = 0;
} else if (count % (8 * 4) == 0) {
- printf("\n");
+ fprintf(outfile, "\n");
} else {
- printf(" ");
+ fprintf(outfile, " ");
}
}
if (count > 0 && count % (8 * 4) != 0)
- printf("\n");
+ fprintf(outfile, "\n");
}
}
}
if (vs_enable) {
- printf("instruction_base %08"PRIx64", start %08"PRIx64"\n",
- instruction_base, start);
+ fprintf(outfile, "instruction_base %08"PRIx64", start %08"PRIx64"\n",
+ instruction_base, start);
insns = (struct brw_instruction *) (gtt + instruction_base + start);
gen_disasm_disassemble(disasm, insns, 0, stdout);
hs_enable = p[2] & 0x80000000;
if (hs_enable) {
- printf("instruction_base %08"PRIx64", start %08"PRIx64"\n",
- instruction_base, start);
+ fprintf(outfile, "instruction_base %08"PRIx64", start %08"PRIx64"\n",
+ instruction_base, start);
insns = (struct brw_instruction *) (gtt + instruction_base + start);
gen_disasm_disassemble(disasm, insns, 0, stdout);
dw = (uint32_t *) f;
for (j = 0; j < length * 8; j++) {
if (probably_float(dw[j]))
- printf(" %04.3f", f[j]);
+ fprintf(outfile, " %04.3f", f[j]);
else
- printf(" 0x%08x", dw[j]);
+ fprintf(outfile, " 0x%08x", dw[j]);
if ((j & 7) == 7)
- printf("\n");
+ fprintf(outfile, "\n");
}
}
}
}
start = instruction_base + (p[1] & mask);
- printf(" Kernel[0] %s\n", k0);
+ fprintf(outfile, " Kernel[0] %s\n", k0);
if (k0 != unused) {
insns = (struct brw_instruction *) (gtt + start);
gen_disasm_disassemble(disasm, insns, 0, stdout);
}
start = instruction_base + (p[k1_offset] & mask);
- printf(" Kernel[1] %s\n", k1);
+ fprintf(outfile, " Kernel[1] %s\n", k1);
if (k1 != unused) {
insns = (struct brw_instruction *) (gtt + start);
gen_disasm_disassemble(disasm, insns, 0, stdout);
}
start = instruction_base + (p[k2_offset] & mask);
- printf(" Kernel[2] %s\n", k2);
+ fprintf(outfile, " Kernel[2] %s\n", k2);
if (k2 != unused) {
insns = (struct brw_instruction *) (gtt + start);
gen_disasm_disassemble(disasm, insns, 0, stdout);
start = dynamic_state_base + (p[1] & ~0x1fu);
for (uint32_t i = 0; i < 4; i++) {
- printf("viewport %d\n", i);
+ fprintf(outfile, "viewport %d\n", i);
decode_structure(spec, cc_viewport, gtt + start + i * 8);
}
}
start = dynamic_state_base + (p[1] & ~0x3fu);
for (uint32_t i = 0; i < 4; i++) {
- printf("viewport %d\n", i);
+ fprintf(outfile, "viewport %d\n", i);
decode_structure(spec, sf_clip_viewport, gtt + start + i * 64);
}
}
struct gen_group *reg = gen_spec_find_register(spec, p[1]);
if (reg != NULL) {
- printf("register %s (0x%x): 0x%x\n",
- reg->name, reg->register_offset, p[2]);
+ fprintf(outfile, "register %s (0x%x): 0x%x\n",
+ reg->name, reg->register_offset, p[2]);
decode_structure(spec, reg, &p[2]);
}
}
for (p = cmds; p < end; p += length) {
inst = gen_spec_find_instruction(spec, p);
if (inst == NULL) {
- printf("unknown instruction %08x\n", p[0]);
+ fprintf(outfile, "unknown instruction %08x\n", p[0]);
length = (p[0] & 0xff) + 2;
continue;
}
else
offset = 0;
- printf("%s0x%08"PRIx64": 0x%08x: %-80s%s\n",
- color, offset, p[0],
- gen_group_get_name(inst), reset_color);
+ fprintf(outfile, "%s0x%08"PRIx64": 0x%08x: %-80s%s\n",
+ color, offset, p[0],
+ gen_group_get_name(inst), reset_color);
if (option_full_decode) {
decode_group(spec, inst, p, 1, true);
engine = GEN_ENGINE_BLITTER;
break;
default:
- printf("command write to unknown ring %d\n", type);
+ fprintf(outfile, "command write to unknown ring %d\n", type);
break;
}
if (spec == NULL || disasm == NULL)
exit(EXIT_FAILURE);
- printf("%sAubinator: Intel AUB file decoder.%-80s%s\n",
- GREEN_HEADER, "", NORMAL);
+ fprintf(outfile, "%sAubinator: Intel AUB file decoder.%-80s%s\n",
+ GREEN_HEADER, "", NORMAL);
if (input_file)
- printf("File name: %s\n", input_file);
+ fprintf(outfile, "File name: %s\n", input_file);
if (aub_pci_id)
- printf("PCI ID: 0x%x\n", aub_pci_id);
+ fprintf(outfile, "PCI ID: 0x%x\n", aub_pci_id);
char app_name[33];
strncpy(app_name, (char *)&p[2], 32);
app_name[32] = 0;
- printf("Application name: %s\n", app_name);
+ fprintf(outfile, "Application name: %s\n", app_name);
- printf("Decoding as: %s\n", gen_get_device_name(pci_id));
+ fprintf(outfile, "Decoding as: %s\n", gen_get_device_name(pci_id));
/* Throw in a new line before the first batch */
- printf("\n");
+ fprintf(outfile, "\n");
}
struct aub_file {
bias = 1;
break;
default:
- printf("unknown opcode %d at %td/%td\n",
- OPCODE(h), file->cursor - file->map,
- file->end - file->map);
+ fprintf(outfile, "unknown opcode %d at %td/%td\n",
+ OPCODE(h), file->cursor - file->map,
+ file->end - file->map);
return AUB_ITEM_DECODE_FAILED;
}
case MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_BMP):
break;
case MAKE_HEADER(TYPE_AUB, OPCODE_NEW_AUB, SUBOPCODE_VERSION):
- printf("version block: dw1 %08x\n", p[1]);
+ fprintf(outfile, "version block: dw1 %08x\n", p[1]);
device = (p[1] >> 8) & 0xff;
- printf(" device %s\n", device_map[device].name);
+ fprintf(outfile, " device %s\n", device_map[device].name);
break;
case MAKE_HEADER(TYPE_AUB, OPCODE_NEW_AUB, SUBOPCODE_REG_WRITE):
- printf("register write block: (dwords %d)\n", h & 0xffff);
- printf(" reg 0x%x, data 0x%x\n", p[1], p[5]);
+ fprintf(outfile, "register write block: (dwords %d)\n", h & 0xffff);
+ fprintf(outfile, " reg 0x%x, data 0x%x\n", p[1], p[5]);
break;
case MAKE_HEADER(TYPE_AUB, OPCODE_NEW_AUB, SUBOPCODE_MEM_WRITE):
- printf("memory write block (dwords %d):\n", h & 0xffff);
- printf(" address 0x%"PRIx64"\n", *(uint64_t *) &p[1]);
+ fprintf(outfile, "memory write block (dwords %d):\n", h & 0xffff);
+ fprintf(outfile, " address 0x%"PRIx64"\n", *(uint64_t *) &p[1]);
data_type = (p[3] >> 20) & 0xff;
if (data_type != 0)
- printf(" data type 0x%x\n", data_type);
- printf(" address space 0x%x\n", (p[3] >> 28) & 0xf);
+ fprintf(outfile, " data type 0x%x\n", data_type);
+ fprintf(outfile, " address space 0x%x\n", (p[3] >> 28) & 0xf);
break;
case MAKE_HEADER(TYPE_AUB, OPCODE_NEW_AUB, SUBOPCODE_MEM_POLL):
- printf("memory poll block (dwords %d):\n", h & 0xffff);
+ fprintf(outfile, "memory poll block (dwords %d):\n", h & 0xffff);
break;
default:
- printf("unknown block type=0x%x, opcode=0x%x, "
+ fprintf(outfile, "unknown block type=0x%x, opcode=0x%x, "
"subopcode=0x%x (%08x)\n", TYPE(h), OPCODE(h), SUBOPCODE(h), h);
break;
}
{ NULL, 0, NULL, 0 }
};
+ outfile = stdout;
+
i = 0;
while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {
switch (c) {