2 # $NetBSD: devlist2h.awk,v 1.11 2005/12/11 12:23:23 christos Exp $
4 # Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
7 # This code is derived from software contributed to The NetBSD Foundation
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
19 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
31 # Copyright (c) 1995, 1996 Christopher G. Demetriou
32 # All rights reserved.
34 # Redistribution and use in source and binary forms, with or without
35 # modification, are permitted provided that the following conditions
37 # 1. Redistributions of source code must retain the above copyright
38 # notice, this list of conditions and the following disclaimer.
39 # 2. Redistributions in binary form must reproduce the above copyright
40 # notice, this list of conditions and the following disclaimer in the
41 # documentation and/or other materials provided with the distribution.
42 # 3. All advertising materials mentioning features or use of this software
43 # must display the following acknowledgement:
44 # This product includes software developed by Christopher G. Demetriou.
45 # This product includes software developed by Christos Zoulas
46 # 4. The name of the author(s) may not be used to endorse or promote products
47 # derived from this software without specific prior written permission
49 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
50 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
53 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
58 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 function collectline
(_f
, _line
) {
87 nproducts = nvendors = blanklines =
0
88 dfile=
"pcmciadevs_data.h"
94 gsub("\\$", "", VERSION
)
95 gsub(/ $
/, "", VERSION
)
97 printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
98 printf("/*\n") > dfile
99 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
101 printf(" *\n") > dfile
102 printf(" * generated from:\n") > dfile
103 printf(" *\t%s\n", VERSION
) > dfile
104 printf(" */\n") > dfile
106 printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
107 printf("/*\n") > hfile
108 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
110 printf(" *\n") > hfile
111 printf(" * generated from:\n") > hfile
112 printf(" *\t%s\n", VERSION
) > hfile
113 printf(" */\n") > hfile
117 NF > 0 && $
1 ==
"vendor" {
120 vendorindex
[$
2] = nvendors
; # record index for this name, for later.
121 vendors
[nvendors
, 1] = $
2; # name
122 vendors
[nvendors
, 2] = $
3; # id
123 printf("#define\tPCMCIA_VENDOR_%s\t%s\t", vendors
[nvendors
, 1],
124 vendors
[nvendors
, 2]) > hfile
125 vendors
[nvendors
, 3] = collectline
(4, line
)
126 printf("/* %s */\n", vendors
[nvendors
, 3]) > hfile
129 NF > 0 && $
1 ==
"product" {
132 products
[nproducts
, 1] = $
2; # vendor name
133 products
[nproducts
, 2] = $
3; # product id
134 products
[nproducts
, 3] = $
4; # id
139 products
[nproducts
, 3] =
-1
141 for (i =
0; i
< 4; i
++) {
144 gsub("&tab", "\t", $f
)
145 gsub("&nl", "\n", $f
)
156 products
[nproducts
, 4] = z $f
160 products
[nproducts
, 4] =
"{ NULL, NULL, NULL, NULL }"
162 printf("#define\tPCMCIA_CIS_%s_%s\t%s\n",
163 products
[nproducts
, 1], products
[nproducts
, 2],
164 products
[nproducts
, 4]) > hfile
165 printf("#define\tPCMCIA_PRODUCT_%s_%s\t%s\n", products
[nproducts
, 1],
166 products
[nproducts
, 2], products
[nproducts
, 3]) > hfile
168 products
[nproducts
, 5] = collectline
(f
, line
)
180 # print out the match tables
184 printf("struct pcmcia_knowndev {\n") > dfile
185 printf("\tint vendorid;\n") > dfile
186 printf("\tint productid;\n") > dfile
187 printf("\tstruct pcmcia_knowndev_cis {\n") > dfile
188 printf("\t\tchar *vendor;\n") > dfile
189 printf("\t\tchar *product;\n") > dfile
190 printf("\t\tchar *version;\n") > dfile
191 printf("\t\tchar *revision;\n") > dfile
192 printf("\t}cis;\n") > dfile
193 printf("\tint flags;\n") > dfile
194 printf("\tchar *vendorname;\n") > dfile
195 printf("\tchar *devicename;\n") > dfile
196 printf("\tint reserve;\n") > dfile
197 printf("};\n\n") > dfile
198 printf("#define PCMCIA_CIS_INVALID\t\t{ NULL, NULL, NULL, NULL }\n") > dfile
199 printf("#define PCMCIA_KNOWNDEV_NOPROD\t\t0\n\n") > dfile
200 printf("struct pcmcia_knowndev pcmcia_knowndevs[] = {\n") > dfile
201 for (i =
1; i
<= nproducts
; i
++) {
202 printf("\t{\n") > dfile
203 if (products
[i
, 3] ==
-1) {
204 printf("\t PCMCIA_VENDOR_UNKNOWN, PCMCIA_PRODUCT_%s_%s,\n",
205 products
[i
, 1], products
[i
, 2]) > dfile
207 printf("\t PCMCIA_VENDOR_%s, PCMCIA_PRODUCT_%s_%s,\n",
208 products
[i
, 1], products
[i
, 1], products
[i
, 2]) > dfile
210 printf("\t PCMCIA_CIS_%s_%s,\n",
211 products
[i
, 1], products
[i
, 2]) > dfile
212 printf("\t ") > dfile
214 printf(",\n") > dfile
216 if (products
[i
, 1] in vendorindex
) {
217 vendi = vendorindex
[products
[i
, 1]];
218 vendname = vendors
[vendi
, 3]
222 printf("\t \"%s\",\n", vendname
) > dfile
223 printf("\t \"%s\",\t}\n", products
[i
, 5]) > dfile
224 printf("\t,\n") > dfile
226 for (i =
1; i
<= nvendors
; i
++) {
227 printf("\t{\n") > dfile
228 printf("\t PCMCIA_VENDOR_%s,\n", vendors
[i
, 1]) > dfile
229 printf("\t PCMCIA_KNOWNDEV_NOPROD,\n") > dfile
230 printf("\t PCMCIA_CIS_INVALID,\n") > dfile
231 printf("\t 0,\n") > dfile
232 printf("\t \"%s\",\n", vendors
[i
, 3]) > dfile
233 printf("\t NULL,\n") > dfile
234 printf("\t},\n") > dfile
236 printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile
237 printf("};\n") > dfile