+void ShowUsage(const char *progname)
+{
+ fprintf(stderr, "Usage: %s [-v|--verbose] [<pcidev>]\n", progname);
+ fprintf(stderr,
+ "\n"
+ "-v | --verbose : Enable dump of BARs\n"
+ "\n"
+ );
+}
+
+int ParseCommandline(int argc, char *argv[])
+{
+ for( int i = 1; i < argc; i ++ )
+ {
+ const char *arg = argv[i];
+ if( arg[0] != '-' ) {
+ // Show an individual device
+ gsDeviceName = arg;
+ }
+ else if( arg[1] != '-' ) {
+ // Short args
+ switch(arg[1])
+ {
+ case 'v':
+ gbEnableVerbose ++;
+ break;
+ default:
+ ShowUsage(argv[0]);
+ return 1;
+ }
+ }
+ else {
+ // Long args
+ if(strcmp(arg, "--verbose") == 0) {
+ gbEnableVerbose ++;
+ }
+ else {
+ ShowUsage(argv[0]);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+const char *get_device_class(uint32_t revclass)
+{
+ uint8_t class = revclass >> 24;
+ uint8_t subclass = revclass >> 16;
+ switch(class)
+ {
+ case 0x00:
+ switch( subclass )
+ {
+ case 0x01: return "VGA-Compatible";
+ }
+ return "Pre Classcodes";
+ case 0x01:
+ switch( subclass )
+ {
+ case 0x00: return "SCSI Bus Controller";
+ case 0x01: return "IDE Controller";
+ case 0x02: return "Floppy Disk Controller";
+ }
+ return "Mass Storage Controller";
+ case 0x02: return "Network Controller";
+ case 0x03: return "Display Controller";
+ case 0x04: return "Multimedia Controller";
+ case 0x05: return "Memory Controller";
+ case 0x06: return "Bridge Device";
+ case 0x07: return "Simple Communications Controller";
+ case 0x08: return "Base System Peripherals";
+ case 0x09: return "Input Device";
+ case 0x0A: return "Docing Station";
+ case 0x0B: return "Processor";
+ case 0x0C: return "Serial Bus Controller";
+ }
+ return "";
+}
+