No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp300 / dev / devlist2h.awk
blobb5e326ab7f443064d61a543204ee148d9fc77db7
1 #! /usr/bin/awk -f
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
7 # All rights reserved.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
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.
34 BEGIN {
35 ndevices = blanklines = 0
36 fbid = 0
37 dfile="diodevs_data.h"
38 hfile="diodevs.h"
40 NR == 1 {
41 VERSION = $0
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") \
47 > dfile
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") \
56 > hfile
57 printf(" *\n") > hfile
58 printf(" * generated from:\n") > hfile
59 printf(" *\t%s\n", VERSION) > hfile
60 printf(" */\n") > hfile
62 next
64 NF > 0 && $1 == "device" {
65 ndevices++
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
71 # used by device
73 # if this is the framebuffer entry, save the primary id
74 if ($2 == "FRAMEBUFFER") {
75 fbid = $3;
78 # emit device primary id
79 printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices[ndevices, 1], \
80 devices[ndevices, 2]) > hfile
82 # emit description
83 printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
84 > hfile
86 f = 5;
88 while (f <= NF) {
89 printf("%s", $f) > hfile
90 if (f < NF)
91 printf(" ") > hfile
92 f++;
94 printf("\"\n") > hfile
96 next
98 NF > 0 && $1 == "framebuffer" {
99 ndevices++
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
105 # used by device
107 # emit device secondary id
108 printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices[ndevices, 1], \
109 devices[ndevices, 3]) > hfile
111 # emit description
112 printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
113 > hfile
115 f = 5;
117 while (f <= NF) {
118 printf("%s", $f) > hfile
119 if (f < NF)
120 printf(" ") > hfile
121 f++;
123 printf("\"\n") > hfile
125 next
128 if ($0 == "")
129 blanklines++
130 if (blanklines != 2 && blanklines != 3)
131 print $0 > hfile
132 if (blanklines < 2)
133 print $0 > dfile
135 END {
136 # emit device count
138 printf("\n") > dfile
139 printf("#define DIO_NDEVICES\t%d\n", ndevices) > dfile
141 # emit select code size table
143 printf("\n") > dfile
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
155 printf("\n") > dfile
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
168 close(dfile)
169 close(hfile)