[BACK]Return to devlist2h.awk CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / dev

Annotation of sys/arch/hp300/dev/devlist2h.awk, Revision 1.1.1.1

1.1       nbrk        1: #! /usr/bin/awk -f
                      2: #
                      3: #      $OpenBSD: devlist2h.awk,v 1.2 1997/02/03 04:47:16 downsj Exp $
                      4: #      $NetBSD: devlist2h.awk,v 1.2 1997/01/30 09:18:36 thorpej Exp $
                      5: #
                      6: # Copyright (c) 1996 Jason R. Thorpe.  All rights reserved.
                      7: # Copyright (c) 1995, 1996 Christopher G. Demetriou
                      8: # All rights reserved.
                      9: #
                     10: # Redistribution and use in source and binary forms, with or without
                     11: # modification, are permitted provided that the following conditions
                     12: # are met:
                     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.
                     18: # 3. All advertising materials mentioning features or use of this software
                     19: #    must display the following acknowledgement:
                     20: #      This product includes software developed by Christopher G. Demetriou.
                     21: # 4. The name of the author may not be used to endorse or promote products
                     22: #    derived from this software without specific prior written permission
                     23: #
                     24: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     25: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     26: # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     27: # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     28: # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     29: # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     30: # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     31: # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     32: # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     33: # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     34: #
                     35: BEGIN {
                     36:        ndevices = 0
                     37:        fbid = 0
                     38:        dfile="diodevs_data.h"
                     39:        hfile="diodevs.h"
                     40: }
                     41: NR == 1 {
                     42:        VERSION = $0
                     43:        gsub("\\$", "", VERSION)
                     44:
                     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
                     52:
                     53:        printf("/*\n") > hfile
                     54:        printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
                     55:            > hfile
                     56:        printf(" *\n") > hfile
                     57:        printf(" * generated from:\n") > hfile
                     58:        printf(" *\t%s\n", VERSION) > hfile
                     59:        printf(" */\n") > hfile
                     60:
                     61:        next
                     62: }
                     63: $1 == "device" {
                     64:        ndevices++
                     65:
                     66:        devices[ndevices, 1] = $2               # nickname
                     67:        devices[ndevices, 2] = $3               # dio primary id
                     68:        devices[ndevices, 3] = "0"              # dio secondary id
                     69:        devices[ndevices, 4] = $4               # number of select codes
                     70:                                                #  used by device
                     71:
                     72:        # if this is the framebuffer entry, save the primary id
                     73:        if ($2 == "FRAMEBUFFER") {
                     74:                fbid = $3;
                     75:        }
                     76:
                     77:        # emit device primary id
                     78:        printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices[ndevices, 1], \
                     79:            devices[ndevices, 2]) > hfile
                     80:
                     81:        # emit description
                     82:        printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
                     83:            > hfile
                     84:
                     85:        f = 5;
                     86:
                     87:        while (f <= NF) {
                     88:                printf("%s", $f) > hfile
                     89:                if (f < NF)
                     90:                        printf(" ") > hfile
                     91:                f++;
                     92:        }
                     93:        printf("\"\n") > hfile
                     94:
                     95:        next
                     96: }
                     97: $1 == "framebuffer" {
                     98:        ndevices++
                     99:
                    100:        devices[ndevices, 1] = $2               # nickname
                    101:        devices[ndevices, 2] = fbid             # dio primary id
                    102:        devices[ndevices, 3] = $3               # dio secondary id
                    103:        devices[ndevices, 4] = $4               # number of select codes
                    104:                                                #  used by device
                    105:
                    106:        # emit device secondary id
                    107:        printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices[ndevices, 1], \
                    108:            devices[ndevices, 3]) > hfile
                    109:
                    110:        # emit description
                    111:        printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
                    112:            > hfile
                    113:
                    114:        f = 5;
                    115:
                    116:        while (f <= NF) {
                    117:                printf("%s", $f) > hfile
                    118:                if (f < NF)
                    119:                        printf(" ") > hfile
                    120:                f++;
                    121:        }
                    122:        printf("\"\n") > hfile
                    123:
                    124:        next
                    125: }
                    126: {
                    127:        if ($0 == "")
                    128:                blanklines++
                    129:        if (blanklines != 2 && blanklines != 3)
                    130:                print $0 > hfile
                    131:        if (blanklines < 2)
                    132:                print $0 > dfile
                    133: }
                    134: END {
                    135:        # emit device count
                    136:
                    137:        printf("\n") > dfile
                    138:        printf("#define DIO_NDEVICES\t%d\n", ndevices) > dfile
                    139:
                    140:        # emit select code size table
                    141:
                    142:        printf("\n") > dfile
                    143:
                    144:        printf("struct dio_devdata dio_devdatas[] = {\n") > dfile
                    145:        for (i = 1; i <= ndevices; i++) {
                    146:                printf("\t{ %s,\t%s,\t%s },\n", devices[i, 2],
                    147:                    devices[i, 3], devices[i, 4]) > dfile
                    148:        }
                    149:
                    150:        printf("};\n") > dfile
                    151:
                    152:        # emit description table
                    153:
                    154:        printf("\n") > dfile
                    155:        printf("#ifdef DIOVERBOSE\n") > dfile
                    156:
                    157:        printf("struct dio_devdesc dio_devdescs[] = {\n") > dfile
                    158:
                    159:        for (i = 1; i <= ndevices; i++) {
                    160:                printf("\t{ %s,\t%s,\tDIO_DEVICE_DESC_%s },\n",
                    161:                    devices[i, 2], devices[i, 3], devices[i, 1]) > dfile
                    162:        }
                    163:
                    164:        printf("};\n") > dfile
                    165:
                    166:        printf("#endif /* DIOVERBOSE */\n") > dfile
                    167: }

CVSweb