+static void
+handle_trace_header(uint32_t *p)
+{
+ /* The intel_aubdump tool from IGT is kind enough to put a PCI-ID= tag in
+ * the AUB header comment. If the user hasn't specified a hardware
+ * generation, try to use the one from the AUB file.
+ */
+ uint32_t *end = p + (p[0] & 0xffff) + 2;
+ int aub_pci_id = 0;
+ if (end > &p[12] && p[12] > 0)
+ sscanf((char *)&p[13], "PCI-ID=%i", &aub_pci_id);
+
+ 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(pci_id);
+
+ if (spec == NULL || disasm == NULL)
+ exit(EXIT_FAILURE);
+
+ fprintf(outfile, "%sAubinator: Intel AUB file decoder.%-80s%s\n",
+ GREEN_HEADER, "", NORMAL);
+
+ if (input_file)
+ fprintf(outfile, "File name: %s\n", input_file);
+
+ if (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;
+ fprintf(outfile, "Application name: %s\n", app_name);
+
+ fprintf(outfile, "Decoding as: %s\n", gen_get_device_name(pci_id));
+
+ /* Throw in a new line before the first batch */
+ fprintf(outfile, "\n");
+}
+