1 | # Clean PCI header script
|
---|
2 | #
|
---|
3 | # Copyright 2006, Haiku.
|
---|
4 | # Distributed under the terms of the MIT License.
|
---|
5 | #
|
---|
6 | # Authors:
|
---|
7 | # John Drinkwater, john@nextraweb.com
|
---|
8 | #
|
---|
9 | # Use with http://pciids.sourceforge.net/pci.ids
|
---|
10 | # run as: awk -f pci-clean pci.ids > pcihdr.h
|
---|
11 |
|
---|
12 | BEGIN {
|
---|
13 | FS = " ";
|
---|
14 | print "#if 0"
|
---|
15 | print "#\tPCIHDR.H: PCI Vendors, Devices, and Class Type information\n#"
|
---|
16 | print "#\tGenerated by pci-clean, sourced from the web at the following URL:\n#\thttp://pciids.sourceforge.net/pci.ids\n#"
|
---|
17 | print "#\tHeader created on " strftime( "%A, %d %b %Y %H:%M:%S %Z", systime() )
|
---|
18 | print "#endif"
|
---|
19 | }
|
---|
20 |
|
---|
21 | # matches vendor; starts with an id as first thing on the line
|
---|
22 | /^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
---|
23 | if ( length(vendor) > 0 ) vendor = vendor ",\n"
|
---|
24 | vendor = vendor "\t{ 0x" $1 ", \"" substr($0, 7) "\" }"
|
---|
25 | # store vendor ID for possible devices afterwards
|
---|
26 | currentVendor = $1
|
---|
27 | };
|
---|
28 |
|
---|
29 | # matches device;
|
---|
30 | /^\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
---|
31 |
|
---|
32 | if ( length(devices) > 0 ) devices = devices ",\n"
|
---|
33 | devices = devices "\t{ 0x" currentVendor ", 0x" $1 ", \"" substr($0, 8) "\" }"
|
---|
34 | };
|
---|
35 |
|
---|
36 | # matches subvendor device
|
---|
37 | /^\t\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
---|
38 |
|
---|
39 | # is something more important meant to happen with subvendor devices?
|
---|
40 | if ( length(devices) > 0 ) devices = devices ",\n"
|
---|
41 | devices = devices "\t{ 0x" $1 ", 0x" $2 ", \"" substr($0, 14) "\" }"
|
---|
42 | };
|
---|
43 |
|
---|
44 |
|
---|
45 | /^C [[:xdigit:]][[:xdigit:]] / {
|
---|
46 | class = $2
|
---|
47 | classdes = substr($0, 7)
|
---|
48 | };
|
---|
49 |
|
---|
50 | /^\t[[:xdigit:]][[:xdigit:]] / {
|
---|
51 | if ( length(classes) > 0 ) classes = classes ",\n"
|
---|
52 | if ( currentclass != class) { classes = classes "\n"; currentclass = class;}
|
---|
53 | subclassdes = substr($0, 6)
|
---|
54 | classes = classes "\t{ 0x" class ", 0x" $1 ", 0x00, \"" classdes "\", \"" subclassdes "\", \"\" }";
|
---|
55 | subclass = $1
|
---|
56 | }
|
---|
57 |
|
---|
58 | /^\t\t[[:xdigit:]][[:xdigit:]] / {
|
---|
59 | if ( $1 != "00" ) {
|
---|
60 | if ( length(classes) > 0 ) classes = classes ",\n"
|
---|
61 | classes = classes "\t{ 0x" class ", 0x" subclass ", 0x" $1 ", \"" classdes "\", \"" subclassdes "\", \"" substr($0, 7) "\" }";
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | END {
|
---|
66 |
|
---|
67 | if ( length( vendor ) > 0 ) {
|
---|
68 | print "\ntypedef struct _PCI_VENTABLE\n{\n\tunsigned short\tVenId ;\n\tchar *\tVenFull ;\n} PCI_VENTABLE, *PPCI_VENTABLE ;\n"
|
---|
69 | print "PCI_VENTABLE\tPciVenTable [] =\n{"
|
---|
70 | print vendor;
|
---|
71 | print "};\n\n// Use this value for loop control during searching:\n#define\tPCI_VENTABLE_LEN\t(sizeof(PciVenTable)/sizeof(PCI_VENTABLE))\n"
|
---|
72 | }
|
---|
73 |
|
---|
74 | if ( length( devices ) > 0 ) {
|
---|
75 |
|
---|
76 | print "typedef struct _PCI_DEVTABLE\n{\n\tunsigned short VenId ;\n\tunsigned short DevId ;\n\tchar *\tChipDesc ;\n} PCI_DEVTABLE, *PPCI_DEVTABLE ;\n"
|
---|
77 | print "PCI_DEVTABLE\tPciDevTable [] =\n{"
|
---|
78 | print devices;
|
---|
79 | #if ( length( subdevices ) > 0 ) {
|
---|
80 | # print subdevices;
|
---|
81 | #}
|
---|
82 | print "} ;\n\n// Use this value for loop control during searching:\n#define PCI_DEVTABLE_LEN (sizeof(PciDevTable)/sizeof(PCI_DEVTABLE))\n";
|
---|
83 |
|
---|
84 | }
|
---|
85 |
|
---|
86 | if ( length( classes) > 0 ) {
|
---|
87 | print "typedef struct _PCI_CLASSCODETABLE\n{\n\tunsigned char BaseClass ;\n\tunsigned char SubClass ;\n\tunsigned char ProgIf ;\n\tchar *\t\tBaseDesc ;\n\tchar *\t\tSubDesc ;\n\tchar *\t\tProgDesc ;\n} PCI_CLASSCODETABLE, *PPCI_CLASSCODETABLE ;\n";
|
---|
88 | print "PCI_CLASSCODETABLE PciClassCodeTable [] =\n{"
|
---|
89 | print classes;
|
---|
90 | print "} ;\n\n// Use this value for loop control during searching:\n#define PCI_CLASSCODETABLE_LEN (sizeof(PciClassCodeTable)/sizeof(PCI_CLASSCODETABLE))\n";
|
---|
91 |
|
---|
92 | }
|
---|
93 |
|
---|
94 | print "char *\tPciCommandFlags [] =\n{\n\t\"I/O Access\",\n\t\"Memory Access\",\n\t\"Bus Mastering\",\n\t\"Special Cycles\",\n\t\"Memory Write & Invalidate\",\n\t\"Palette Snoop\",\n\t\"Parity Errors\",\n\t\"Wait Cycles\",\n\t\"System Errors\",\n\t\"Fast Back-To-Back\",\n\t\"Reserved 10\",\n\t\"Reserved 11\",\n\t\"Reserved 12\",\n\t\"Reserved 13\",\n\t\"Reserved 14\",\n\t\"Reserved 15\"\n} ;\n";
|
---|
95 | print "// Use this value for loop control during searching:\n#define PCI_COMMANDFLAGS_LEN (sizeof(PciCommandFlags)/sizeof(char *))\n";
|
---|
96 | print "char *\tPciStatusFlags [] =\n{\n\t\"Reserved 0\",\n\t\"Reserved 1\",\n\t\"Reserved 2\",\n\t\"Reserved 3\",\n\t\"Reserved 4\",\n\t\"66 MHz Capable\",\n\t\"User-Defined Features\",\n\t\"Fast Back-To-Back\",\n\t\"Data Parity Reported\",\n\t\"\",\n\t\"\",\n\t\"Signalled Target Abort\",\n\t\"Received Target Abort\",\n\t\"Received Master Abort\",\n\t\"Signalled System Error\",\n\t\"Detected Parity Error\"\n} ;\n";
|
---|
97 | print "// Use this value for loop control during searching:\n#define PCI_STATUSFLAGS_LEN (sizeof(PciStatusFlags)/sizeof(char *))\n";
|
---|
98 | print "char *\tPciDevSelFlags [] =\n{\n\t\"Fast Devsel Speed\",\n\t\"Medium Devsel Speed\",\n\t\"Slow Devsel Speed\",\n\t\"Reserved 9&10\"\n} ;\n";
|
---|
99 | print "// Use this value for loop control during searching:\n#define PCI_DEVSELFLAGS_LEN (sizeof(PciDevSelFlags)/sizeof(char *))";
|
---|
100 |
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|