3 # $NetBSD: devlist2h.awk,v 1.5.48.3 2004/09/21 13:15:13 skrll Exp $
5 # Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
6 # Copyright (c) 1995, 1996 Christopher G. Demetriou
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. All advertising materials mentioning features or use of this software
18 # must display the following acknowledgement:
19 # This product includes software developed by Christopher G. Demetriou.
20 # 4. The name of the author may not be used to endorse or promote products
21 # derived from this software without specific prior written permission
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ndevices = blanklines =
0
37 dfile=
"diodevs_data.h"
42 gsub("\\$", "", VERSION
)
44 printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
45 printf("/*\n") > dfile
46 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
48 printf(" *\n") > dfile
49 printf(" * generated from:\n") > dfile
50 printf(" *\t%s\n", VERSION
) > dfile
51 printf(" */\n") > dfile
53 printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
54 printf("/*\n") > hfile
55 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
57 printf(" *\n") > hfile
58 printf(" * generated from:\n") > hfile
59 printf(" *\t%s\n", VERSION
) > hfile
60 printf(" */\n") > hfile
64 NF > 0 && $
1 ==
"device" {
67 devices
[ndevices
, 1] = $
2 # nickname
68 devices
[ndevices
, 2] = $
3 # dio primary id
69 devices
[ndevices
, 3] =
"0" # dio secondary id
70 devices
[ndevices
, 4] = $
4 # number of select codes
73 # if this is the framebuffer entry, save the primary id
74 if ($
2 ==
"FRAMEBUFFER") {
78 # emit device primary id
79 printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices
[ndevices
, 1], \
80 devices
[ndevices
, 2]) > hfile
83 printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices
[ndevices
, 1]) \
89 printf("%s", $f
) > hfile
94 printf("\"\n") > hfile
98 NF > 0 && $
1 ==
"framebuffer" {
101 devices
[ndevices
, 1] = $
2 # nickname
102 devices
[ndevices
, 2] = fbid
# dio primary id
103 devices
[ndevices
, 3] = $
3 # dio secondary id
104 devices
[ndevices
, 4] = $
4 # number of select codes
107 # emit device secondary id
108 printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices
[ndevices
, 1], \
109 devices
[ndevices
, 3]) > hfile
112 printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices
[ndevices
, 1]) \
118 printf("%s", $f
) > hfile
123 printf("\"\n") > hfile
130 if (blanklines
!= 2 && blanklines
!= 3)
139 printf("#define DIO_NDEVICES\t%d\n", ndevices
) > dfile
141 # emit select code size table
145 printf("struct dio_devdata dio_devdatas[] = {\n") > dfile
146 for (i =
1; i
<= ndevices
; i
++) {
147 printf("\t{ %s,\t%s,\t%s },\n", devices
[i
, 2],
148 devices
[i
, 3], devices
[i
, 4]) > dfile
151 printf("};\n") > dfile
153 # emit description table
156 printf("#ifdef DIOVERBOSE\n") > dfile
158 printf("struct dio_devdesc dio_devdescs[] = {\n") > dfile
160 for (i =
1; i
<= ndevices
; i
++) {
161 printf("\t{ %s,\t%s,\tDIO_DEVICE_DESC_%s },\n",
162 devices
[i
, 2], devices
[i
, 3], devices
[i
, 1]) > dfile
165 printf("};\n") > dfile
167 printf("#endif /* DIOVERBOSE */\n") > dfile