The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/isapnp/devlist2h.awk

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #! /usr/bin/awk -f
    2 #       $NetBSD: devlist2h.awk,v 1.6 2003/12/15 07:32:20 jmc Exp $
    3 #
    4 # Copyright (c) 1998 The NetBSD Foundation, Inc.
    5 # All rights reserved.
    6 #
    7 # This code is derived from software contributed to The NetBSD Foundation
    8 # by Christos Zoulas.
    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 the NetBSD
   21 #        Foundation, Inc. and its contributors.
   22 # 4. Neither the name of The NetBSD Foundation nor the names of its
   23 #    contributors may be used to endorse or promote products derived
   24 #    from this software without specific prior written permission.
   25 #
   26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36 # POSSIBILITY OF SUCH DAMAGE.
   37 #
   38 # Copyright (c) 1995, 1996 Christopher G. Demetriou
   39 # All rights reserved.
   40 #
   41 # Redistribution and use in source and binary forms, with or without
   42 # modification, are permitted provided that the following conditions
   43 # are met:
   44 # 1. Redistributions of source code must retain the above copyright
   45 #    notice, this list of conditions and the following disclaimer.
   46 # 2. Redistributions in binary form must reproduce the above copyright
   47 #    notice, this list of conditions and the following disclaimer in the
   48 #    documentation and/or other materials provided with the distribution.
   49 # 3. All advertising materials mentioning features or use of this software
   50 #    must display the following acknowledgement:
   51 #      This product includes software developed by Christopher G. Demetriou.
   52 #      This product includes software developed by Christos Zoulas
   53 # 4. The name of the author(s) may not be used to endorse or promote products
   54 #    derived from this software without specific prior written permission
   55 #
   56 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   57 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   58 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   59 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   60 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   61 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   62 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   63 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   64 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   65 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   66 #
   67 function collectline(f) {
   68         oparen = 0
   69         line = ""
   70         while (f <= NF) {
   71                 if ($f == "#") {
   72                         line = line "("
   73                         oparen = 1
   74                         f++
   75                         continue
   76                 }
   77                 if (oparen) {
   78                         line = line $f
   79                         if (f < NF)
   80                                 line = line " "
   81                         f++
   82                         continue
   83                 }
   84                 line = line $f
   85                 if (f < NF)
   86                         line = line " "
   87                 f++
   88         }
   89         if (oparen)
   90                 line = line ")"
   91         return line
   92 }
   93 function checkdecl() {
   94         done = 1
   95         if (!decl) {
   96                 decl = 1;
   97                 printf("struct isapnp_matchinfo {\n") > hfile
   98                 printf("\tconst char *name;\n") > hfile
   99                 printf("\tint variant;\n") > hfile
  100                 printf("};\n\n") > hfile
  101                 printf("struct isapnp_devinfo {\n") > hfile
  102                 printf("\tconst struct isapnp_matchinfo *devlogic;\n") > hfile
  103                 printf("\tint nlogic;\n") > hfile
  104                 printf("\tconst struct isapnp_matchinfo *devcompat;\n") > hfile
  105                 printf("\tint ncompat;\n") > hfile
  106                 printf("};\n\n") > hfile
  107                 printf("\n#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"$NetBSD" "$\");\n\n") > cfile
  108                 printf("#include <sys/param.h>\n") > cfile
  109                 printf("#include <dev/isapnp/isapnpdevs.h>\n\n") > cfile
  110         }
  111 }
  112 BEGIN {
  113         decl = done = ncompat = nlogicals = ndriver = blanklines = ncompats = 0
  114         cfile="isapnpdevs.c"
  115         hfile="isapnpdevs.h"
  116 }
  117 NR == 1 {
  118         VERSION = $0
  119         gsub("\\$", "", VERSION)
  120 
  121         printf("/*\t$NetBSD" "$\t*/\n\n") > cfile
  122         printf("/*\n") > cfile
  123         printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
  124             > cfile
  125         printf(" *\n") > cfile
  126         printf(" * generated from:\n") > cfile
  127         printf(" *\t%s\n", VERSION) > cfile
  128         printf(" */\n") > cfile
  129 
  130         printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
  131         printf("/*\n") > hfile
  132         printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
  133             > hfile
  134         printf(" *\n") > hfile
  135         printf(" * generated from:\n") > hfile
  136         printf(" *\t%s\n", VERSION) > hfile
  137         printf(" */\n") > hfile
  138         printf("\n") > hfile
  139         next
  140 }
  141 NF > 0 && $1 == "driver" {
  142         checkdecl()
  143         ndriver++
  144 
  145         driverindex[$2] = ndriver;
  146         driver[ndriver, 1] = $2;
  147         driver[ndriver, 2] = collectline(3);
  148         printf("/* %s */\n", driver[ndriver, 2]) > hfile
  149         printf("extern const struct isapnp_devinfo isapnp_%s_devinfo;\n",
  150             driver[ndriver, 1]) > hfile
  151         next
  152 }
  153 NF > 0 && $1 == "devlogic" {
  154         checkdecl()
  155         nlogicals++
  156 
  157         logicals[nlogicals, 1] = $2;
  158         logicals[nlogicals, 2] = $3;
  159         logicals[nlogicals, 3] = $4;
  160         logicals[nlogicals, 4] = collectline(5);
  161         next
  162 }
  163 NF > 0 && $1 == "devcompat" {
  164         checkdecl()
  165         ncompats++
  166 
  167         compats[ncompats, 1] = $2;
  168         compats[ncompats, 2] = $3;
  169         compats[ncompats, 3] = $4;
  170         compats[ncompats, 4] = collectline(5);
  171         next
  172 }
  173 {
  174         if (!done) {
  175                 if ($0 == "")
  176                         blanklines++
  177                 print $0 > hfile
  178                 if (blanklines < 2)
  179                         print $0 > cfile
  180         }
  181 }
  182 END {
  183         # print out the match tables
  184 
  185         printf("\n") > cfile
  186 
  187         for (i = 1; i <= ndriver; i++) {
  188                 nlogical = ncompat = 0;
  189                 printf("/* %s */\n", driver[i, 2]) > cfile
  190                 for (j = 1; j <= nlogicals; j++) {
  191                         if (logicals[j, 1] == driver[i, 1]) {
  192                                 if (nlogical == 0)
  193                                         printf("static const struct isapnp_matchinfo isapnp_%s_devlogic[] = {\n",
  194                                             driver[i, 1]) > cfile
  195                                 nlogical++;
  196                                 printf("\t{\"%s\", %d},\t/* %s */\n",
  197                                     logicals[j, 2], logicals[j, 3],
  198                                     logicals[j, 4]) > cfile
  199                         }
  200                 }
  201                 if (nlogical != 0)
  202                         printf("};\n") > cfile
  203                 for (j = 1; j <= ncompats; j++) {
  204                         if (compats[j, 1] == driver[i, 1]) {
  205                                 if (ncompat == 0)
  206                                         printf("static const struct isapnp_matchinfo isapnp_%s_devcompat[] = {\n",
  207                                             driver[i, 1]) > cfile
  208                                 ncompat++;
  209                                 printf("\t{\"%s\", %d},\t/* %s */\n",
  210                                     compats[j, 2], compats[j, 3],
  211                                     compats[j, 4]) > cfile
  212                         }
  213                 }
  214                 if (ncompat != 0)
  215                         printf("};\n") > cfile
  216                 printf("const struct isapnp_devinfo isapnp_%s_devinfo = {\n",
  217                     driver[i, 1]) > cfile
  218                 if (nlogical != 0)
  219                         printf("\tisapnp_%s_devlogic, %d,\n",
  220                             driver[i, 1], nlogical) > cfile
  221                 else
  222                         printf("\tNULL, 0,\n") > cfile
  223                 if (ncompat != 0)
  224                         printf("\tisapnp_%s_devcompat, %d,\n",
  225                             driver[i, 1], ncompat) > cfile
  226                 else
  227                         printf("\tNULL, 0,\n") > cfile
  228                 printf("};\n\n") > cfile;
  229 
  230         }
  231         close(cfile)
  232         close(hfile)
  233 }

Cache object: de96ddc40f1e6f17eb29e76a378215ae


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.