diff options
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/Makefile.tools.am | 1 | ||||
-rw-r--r-- | src/intel/tools/aubinator.c | 719 | ||||
-rw-r--r-- | src/intel/tools/meson.build | 3 |
3 files changed, 33 insertions, 690 deletions
diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am index 9332ae3e7d3..944ee19805c 100644 --- a/src/intel/Makefile.tools.am +++ b/src/intel/Makefile.tools.am @@ -26,6 +26,7 @@ noinst_PROGRAMS += \ tools_aubinator_SOURCES = \ tools/aubinator.c \ tools/disasm.c \ + tools/gen_batch_decoder.c \ tools/gen_disasm.h \ tools/intel_aub.h diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index 4ae70ad4fbc..ed7446cf1ee 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -64,8 +64,8 @@ static enum { COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER } option_color; uint16_t pci_id = 0; char *input_file = NULL, *xml_path = NULL; -struct gen_spec *spec; -struct gen_disasm *disasm; +struct gen_device_info devinfo; +struct gen_batch_decode_ctx batch_ctx; uint64_t gtt_size, gtt_end; void *gtt; @@ -95,683 +95,6 @@ valid_offset(uint32_t offset) return offset < gtt_end; } -static void -decode_group(struct gen_group *strct, const uint32_t *p, int starting_dword) -{ - uint64_t offset = option_print_offsets ? (void *) p - gtt : 0; - - gen_print_group(outfile, strct, offset, p, 0, option_color == COLOR_ALWAYS); -} - -static void -dump_binding_table(struct gen_spec *spec, uint32_t offset) -{ - uint32_t *pointers, i; - uint64_t start; - struct gen_group *surface_state; - - surface_state = gen_spec_find_struct(spec, "RENDER_SURFACE_STATE"); - if (surface_state == NULL) { - fprintf(outfile, "did not find RENDER_SURFACE_STATE info\n"); - return; - } - - start = surface_state_base + offset; - pointers = gtt + start; - for (i = 0; i < 16; i++) { - if (pointers[i] == 0) - continue; - start = pointers[i] + surface_state_base; - if (!valid_offset(start)) { - fprintf(outfile, "pointer %u: %08x <not valid>\n", - i, pointers[i]); - continue; - } else { - fprintf(outfile, "pointer %u: %08x\n", i, pointers[i]); - } - - decode_group(surface_state, gtt + start, 0); - } -} - -static void -handle_3dstate_index_buffer(struct gen_spec *spec, uint32_t *p) -{ - void *start; - uint32_t length, i, type, size; - - start = gtt + p[2]; - type = (p[1] >> 8) & 3; - size = 1 << type; - length = p[4] / size; - if (length > 10) - length = 10; - - fprintf(outfile, "\t"); - - for (i = 0; i < length; i++) { - switch (type) { - case 0: - fprintf(outfile, "%3d ", ((uint8_t *)start)[i]); - break; - case 1: - fprintf(outfile, "%3d ", ((uint16_t *)start)[i]); - break; - case 2: - fprintf(outfile, "%3d ", ((uint32_t *)start)[i]); - break; - } - } - if (length < p[4] / size) - fprintf(outfile, "...\n"); - else - fprintf(outfile, "\n"); -} - -static inline uint64_t -get_address(struct gen_spec *spec, uint32_t *p) -{ - /* Addresses are always guaranteed to be page-aligned and sometimes - * hardware packets have extra stuff stuffed in the bottom 12 bits. - */ - uint64_t addr = p[0] & ~0xfffu; - - if (gen_spec_get_gen(spec) >= gen_make_gen(8,0)) { - /* On Broadwell and above, we have 48-bit addresses which consume two - * dwords. Some packets require that these get stored in a "canonical - * form" which means that bit 47 is sign-extended through the upper - * bits. In order to correctly handle those aub dumps, we need to mask - * off the top 16 bits. - */ - addr |= ((uint64_t)p[1] & 0xffff) << 32; - } - - return addr; -} - -static inline uint64_t -get_offset(uint32_t *p, uint32_t start, uint32_t end) -{ - assert(start <= end); - assert(end < 64); - - uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start; - - uint64_t offset = p[0]; - if (end >= 32) - offset |= (uint64_t) p[1] << 32; - - return offset & mask; -} - -static void -handle_state_base_address(struct gen_spec *spec, uint32_t *p) -{ - if (gen_spec_get_gen(spec) >= gen_make_gen(8,0)) { - if (p[1] & 1) - general_state_base = get_address(spec, &p[1]); - if (p[4] & 1) - surface_state_base = get_address(spec, &p[4]); - if (p[6] & 1) - dynamic_state_base = get_address(spec, &p[6]); - if (p[10] & 1) - instruction_base = get_address(spec, &p[10]); - if (p[15] & 1) - instruction_bound = p[15] & 0xfff; - } else { - if (p[2] & 1) - surface_state_base = get_address(spec, &p[2]); - if (p[3] & 1) - dynamic_state_base = get_address(spec, &p[3]); - if (p[5] & 1) - instruction_base = get_address(spec, &p[5]); - if (p[9] & 1) - instruction_bound = get_address(spec, &p[9]); - } -} - -static void -dump_samplers(struct gen_spec *spec, uint32_t offset) -{ - uint32_t i; - uint64_t start; - struct gen_group *sampler_state; - - sampler_state = gen_spec_find_struct(spec, "SAMPLER_STATE"); - - start = dynamic_state_base + offset; - for (i = 0; i < 4; i++) { - fprintf(outfile, "sampler state %d\n", i); - decode_group(sampler_state, gtt + start + i * 16, 0); - } -} - -static void -handle_media_interface_descriptor_load(struct gen_spec *spec, uint32_t *p) -{ - int i, length = p[2] / 32; - struct gen_group *descriptor_structure; - uint32_t *descriptors; - uint64_t start; - struct brw_instruction *insns; - - descriptor_structure = - gen_spec_find_struct(spec, "INTERFACE_DESCRIPTOR_DATA"); - if (descriptor_structure == NULL) { - 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) { - fprintf(outfile, "descriptor %u: %08x\n", i, *descriptors); - decode_group(descriptor_structure, descriptors, 0); - - start = instruction_base + descriptors[0]; - if (!valid_offset(start)) { - fprintf(outfile, "kernel: %08"PRIx64" <not valid>\n", start); - continue; - } else { - fprintf(outfile, "kernel: %08"PRIx64"\n", start); - } - - insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, stdout); - - dump_samplers(spec, descriptors[3] & ~0x1f); - dump_binding_table(spec, descriptors[4] & ~0x1f); - } -} - -/* Heuristic to determine whether a uint32_t is probably actually a float - * (http://stackoverflow.com/a/2953466) - */ - -static bool -probably_float(uint32_t bits) -{ - int exp = ((bits & 0x7f800000U) >> 23) - 127; - uint32_t mant = bits & 0x007fffff; - - /* +- 0.0 */ - if (exp == -127 && mant == 0) - return true; - - /* +- 1 billionth to 1 billion */ - if (-30 <= exp && exp <= 30) - return true; - - /* some value with only a few binary digits */ - if ((mant & 0x0000ffff) == 0) - return true; - - return false; -} - -static void -handle_3dstate_vertex_buffers(struct gen_spec *spec, uint32_t *p) -{ - uint32_t *end, *s, *dw, *dwend; - uint64_t offset; - int n, i, count, stride; - - end = (p[0] & 0xff) + p + 2; - for (s = &p[1], n = 0; s < end; s += 4, n++) { - if (gen_spec_get_gen(spec) >= gen_make_gen(8, 0)) { - offset = *(uint64_t *) &s[1]; - dwend = gtt + offset + s[3]; - } else { - offset = s[1]; - dwend = gtt + s[2] + 1; - } - - stride = field(s[0], 0, 11); - count = 0; - 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) - fprintf(outfile, " "); - - if (probably_float(*dw)) - fprintf(outfile, " %8.2f", *(float *) dw); - else - fprintf(outfile, " 0x%08x", *dw); - - i++; - count += 4; - - if (count == stride) { - fprintf(outfile, "\n"); - count = 0; - } else if (count % (8 * 4) == 0) { - fprintf(outfile, "\n"); - } else { - fprintf(outfile, " "); - } - } - if (count > 0 && count % (8 * 4) != 0) - fprintf(outfile, "\n"); - } -} - -static void -handle_3dstate_vs(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct brw_instruction *insns; - int vs_enable; - - if (gen_spec_get_gen(spec) >= gen_make_gen(8, 0)) { - start = get_offset(&p[1], 6, 63); - vs_enable = p[7] & 1; - } else { - start = get_offset(&p[1], 6, 31); - vs_enable = p[5] & 1; - } - - if (vs_enable) { - 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); - } -} - -static void -handle_3dstate_hs(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct brw_instruction *insns; - int hs_enable; - - if (gen_spec_get_gen(spec) >= gen_make_gen(8, 0)) { - start = get_offset(&p[3], 6, 63); - } else { - start = get_offset(&p[3], 6, 31); - } - - hs_enable = p[2] & 0x80000000; - - if (hs_enable) { - 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); - } -} - -static void -handle_3dstate_constant(struct gen_spec *spec, uint32_t *p) -{ - int i, j, length; - uint32_t *dw; - float *f; - - for (i = 0; i < 4; i++) { - length = (p[1 + i / 2] >> (i & 1) * 16) & 0xffff; - f = (float *) (gtt + p[3 + i * 2] + dynamic_state_base); - dw = (uint32_t *) f; - for (j = 0; j < length * 8; j++) { - if (probably_float(dw[j])) - fprintf(outfile, " %04.3f", f[j]); - else - fprintf(outfile, " 0x%08x", dw[j]); - - if ((j & 7) == 7) - fprintf(outfile, "\n"); - } - } -} - -static void -handle_3dstate_ps(struct gen_spec *spec, uint32_t *p) -{ - uint32_t mask = ~((1 << 6) - 1); - uint64_t start; - struct brw_instruction *insns; - static const char unused[] = "unused"; - static const char *pixel_type[3] = {"8 pixel", "16 pixel", "32 pixel"}; - const char *k0, *k1, *k2; - uint32_t k_mask, k1_offset, k2_offset; - - if (gen_spec_get_gen(spec) >= gen_make_gen(8, 0)) { - k_mask = p[6] & 7; - k1_offset = 8; - k2_offset = 10; - } else { - k_mask = p[4] & 7; - k1_offset = 6; - k2_offset = 7; - } - -#define DISPATCH_8 1 -#define DISPATCH_16 2 -#define DISPATCH_32 4 - - switch (k_mask) { - case DISPATCH_8: - k0 = pixel_type[0]; - k1 = unused; - k2 = unused; - break; - case DISPATCH_16: - k0 = pixel_type[1]; - k1 = unused; - k2 = unused; - break; - case DISPATCH_8 | DISPATCH_16: - k0 = pixel_type[0]; - k1 = unused; - k2 = pixel_type[1]; - break; - case DISPATCH_32: - k0 = pixel_type[2]; - k1 = unused; - k2 = unused; - break; - case DISPATCH_16 | DISPATCH_32: - k0 = unused; - k1 = pixel_type[2]; - k2 = pixel_type[1]; - break; - case DISPATCH_8 | DISPATCH_16 | DISPATCH_32: - k0 = pixel_type[0]; - k1 = pixel_type[2]; - k2 = pixel_type[1]; - break; - default: - k0 = unused; - k1 = unused; - k2 = unused; - break; - } - - start = instruction_base + (p[1] & mask); - 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); - 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); - fprintf(outfile, " Kernel[2] %s\n", k2); - if (k2 != unused) { - insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, stdout); - } -} - -static void -handle_3dstate_binding_table_pointers(struct gen_spec *spec, uint32_t *p) -{ - dump_binding_table(spec, p[1]); -} - -static void -handle_3dstate_sampler_state_pointers(struct gen_spec *spec, uint32_t *p) -{ - dump_samplers(spec, p[1]); -} - -static void -handle_3dstate_sampler_state_pointers_gen6(struct gen_spec *spec, uint32_t *p) -{ - dump_samplers(spec, p[1]); - dump_samplers(spec, p[2]); - dump_samplers(spec, p[3]); -} - -static void -handle_3dstate_viewport_state_pointers_cc(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct gen_group *cc_viewport; - - cc_viewport = gen_spec_find_struct(spec, "CC_VIEWPORT"); - - start = dynamic_state_base + (p[1] & ~0x1fu); - for (uint32_t i = 0; i < 4; i++) { - fprintf(outfile, "viewport %d\n", i); - decode_group(cc_viewport, gtt + start + i * 8, 0); - } -} - -static void -handle_3dstate_viewport_state_pointers_sf_clip(struct gen_spec *spec, - uint32_t *p) -{ - uint64_t start; - struct gen_group *sf_clip_viewport; - - sf_clip_viewport = gen_spec_find_struct(spec, "SF_CLIP_VIEWPORT"); - - start = dynamic_state_base + (p[1] & ~0x3fu); - for (uint32_t i = 0; i < 4; i++) { - fprintf(outfile, "viewport %d\n", i); - decode_group(sf_clip_viewport, gtt + start + i * 64, 0); - } -} - -static void -handle_3dstate_blend_state_pointers(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct gen_group *blend_state; - - blend_state = gen_spec_find_struct(spec, "BLEND_STATE"); - - start = dynamic_state_base + (p[1] & ~0x3fu); - decode_group(blend_state, gtt + start, 0); -} - -static void -handle_3dstate_cc_state_pointers(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct gen_group *cc_state; - - cc_state = gen_spec_find_struct(spec, "COLOR_CALC_STATE"); - - start = dynamic_state_base + (p[1] & ~0x3fu); - decode_group(cc_state, gtt + start, 0); -} - -static void -handle_3dstate_scissor_state_pointers(struct gen_spec *spec, uint32_t *p) -{ - uint64_t start; - struct gen_group *scissor_rect; - - scissor_rect = gen_spec_find_struct(spec, "SCISSOR_RECT"); - - start = dynamic_state_base + (p[1] & ~0x1fu); - decode_group(scissor_rect, gtt + start, 0); -} - -static void -handle_load_register_imm(struct gen_spec *spec, uint32_t *p) -{ - struct gen_group *reg = gen_spec_find_register(spec, p[1]); - - if (reg != NULL) { - fprintf(outfile, "register %s (0x%x): 0x%x\n", - reg->name, reg->register_offset, p[2]); - decode_group(reg, &p[2], 0); - } -} - -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) - -#define STATE_BASE_ADDRESS 0x61010000 - -#define MEDIA_INTERFACE_DESCRIPTOR_LOAD 0x70020000 - -#define _3DSTATE_INDEX_BUFFER 0x780a0000 -#define _3DSTATE_VERTEX_BUFFERS 0x78080000 - -#define _3DSTATE_VS 0x78100000 -#define _3DSTATE_GS 0x78110000 -#define _3DSTATE_HS 0x781b0000 -#define _3DSTATE_DS 0x781d0000 - -#define _3DSTATE_CONSTANT_VS 0x78150000 -#define _3DSTATE_CONSTANT_GS 0x78160000 -#define _3DSTATE_CONSTANT_PS 0x78170000 -#define _3DSTATE_CONSTANT_HS 0x78190000 -#define _3DSTATE_CONSTANT_DS 0x781A0000 - -#define _3DSTATE_PS 0x78200000 - -#define _3DSTATE_BINDING_TABLE_POINTERS_VS 0x78260000 -#define _3DSTATE_BINDING_TABLE_POINTERS_HS 0x78270000 -#define _3DSTATE_BINDING_TABLE_POINTERS_DS 0x78280000 -#define _3DSTATE_BINDING_TABLE_POINTERS_GS 0x78290000 -#define _3DSTATE_BINDING_TABLE_POINTERS_PS 0x782a0000 - -#define _3DSTATE_SAMPLER_STATE_POINTERS_VS 0x782b0000 -#define _3DSTATE_SAMPLER_STATE_POINTERS_GS 0x782e0000 -#define _3DSTATE_SAMPLER_STATE_POINTERS_PS 0x782f0000 - -#define _3DSTATE_SAMPLER_STATE_POINTERS 0x78020000 - -#define _3DSTATE_VIEWPORT_STATE_POINTERS_CC 0x78230000 -#define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP 0x78210000 -#define _3DSTATE_BLEND_STATE_POINTERS 0x78240000 -#define _3DSTATE_CC_STATE_POINTERS 0x780e0000 -#define _3DSTATE_SCISSOR_STATE_POINTERS 0x780f0000 - -#define _MI_LOAD_REGISTER_IMM 0x11000000 - -struct custom_handler { - uint32_t opcode; - void (*handle)(struct gen_spec *spec, uint32_t *p); -} custom_handlers[] = { - { STATE_BASE_ADDRESS, handle_state_base_address }, - { MEDIA_INTERFACE_DESCRIPTOR_LOAD, handle_media_interface_descriptor_load }, - { _3DSTATE_VERTEX_BUFFERS, handle_3dstate_vertex_buffers }, - { _3DSTATE_INDEX_BUFFER, handle_3dstate_index_buffer }, - { _3DSTATE_VS, handle_3dstate_vs }, - { _3DSTATE_GS, handle_3dstate_vs }, - { _3DSTATE_DS, handle_3dstate_vs }, - { _3DSTATE_HS, handle_3dstate_hs }, - { _3DSTATE_CONSTANT_VS, handle_3dstate_constant }, - { _3DSTATE_CONSTANT_GS, handle_3dstate_constant }, - { _3DSTATE_CONSTANT_PS, handle_3dstate_constant }, - { _3DSTATE_CONSTANT_HS, handle_3dstate_constant }, - { _3DSTATE_CONSTANT_DS, handle_3dstate_constant }, - { _3DSTATE_PS, handle_3dstate_ps }, - - { _3DSTATE_BINDING_TABLE_POINTERS_VS, handle_3dstate_binding_table_pointers }, - { _3DSTATE_BINDING_TABLE_POINTERS_HS, handle_3dstate_binding_table_pointers }, - { _3DSTATE_BINDING_TABLE_POINTERS_DS, handle_3dstate_binding_table_pointers }, - { _3DSTATE_BINDING_TABLE_POINTERS_GS, handle_3dstate_binding_table_pointers }, - { _3DSTATE_BINDING_TABLE_POINTERS_PS, handle_3dstate_binding_table_pointers }, - - { _3DSTATE_SAMPLER_STATE_POINTERS_VS, handle_3dstate_sampler_state_pointers }, - { _3DSTATE_SAMPLER_STATE_POINTERS_GS, handle_3dstate_sampler_state_pointers }, - { _3DSTATE_SAMPLER_STATE_POINTERS_PS, handle_3dstate_sampler_state_pointers }, - { _3DSTATE_SAMPLER_STATE_POINTERS, handle_3dstate_sampler_state_pointers_gen6 }, - - { _3DSTATE_VIEWPORT_STATE_POINTERS_CC, handle_3dstate_viewport_state_pointers_cc }, - { _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, handle_3dstate_viewport_state_pointers_sf_clip }, - { _3DSTATE_BLEND_STATE_POINTERS, handle_3dstate_blend_state_pointers }, - { _3DSTATE_CC_STATE_POINTERS, handle_3dstate_cc_state_pointers }, - { _3DSTATE_SCISSOR_STATE_POINTERS, handle_3dstate_scissor_state_pointers }, - { _MI_LOAD_REGISTER_IMM, handle_load_register_imm } -}; - -static void -parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine) -{ - uint32_t *p, *end = cmds + size / 4; - int length, i; - struct gen_group *inst; - - for (p = cmds; p < end; p += length) { - inst = gen_spec_find_instruction(spec, p); - length = gen_group_get_length(inst, p); - assert(inst == NULL || length > 0); - length = MAX2(1, length); - if (inst == NULL) { - fprintf(outfile, "unknown instruction %08x\n", p[0]); - continue; - } - - const char *color, *reset_color = NORMAL; - uint64_t offset; - - if (option_full_decode) { - if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_START || - (p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_END) - color = GREEN_HEADER; - else - color = BLUE_HEADER; - } else - color = NORMAL; - - if (option_color == COLOR_NEVER) { - color = ""; - reset_color = ""; - } - - if (option_print_offsets) - offset = (void *) p - gtt; - else - offset = 0; - - 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(inst, p, 0); - - for (i = 0; i < ARRAY_LENGTH(custom_handlers); i++) { - if (gen_group_get_opcode(inst) == custom_handlers[i].opcode) { - custom_handlers[i].handle(spec, p); - break; - } - } - } - - if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_START) { - uint64_t start = get_address(spec, &p[1]); - - if (p[0] & (1 << 22)) { - /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" set acts - * like a subroutine call. Commands that come afterwards get - * processed once the 2nd level batch buffer returns with - * MI_BATCH_BUFFER_END. - */ - parse_commands(spec, gtt + start, gtt_end - start, engine); - } else { - /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts - * like a goto. Nothing after it will ever get processed. In - * order to prevent the recursion from growing, we just reset the - * loop and continue; - */ - p = gtt + start; - /* We don't know where secondaries end so use the GTT end */ - end = gtt + gtt_end; - length = 0; - continue; - } - } else if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_END) { - break; - } - } -} - #define GEN_ENGINE_RENDER 1 #define GEN_ENGINE_BLITTER 2 @@ -787,7 +110,7 @@ handle_trace_block(uint32_t *p) uint32_t *data = p + header_length + 2; int engine = GEN_ENGINE_RENDER; - if (gen_spec_get_gen(spec) >= gen_make_gen(8,0)) + if (devinfo.gen >= 8) offset += (uint64_t) p[5] << 32; switch (operation) { @@ -815,12 +138,28 @@ handle_trace_block(uint32_t *p) break; } - parse_commands(spec, data, size, engine); + (void)engine; /* TODO */ + gen_print_batch(&batch_ctx, data, size, 0); + gtt_end = 0; break; } } +static struct gen_batch_decode_bo +get_gen_batch_bo(void *user_data, uint64_t address) +{ + if (address > gtt_end) + return (struct gen_batch_decode_bo) { .map = NULL }; + + /* We really only have one giant address range */ + return (struct gen_batch_decode_bo) { + .addr = 0, + .map = gtt, + .size = gtt_size + }; +} + static void handle_trace_header(uint32_t *p) { @@ -836,20 +175,22 @@ handle_trace_header(uint32_t *p) if (pci_id == 0) pci_id = aub_pci_id; - struct gen_device_info devinfo; if (!gen_get_device_info(pci_id, &devinfo)) { fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id); exit(EXIT_FAILURE); } - if (xml_path == NULL) - spec = gen_spec_load(&devinfo); - else - spec = gen_spec_load_from_path(&devinfo, xml_path); - disasm = gen_disasm_create(&devinfo); + enum gen_batch_decode_flags batch_flags = 0; + if (option_color == COLOR_ALWAYS) + batch_flags |= GEN_BATCH_DECODE_IN_COLOR; + if (option_full_decode) + batch_flags |= GEN_BATCH_DECODE_FULL; + if (option_print_offsets) + batch_flags |= GEN_BATCH_DECODE_OFFSETS; + batch_flags |= GEN_BATCH_DECODE_FLOATS; - if (spec == NULL || disasm == NULL) - exit(EXIT_FAILURE); + gen_batch_decode_ctx_init(&batch_ctx, &devinfo, outfile, batch_flags, + xml_path, get_gen_batch_bo, NULL); fprintf(outfile, "%sAubinator: Intel AUB file decoder.%-80s%s\n", GREEN_HEADER, "", NORMAL); diff --git a/src/intel/tools/meson.build b/src/intel/tools/meson.build index bff7e536630..7890eeca1dc 100644 --- a/src/intel/tools/meson.build +++ b/src/intel/tools/meson.build @@ -20,7 +20,8 @@ aubinator = executable( 'aubinator', - files('aubinator.c', 'disasm.c', 'gen_disasm.h', 'intel_aub.h'), + files('aubinator.c', 'disasm.c', 'gen_batch_decoder.c', + 'gen_disasm.h', 'intel_aub.h'), dependencies : [dep_expat, dep_zlib, dep_dl, dep_thread, dep_m], include_directories : [inc_common, inc_intel], link_with : [libintel_common, libintel_compiler, libmesa_util], |