2 # $NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd 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 =
0
34 dfile=
"pcidevs_data.h"
39 gsub("\\$", "", VERSION
)
41 printf("/*\n") > dfile
42 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
44 printf(" *\n") > dfile
45 printf(" * generated from:\n") > dfile
46 printf(" *\t%s\n", VERSION
) > dfile
47 printf(" */\n") > dfile
49 printf("/*\n") > hfile
50 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
52 printf(" *\n") > hfile
53 printf(" * generated from:\n") > hfile
54 printf(" *\t%s\n", VERSION
) > hfile
55 printf(" */\n") > hfile
62 vendorindex
[$
2] = nvendors
; # record index for this name, for later.
63 vendors
[nvendors
, 1] = $
2; # name
64 vendors
[nvendors
, 2] = $
3; # id
65 printf("#define\tPCI_VENDOR_%s\t%s\t", vendors
[nvendors
, 1],
66 vendors
[nvendors
, 2]) > hfile
73 printf("\t/* ") > hfile
84 printf("%s", $f
) > hfile
90 vendors
[nvendors
, i
] = $f
91 printf("%s", vendors
[nvendors
, i
]) > hfile
107 products
[nproducts
, 1] = $
2; # vendor name
108 products
[nproducts
, 2] = $
3; # product id
109 products
[nproducts
, 3] = $
4; # id
110 printf("#define\tPCI_PRODUCT_%s_%s\t%s\t", products
[nproducts
, 1],
111 products
[nproducts
, 2], products
[nproducts
, 3]) > hfile
116 ocomment = oparen =
0
118 printf("\t/* ") > hfile
129 printf("%s", $f
) > hfile
135 products
[nproducts
, i
] = $f
136 printf("%s", products
[nproducts
, i
]) > hfile
144 printf(" */") > hfile
157 # print out the match tables
162 printf("static const struct pci_knowndev pci_knowndevs[] = {\n") > dfile
163 for (i =
1; i
<= nproducts
; i
++) {
164 printf("\t{\n") > dfile
165 printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s,\n",
166 products
[i
, 1], products
[i
, 1], products
[i
, 2]) \
168 printf("\t ") > dfile
170 printf(",\n") > dfile
172 vendi = vendorindex
[products
[i
, 1]];
173 printf("\t \"") > dfile
176 while (vendors
[vendi
, j
] != "") {
179 printf("%s", vendors
[vendi
, j
]) > dfile
183 printf("\",\n") > dfile
185 printf("\t \"") > dfile
188 while (products
[i
, j
] != "") {
191 printf("%s", products
[i
, j
]) > dfile
195 printf("\",\n") > dfile
196 printf("\t},\n") > dfile
198 for (i =
1; i
<= nvendors
; i
++) {
199 printf("\t{\n") > dfile
200 printf("\t PCI_VENDOR_%s, 0,\n", vendors
[i
, 1]) \
202 printf("\t PCI_KNOWNDEV_NOPROD,\n") \
204 printf("\t \"") > dfile
207 while (vendors
[i
, j
] != "") {
210 printf("%s", vendors
[i
, j
]) > dfile
214 printf("\",\n") > dfile
215 printf("\t NULL,\n") > dfile
216 printf("\t},\n") > dfile
218 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
219 printf("};\n") > dfile