2 # $NetBSD: devlist2h.awk,v 1.12 2005/12/11 12:22:49 christos Exp $
4 # Copyright (c) 1995, 1996 Christopher G. Demetriou
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed by Christopher G. Demetriou.
18 # 4. The name of the author may not be used to endorse or promote products
19 # derived from this software without specific prior written permission
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 nproducts = nvendors = blanklines =
0
35 dfile=
"pcidevs_data.h"
40 gsub("\\$", "", VERSION
)
41 gsub(/ $
/, "", VERSION
)
43 printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
44 printf("/*\n") > dfile
45 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
47 printf(" *\n") > dfile
48 printf(" * generated from:\n") > dfile
49 printf(" *\t%s\n", VERSION
) > dfile
50 printf(" */\n") > dfile
52 printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
53 printf("/*\n") > hfile
54 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
56 printf(" *\n") > hfile
57 printf(" * generated from:\n") > hfile
58 printf(" *\t%s\n", VERSION
) > hfile
59 printf(" */\n") > hfile
63 NF > 0 && $
1 ==
"vendor" {
66 vendorindex
[$
2] = nvendors
; # record index for this name, for later.
67 vendors
[nvendors
, 1] = $
2; # name
68 vendors
[nvendors
, 2] = $
3; # id
69 printf("#define\tPCI_VENDOR_%s\t%s", vendors
[nvendors
, 1],
70 vendors
[nvendors
, 2]) > hfile
77 printf("\t\t/* ") > hfile
88 printf("%s", $f
) > hfile
94 vendors
[nvendors
, i
] = $f
95 if (words
[$f
, 1] ==
0) {
97 parts =
split($f
, junk
, "\\");
100 words
[$f
, 1] = nwords
;
102 wordlist
[nwords
, 1] = $f
;
103 wordlist
[nwords
, 3] = nchars
;
104 nchars = nchars
+ l
+ 1;
106 wordlist
[words
[$f
, 1], 2]++;
107 vendors
[nvendors
, i
] = words
[$f
, 1];
108 printf("%s", $f
) > hfile
116 printf(" */") > hfile
121 NF > 0 && $
1 ==
"product" {
124 products
[nproducts
, 1] = $
2; # vendor name
125 products
[nproducts
, 2] = $
3; # product id
126 products
[nproducts
, 3] = $
4; # id
127 printf("#define\tPCI_PRODUCT_%s_%s\t%s", products
[nproducts
, 1],
128 products
[nproducts
, 2], products
[nproducts
, 3]) > hfile
133 ocomment = oparen =
0
135 printf("\t\t/* ") > hfile
146 printf("%s", $f
) > hfile
152 if (words
[$f
, 1] ==
0) {
154 parts =
split($f
, junk
, "\\");
158 words
[$f
, 1] = nwords
;
159 wordlist
[nwords
, 1] = $f
;
160 wordlist
[nwords
, 3] = nchars
;
161 nchars = nchars
+ l
+ 1;
163 wordlist
[words
[$f
, 1], 2]++;
164 products
[nproducts
, i
] = words
[$f
, 1];
165 printf("%s", $f
) > hfile
173 printf(" */") > hfile
186 # print out the match tables
190 printf("static const uint16_t pci_vendors[] = {\n") > dfile
191 for (i =
1; i
<= nvendors
; i
++) {
192 printf("\t PCI_VENDOR_%s", vendors
[i
, 1]) \
196 while ((i
, j
) in vendors
) {
198 wordlist
[vendors
[i
, j
], 3]) > dfile
199 # printf(", %d /* %s */",
200 # wordlist[vendors[i, j], 3],
201 # wordlist[vendors[i, j], 1]) > dfile
204 printf(", 0,\n", sep
) > dfile
206 printf("};\n") > dfile
210 printf("static const uint16_t pci_products[] = {\n") > dfile
211 for (i =
1; i
<= nproducts
; i
++) {
212 printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s, \n",
213 products
[i
, 1], products
[i
, 1], products
[i
, 2]) \
216 printf("\t ") > dfile
219 while ((i
, j
) in products
) {
221 wordlist
[products
[i
, j
], 3]) > dfile
222 # printf("%s%d /* %s */", sep,
223 # wordlist[products[i, j], 3],
224 # wordlist[products[i, j], 1]) > dfile
228 printf("%s0,\n", sep
) > dfile
230 printf("};\n") > dfile
232 printf("static const char pci_words[] = { \".\" \n") > dfile
233 for (i =
1; i
<= nwords
; i
++) {
234 printf("\t \"%s\\0\" /* %d refs @ %d */\n",
235 wordlist
[i
, 1], wordlist
[i
, 2], wordlist
[i
, 3]) > dfile
237 printf("};\n") > dfile
238 printf("const int pci_nwords = %d;\n", nwords
) > dfile