- int i, pci_id = 0;
- bool found_arg_gen = false, pager = true;
- int gen_major, gen_minor;
- const char *value;
- char gen_file[256], gen_val[24];
-
- if (argc == 1) {
- print_help(argv[0], stderr);
- exit(EXIT_FAILURE);
- }
-
- for (i = 1; i < argc; ++i) {
- if (strcmp(argv[i], "--no-pager") == 0) {
- pager = false;
- } else if (strcmp(argv[i], "--no-offsets") == 0) {
- option_print_offsets = false;
- } else if (is_prefix(argv[i], "--gen", &value)) {
- if (value == NULL) {
- fprintf(stderr, "option '--gen' requires an argument\n");
+ int c, i;
+ bool help = false, pager = true;
+ const struct {
+ const char *name;
+ int pci_id;
+ } gens[] = {
+ { "ilk", 0x0046 }, /* Intel(R) Ironlake Mobile */
+ { "snb", 0x0126 }, /* Intel(R) Sandybridge Mobile GT2 */
+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */
+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */
+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */
+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */
+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */
+ { "bxt", 0x0A84 }, /* Intel(R) HD Graphics (Broxton) */
+ { "cnl", 0x5A52 }, /* Intel(R) HD Graphics (Cannonlake) */
+ };
+ const struct option aubinator_opts[] = {
+ { "help", no_argument, (int *) &help, true },
+ { "no-pager", no_argument, (int *) &pager, false },
+ { "no-offsets", no_argument, (int *) &option_print_offsets, false },
+ { "gen", required_argument, NULL, 'g' },
+ { "headers", no_argument, (int *) &option_full_decode, false },
+ { "color", required_argument, NULL, 'c' },
+ { "xml", required_argument, NULL, 'x' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ outfile = stdout;
+
+ i = 0;
+ while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {
+ switch (c) {
+ case 'g':
+ for (i = 0; i < ARRAY_SIZE(gens); i++) {
+ if (!strcmp(optarg, gens[i].name)) {
+ pci_id = gens[i].pci_id;
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(gens)) {
+ fprintf(stderr, "can't parse gen: '%s', expected ivb, byt, hsw, "
+ "bdw, chv, skl, kbl or bxt\n", optarg);