2 # $DragonFly: src/sys/bus/pci/devlist2h.awk,v 1.2 2004/02/19 20:47:56 joerg Exp $
3 # $NetBSD: devlist2h.awk,v 1.7 2003/12/05 04:33:27 grant Exp $
5 # Copyright (c) 1995, 1996 Christopher G. Demetriou
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed by Christopher G. Demetriou.
19 # 4. The name of the author may not be used to endorse or promote products
20 # derived from this software without specific prior written permission
22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 nproducts = nvendors = blanklines = 0
35 dfile="pcidevs_data.h"
40 gsub("\\$", "", VERSION)
42 printf("/*\t$DragonFly" "$\t*/\n\n") > dfile
43 printf("/*\n") > dfile
44 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
46 printf(" *\n") > dfile
47 printf(" * generated from:\n") > dfile
48 printf(" *\t%s\n", VERSION) > dfile
49 printf(" */\n") > dfile
51 printf("/*\t$DragonFly" "$\t*/\n\n") > hfile
52 printf("/*\n") > hfile
53 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
55 printf(" *\n") > hfile
56 printf(" * generated from:\n") > hfile
57 printf(" *\t%s\n", VERSION) > hfile
58 printf(" */\n") > hfile
62 NF > 0 && $1 == "vendor" {
65 vendorindex[$2] = nvendors; # record index for this name, for later.
66 vendors[nvendors, 1] = $2; # name
67 vendors[nvendors, 2] = $3; # id
68 printf("#define\tPCI_VENDOR_%s\t%s\t", vendors[nvendors, 1],
69 vendors[nvendors, 2]) > hfile
76 printf("\t/* ") > hfile
87 printf("%s", $f) > hfile
93 vendors[nvendors, i] = $f
94 printf("%s", vendors[nvendors, i]) > hfile
102 printf(" */") > hfile
107 NF > 0 && $1 == "product" {
110 products[nproducts, 1] = $2; # vendor name
111 products[nproducts, 2] = $3; # product id
112 products[nproducts, 3] = $4; # id
113 printf("#define\tPCI_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
114 products[nproducts, 2], products[nproducts, 3]) > hfile
119 ocomment = oparen = 0
121 printf("\t/* ") > hfile
132 printf("%s", $f) > hfile
138 products[nproducts, i] = $f
139 printf("%s", products[nproducts, i]) > hfile
147 printf(" */") > hfile
160 # print out the match tables
164 printf("const struct pci_knowndev pci_knowndevs[] = {\n") > dfile
165 for (i = 1; i <= nproducts; i++) {
166 printf("\t{\n") > dfile
167 printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s,\n",
168 products[i, 1], products[i, 1], products[i, 2]) \
170 printf("\t ") > dfile
172 printf(",\n") > dfile
174 vendi = vendorindex[products[i, 1]];
175 printf("\t \"") > dfile
178 while ((vendi, j) in vendors) {
181 printf("%s", vendors[vendi, j]) > dfile
185 printf("\",\n") > dfile
187 printf("\t \"") > dfile
190 while ((i, j) in products) {
193 printf("%s", products[i, j]) > dfile
197 printf("\",\n") > dfile
198 printf("\t},\n") > dfile
200 for (i = 1; i <= nvendors; i++) {
201 printf("\t{\n") > dfile
202 printf("\t PCI_VENDOR_%s, 0,\n", vendors[i, 1]) \
204 printf("\t PCI_KNOWNDEV_NOPROD,\n") \
206 printf("\t \"") > dfile
209 while ((i, j) in vendors) {
212 printf("%s", vendors[i, j]) > dfile
216 printf("\",\n") > dfile
217 printf("\t NULL,\n") > dfile
218 printf("\t},\n") > dfile
220 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
221 printf("};\n") > dfile