summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2016-10-04 16:17:56 +0100
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>2016-10-05 16:23:28 +0100
commitf8b861a8673ca49eb6e4fbcdc1cf7f6be884afe1 (patch)
tree419b6f43ee65859c1b97b72725c5f688d1bfdbb9
parent2dc06e23245429bceaac16e8a31e29ddc822ebc9 (diff)
intel: aubinator: pack supported generations into an array
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/intel/tools/aubinator.c88
1 files changed, 35 insertions, 53 deletions
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 1798191f0b..6fc0208818 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -36,6 +36,8 @@
#include <sys/wait.h>
#include <sys/mman.h>
+#include "util/macros.h"
+
#include "decoder.h"
#include "intel_aub.h"
#include "gen_disasm.h"
@@ -1059,11 +1061,25 @@ int main(int argc, char *argv[])
{
struct gen_spec *spec;
struct aub_file *file;
- int i, pci_id = 0;
+ int i;
bool found_arg_gen = false, pager = true;
- int gen_major, gen_minor;
- const char *value;
+ const char *value, *input_file;
char gen_file[256], gen_val[24];
+ const struct {
+ const char *name;
+ int pci_id;
+ int major;
+ int minor;
+ } gens[] = {
+ { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */
+ { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */
+ { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */
+ { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
+ { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */
+ { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
+ { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */
+ { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */
+ }, *gen = NULL;
if (argc == 1) {
print_help(argv[0], stderr);
@@ -1081,8 +1097,6 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
found_arg_gen = true;
- gen_major = 0;
- gen_minor = 0;
snprintf(gen_val, sizeof(gen_val), "%s", value);
} else if (strcmp(argv[i], "--headers") == 0) {
option_full_decode = false;
@@ -1105,6 +1119,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "unknown option %s\n", argv[i]);
exit(EXIT_FAILURE);
}
+ input_file = argv[i];
break;
}
}
@@ -1114,47 +1129,14 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (strstr(gen_val, "ivb") != NULL) {
- /* Intel(R) Ivybridge Mobile GT2 */
- pci_id = 0x0166;
- gen_major = 7;
- gen_minor = 0;
- } else if (strstr(gen_val, "hsw") != NULL) {
- /* Intel(R) Haswell Mobile GT2 */
- pci_id = 0x0416;
- gen_major = 7;
- gen_minor = 5;
- } else if (strstr(gen_val, "byt") != NULL) {
- /* Intel(R) Bay Trail */
- pci_id = 0x0155;
- gen_major = 7;
- gen_minor = 5;
- } else if (strstr(gen_val, "bdw") != NULL) {
- /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
- pci_id = 0x1616;
- gen_major = 8;
- gen_minor = 0;
- } else if (strstr(gen_val, "chv") != NULL) {
- /* Intel(R) HD Graphics (Cherryview) */
- pci_id = 0x22B3;
- gen_major = 8;
- gen_minor = 0;
- } else if (strstr(gen_val, "skl") != NULL) {
- /* Intel(R) HD Graphics 530 (Skylake GT2) */
- pci_id = 0x1912;
- gen_major = 9;
- gen_minor = 0;
- } else if (strstr(gen_val, "kbl") != NULL) {
- /* Intel(R) Kabylake GT2 */
- pci_id = 0x591D;
- gen_major = 9;
- gen_minor = 0;
- } else if (strstr(gen_val, "bxt") != NULL) {
- /* Intel(R) HD Graphics (Broxton) */
- pci_id = 0x0A84;
- gen_major = 9;
- gen_minor = 0;
- } else {
+ for (i = 0; i < ARRAY_SIZE(gens); i++) {
+ if (!strcmp(gen_val, gens[i].name)) {
+ gen = &gens[i];
+ break;
+ }
+ }
+
+ if (gen == NULL) {
fprintf(stderr, "can't parse gen: %s, expected ivb, byt, hsw, "
"bdw, chv, skl, kbl or bxt\n", gen_val);
exit(EXIT_FAILURE);
@@ -1167,21 +1149,21 @@ int main(int argc, char *argv[])
if (isatty(1) && pager)
setup_pager();
- if (gen_minor > 0) {
+ if (gen->minor > 0) {
snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",
- gen_major, gen_minor);
+ gen->major, gen->minor);
} else {
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen_major);
+ snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);
}
spec = gen_spec_load(gen_file);
- disasm = gen_disasm_create(pci_id);
+ disasm = gen_disasm_create(gen->pci_id);
- if (argv[i] == NULL) {
- print_help(argv[0], stderr);
+ if (input_file == NULL) {
+ print_help(input_file, stderr);
exit(EXIT_FAILURE);
} else {
- file = aub_file_open(argv[i]);
+ file = aub_file_open(input_file);
}
while (aub_file_more_stuff(file))