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"
39 printf("/*\n") > dfile
40 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
42 printf(" */\n") > dfile
44 printf("/*\n") > hfile
45 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
47 printf(" */\n") > hfile
51 NF > 0 && $1 == "vendor" {
54 vendorindex[$2] = nvendors; # record index for this name, for later.
55 vendors[nvendors, 1] = $2; # name
56 vendors[nvendors, 2] = $3; # id
57 printf("#define\tPCI_VENDOR_%s\t%s\t", vendors[nvendors, 1],
58 vendors[nvendors, 2]) > hfile
65 printf("\t/* ") > hfile
76 printf("%s", $f) > hfile
82 vendors[nvendors, i] = $f
83 printf("%s", vendors[nvendors, i]) > hfile
96 NF > 0 && $1 == "product" {
99 products[nproducts, 1] = $2; # vendor name
100 products[nproducts, 2] = $3; # product id
101 products[nproducts, 3] = $4; # id
102 printf("#define\tPCI_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
103 products[nproducts, 2], products[nproducts, 3]) > hfile
108 ocomment = oparen = 0
110 printf("\t/* ") > hfile
121 printf("%s", $f) > hfile
127 products[nproducts, i] = $f
128 printf("%s", products[nproducts, i]) > hfile
136 printf(" */") > hfile
149 # print out the match tables
153 printf("const struct pci_knowndev pci_knowndevs[] = {\n") > dfile
154 for (i = 1; i <= nproducts; i++) {
155 printf("\t{\n") > dfile
156 printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s,\n",
157 products[i, 1], products[i, 1], products[i, 2]) \
159 printf("\t ") > dfile
161 printf(",\n") > dfile
163 vendi = vendorindex[products[i, 1]];
164 printf("\t \"") > dfile
167 while ((vendi, j) in vendors) {
170 printf("%s", vendors[vendi, j]) > dfile
174 printf("\",\n") > dfile
176 printf("\t \"") > dfile
179 while ((i, j) in products) {
182 printf("%s", products[i, j]) > dfile
186 printf("\",\n") > dfile
187 printf("\t},\n") > dfile
189 for (i = 1; i <= nvendors; i++) {
190 printf("\t{\n") > dfile
191 printf("\t PCI_VENDOR_%s, 0,\n", vendors[i, 1]) \
193 printf("\t PCI_KNOWNDEV_NOPROD,\n") \
195 printf("\t \"") > dfile
198 while ((i, j) in vendors) {
201 printf("%s", vendors[i, j]) > dfile
205 printf("\",\n") > dfile
206 printf("\t NULL,\n") > dfile
207 printf("\t},\n") > dfile
209 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
210 printf("};\n") > dfile