summaryrefslogtreecommitdiffstats
path: root/sys/tools
diff options
context:
space:
mode:
Diffstat (limited to 'sys/tools')
-rw-r--r--sys/tools/devlist2h.awk147
-rw-r--r--sys/tools/miidevs2h.awk147
-rw-r--r--sys/tools/pccarddevs2h.awk226
-rw-r--r--sys/tools/usbdevs2h.awk236
-rw-r--r--sys/tools/vnode_if.awk354
5 files changed, 1110 insertions, 0 deletions
diff --git a/sys/tools/devlist2h.awk b/sys/tools/devlist2h.awk
new file mode 100644
index 0000000..6c76b17
--- /dev/null
+++ b/sys/tools/devlist2h.awk
@@ -0,0 +1,147 @@
+#! /usr/bin/awk -f
+# $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
+#
+# Copyright (c) 1998 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This model includes software developed by Christopher G. Demetriou.
+# This model includes software developed by Christos Zoulas
+# 4. The name of the author(s) may not be used to endorse or promote models
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+function collectline(f, line) {
+ oparen = 0
+ line = ""
+ while (f <= NF) {
+ if ($f == "#") {
+ line = line "("
+ oparen = 1
+ f++
+ continue
+ }
+ if (oparen) {
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ continue
+ }
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ }
+ if (oparen)
+ line = line ")"
+ return line
+}
+BEGIN {
+ nmodels = nouis = 0
+ hfile="miidevs.h"
+}
+NR == 1 {
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
+ printf("/*\n") > hfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > hfile
+ printf(" *\n") > hfile
+ printf(" * generated from:\n") > hfile
+ printf(" *\t%s\n", VERSION) > hfile
+ printf(" */\n") > hfile
+
+ next
+}
+$1 == "oui" {
+ nuios++
+
+ ouiindex[$2] = nouis; # record index for this name, for later.
+
+ ouis[nouis, 1] = $2; # name
+ ouis[nouis, 2] = $3; # id
+ printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
+ ouis[nouis, 2]) > hfile
+ ouis[nouis, 3] = collectline(4, line)
+ printf("/* %s */\n", ouis[nouis, 3]) > hfile
+ next
+}
+$1 == "model" {
+ nmodels++
+
+ models[nmodels, 1] = $2; # oui name
+ models[nmodels, 2] = $3; # model id
+ models[nmodels, 3] = $4; # id
+
+ printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
+ models[nmodels, 2], models[nmodels, 3]) > hfile
+
+ models[nmodels, 4] = collectline(5, line)
+
+ printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
+ models[nmodels, 1], models[nmodels, 2],
+ models[nmodels, 4]) > hfile
+
+ next
+}
+{
+ print $0 > hfile
+}
diff --git a/sys/tools/miidevs2h.awk b/sys/tools/miidevs2h.awk
new file mode 100644
index 0000000..6c76b17
--- /dev/null
+++ b/sys/tools/miidevs2h.awk
@@ -0,0 +1,147 @@
+#! /usr/bin/awk -f
+# $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
+#
+# Copyright (c) 1998 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This model includes software developed by Christopher G. Demetriou.
+# This model includes software developed by Christos Zoulas
+# 4. The name of the author(s) may not be used to endorse or promote models
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+function collectline(f, line) {
+ oparen = 0
+ line = ""
+ while (f <= NF) {
+ if ($f == "#") {
+ line = line "("
+ oparen = 1
+ f++
+ continue
+ }
+ if (oparen) {
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ continue
+ }
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ }
+ if (oparen)
+ line = line ")"
+ return line
+}
+BEGIN {
+ nmodels = nouis = 0
+ hfile="miidevs.h"
+}
+NR == 1 {
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
+ printf("/*\n") > hfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > hfile
+ printf(" *\n") > hfile
+ printf(" * generated from:\n") > hfile
+ printf(" *\t%s\n", VERSION) > hfile
+ printf(" */\n") > hfile
+
+ next
+}
+$1 == "oui" {
+ nuios++
+
+ ouiindex[$2] = nouis; # record index for this name, for later.
+
+ ouis[nouis, 1] = $2; # name
+ ouis[nouis, 2] = $3; # id
+ printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
+ ouis[nouis, 2]) > hfile
+ ouis[nouis, 3] = collectline(4, line)
+ printf("/* %s */\n", ouis[nouis, 3]) > hfile
+ next
+}
+$1 == "model" {
+ nmodels++
+
+ models[nmodels, 1] = $2; # oui name
+ models[nmodels, 2] = $3; # model id
+ models[nmodels, 3] = $4; # id
+
+ printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
+ models[nmodels, 2], models[nmodels, 3]) > hfile
+
+ models[nmodels, 4] = collectline(5, line)
+
+ printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
+ models[nmodels, 1], models[nmodels, 2],
+ models[nmodels, 4]) > hfile
+
+ next
+}
+{
+ print $0 > hfile
+}
diff --git a/sys/tools/pccarddevs2h.awk b/sys/tools/pccarddevs2h.awk
new file mode 100644
index 0000000..f586397
--- /dev/null
+++ b/sys/tools/pccarddevs2h.awk
@@ -0,0 +1,226 @@
+#! /usr/bin/awk -f
+# $NetBSD: devlist2h.awk,v 1.3 1998/09/05 14:42:06 christos Exp $
+# $FreeBSD$
+#
+# Copyright (c) 1998 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Christopher G. Demetriou.
+# This product includes software developed by Christos Zoulas
+# 4. The name of the author(s) may not be used to endorse or promote products
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+function collectline(f, line) {
+ oparen = 0
+ line = ""
+ while (f <= NF) {
+ if ($f == "#") {
+ line = line "("
+ oparen = 1
+ f++
+ continue
+ }
+ if (oparen) {
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ continue
+ }
+ line = line $f
+ if (f < NF)
+ line = line " "
+ f++
+ }
+ if (oparen)
+ line = line ")"
+ return line
+}
+BEGIN {
+ nproducts = nvendors = 0
+ dfile="pccarddevs_data.h"
+ hfile="pccarddevs.h"
+}
+NR == 1 {
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
+ printf("/*\n") > dfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > dfile
+ printf(" *\n") > dfile
+ printf(" * generated from:\n") > dfile
+ printf(" *\t%s\n", VERSION) > dfile
+ printf(" */\n") > dfile
+
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
+ printf("/*\n") > hfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > hfile
+ printf(" *\n") > hfile
+ printf(" * generated from:\n") > hfile
+ printf(" *\t%s\n", VERSION) > hfile
+ printf(" */\n") > hfile
+
+ next
+}
+$1 == "vendor" {
+ nvendors++
+
+ vendorindex[$2] = nvendors; # record index for this name, for later.
+ vendors[nvendors, 1] = $2; # name
+ vendors[nvendors, 2] = $3; # id
+ printf("#define\tPCCARD_VENDOR_%s\t%s\t", vendors[nvendors, 1],
+ vendors[nvendors, 2]) > hfile
+ vendors[nvendors, 3] = collectline(4, line)
+ printf("/* %s */\n", vendors[nvendors, 3]) > hfile
+ next
+}
+$1 == "product" {
+ nproducts++
+
+ products[nproducts, 1] = $2; # vendor name
+ products[nproducts, 2] = $3; # product id
+ products[nproducts, 3] = $4; # id
+
+ f = 5;
+
+ if ($4 == "{") {
+ products[nproducts, 3] = -1
+ z = "{ "
+ for (i = 0; i < 4; i++) {
+ if (f <= NF) {
+ gsub("&sp", " ", $f)
+ gsub("&tab", "\t", $f)
+ gsub("&nl", "\n", $f)
+ z = z $f " "
+ f++
+ }
+ else {
+ if (i == 3)
+ z = z "NULL "
+ else
+ z = z "NULL, "
+ }
+ }
+ products[nproducts, 4] = z $f
+ f++
+ }
+ else {
+ products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }"
+ }
+ printf("#define\tPCCARD_CIS_%s_%s\t%s\n",
+ products[nproducts, 1], products[nproducts, 2],
+ products[nproducts, 4]) > hfile
+ printf("#define\tPCCARD_PRODUCT_%s_%s\t%s\n", products[nproducts, 1],
+ products[nproducts, 2], products[nproducts, 3]) > hfile
+
+ products[nproducts, 5] = collectline(f, line)
+
+ printf("#define\tPCCARD_STR_%s_%s\t\"%s\"\n",
+ products[nproducts, 1], products[nproducts, 2],
+ products[nproducts, 5]) > hfile
+
+ next
+}
+{
+ if ($0 == "")
+ blanklines++
+ print $0 > hfile
+ if (blanklines < 2)
+ print $0 > dfile
+}
+END {
+ # print out the match tables
+
+ printf("\n") > dfile
+
+ printf("struct pccard_knowndev pccard_knowndevs[] = {\n") > dfile
+ for (i = 1; i <= nproducts; i++) {
+ printf("\t{\n") > dfile
+ if (products[i, 3] == -1) {
+ printf("\t PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_%s_%s,\n",
+ products[i, 1], products[i, 2]) > dfile
+ } else {
+ printf("\t PCCARD_VENDOR_%s, PCCARD_PRODUCT_%s_%s,\n",
+ products[i, 1], products[i, 1], products[i, 2]) > dfile
+ }
+ printf("\t PCCARD_CIS_%s_%s,\n",
+ products[i, 1], products[i, 2]) > dfile
+ printf("\t ") > dfile
+ printf("0") > dfile
+ printf(",\n") > dfile
+
+ vendi = vendorindex[products[i, 1]];
+ printf("\t \"%s\",\n", vendors[vendi, 3]) > dfile
+ printf("\t \"%s\"\t},\n", products[i, 5]) > dfile
+ printf("\t},\n") > dfile
+ }
+ for (i = 1; i <= nvendors; i++) {
+ printf("\t{\n") > dfile
+ printf("\t PCCARD_VENDOR_%s, 0,\n", vendors[i, 1]) > dfile
+ printf("\t PCCARD_KNOWNDEV_NOPROD,\n") > dfile
+ printf("\t PCCARD_CIS_INVALID,\n") > dfile
+ printf("\t \"%s\",\n", vendors[i, 3]) > dfile
+ printf("\t NULL,\n") > dfile
+ printf("\t},\n") > dfile
+ }
+ printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile
+ printf("};\n") > dfile
+}
diff --git a/sys/tools/usbdevs2h.awk b/sys/tools/usbdevs2h.awk
new file mode 100644
index 0000000..6b99b3d
--- /dev/null
+++ b/sys/tools/usbdevs2h.awk
@@ -0,0 +1,236 @@
+#! /usr/bin/awk -f
+# $NetBSD: devlist2h.awk,v 1.6 1999/08/17 16:06:20 augustss Exp $
+# $FreeBSD$
+#
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Christopher G. Demetriou.
+# 4. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+BEGIN {
+ nproducts = nvendors = 0
+ dfile="usbdevs_data.h"
+ hfile="usbdevs.h"
+}
+NR == 1 {
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+
+ if (os == "NetBSD")
+ printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
+ else if (os == "FreeBSD")
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
+ else if (os == "OpenBSD")
+ printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
+ else
+ printf("/* ??? */\n\n") > dfile
+ printf("/*\n") > dfile
+ printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > dfile
+ printf(" *\n") > dfile
+ printf(" * generated from:\n") > dfile
+ printf(" *\t%s\n", VERSION) > dfile
+ printf(" */\n") > dfile
+
+ if (os == "NetBSD")
+ printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
+ else if (os == "FreeBSD")
+ printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
+ else if (os == "OpenBSD")
+ printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
+ else
+ printf("/* ??? */\n\n") > hfile
+ printf("/*\n") > hfile
+ printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > hfile
+ printf(" *\n") > hfile
+ printf(" * generated from:\n") > hfile
+ printf(" *\t%s\n", VERSION) > hfile
+ printf(" */\n") > hfile
+
+ next
+}
+$1 == "vendor" {
+ nvendors++
+
+ vendorindex[$2] = nvendors; # record index for this name, for later.
+ vendors[nvendors, 1] = $2; # name
+ vendors[nvendors, 2] = $3; # id
+ printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
+ vendors[nvendors, 2]) > hfile
+
+ i = 3; f = 4;
+
+ # comments
+ ocomment = oparen = 0
+ if (f <= NF) {
+ printf("\t/* ") > hfile
+ ocomment = 1;
+ }
+ while (f <= NF) {
+ if ($f == "#") {
+ printf("(") > hfile
+ oparen = 1
+ f++
+ continue
+ }
+ if (oparen) {
+ printf("%s", $f) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ f++
+ continue
+ }
+ vendors[nvendors, i] = $f
+ printf("%s", vendors[nvendors, i]) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ i++; f++;
+ }
+ if (oparen)
+ printf(")") > hfile
+ if (ocomment)
+ printf(" */") > hfile
+ printf("\n") > hfile
+
+ next
+}
+$1 == "product" {
+ nproducts++
+
+ products[nproducts, 1] = $2; # vendor name
+ products[nproducts, 2] = $3; # product id
+ products[nproducts, 3] = $4; # id
+ printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
+ products[nproducts, 2], products[nproducts, 3]) > hfile
+
+ i=4; f = 5;
+
+ # comments
+ ocomment = oparen = 0
+ if (f <= NF) {
+ printf("\t/* ") > hfile
+ ocomment = 1;
+ }
+ while (f <= NF) {
+ if ($f == "#") {
+ printf("(") > hfile
+ oparen = 1
+ f++
+ continue
+ }
+ if (oparen) {
+ printf("%s", $f) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ f++
+ continue
+ }
+ products[nproducts, i] = $f
+ printf("%s", products[nproducts, i]) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ i++; f++;
+ }
+ if (oparen)
+ printf(")") > hfile
+ if (ocomment)
+ printf(" */") > hfile
+ printf("\n") > hfile
+
+ next
+}
+{
+ if ($0 == "")
+ blanklines++
+ print $0 > hfile
+ if (blanklines < 2)
+ print $0 > dfile
+}
+END {
+ # print out the match tables
+
+ printf("\n") > dfile
+
+ printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
+ for (i = 1; i <= nproducts; i++) {
+ printf("\t{\n") > dfile
+ printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
+ products[i, 1], products[i, 1], products[i, 2]) \
+ > dfile
+ printf("\t ") > dfile
+ printf("0") > dfile
+ printf(",\n") > dfile
+
+ vendi = vendorindex[products[i, 1]];
+ printf("\t \"") > dfile
+ j = 3;
+ needspace = 0;
+ while (vendors[vendi, j] != "") {
+ if (needspace)
+ printf(" ") > dfile
+ printf("%s", vendors[vendi, j]) > dfile
+ needspace = 1
+ j++
+ }
+ printf("\",\n") > dfile
+
+ printf("\t \"") > dfile
+ j = 4;
+ needspace = 0;
+ while (products[i, j] != "") {
+ if (needspace)
+ printf(" ") > dfile
+ printf("%s", products[i, j]) > dfile
+ needspace = 1
+ j++
+ }
+ printf("\",\n") > dfile
+ printf("\t},\n") > dfile
+ }
+ for (i = 1; i <= nvendors; i++) {
+ printf("\t{\n") > dfile
+ printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
+ > dfile
+ printf("\t USB_KNOWNDEV_NOPROD,\n") \
+ > dfile
+ printf("\t \"") > dfile
+ j = 3;
+ needspace = 0;
+ while (vendors[i, j] != "") {
+ if (needspace)
+ printf(" ") > dfile
+ printf("%s", vendors[i, j]) > dfile
+ needspace = 1
+ j++
+ }
+ printf("\",\n") > dfile
+ printf("\t NULL,\n") > dfile
+ printf("\t},\n") > dfile
+ }
+ printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
+ printf("};\n") > dfile
+}
diff --git a/sys/tools/vnode_if.awk b/sys/tools/vnode_if.awk
new file mode 100644
index 0000000..f8675cd
--- /dev/null
+++ b/sys/tools/vnode_if.awk
@@ -0,0 +1,354 @@
+#!/usr/bin/perl
+eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+#
+# Copyright (c) 1992, 1993
+# The Regents of the University of California. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
+# $FreeBSD$
+#
+# Script to produce VFS front-end sugar.
+#
+# usage: vnode_if.sh srcfile
+# (where srcfile is currently /sys/kern/vnode_if.src)
+#
+
+my %lockdata;
+
+$cfile = 0;
+$hfile = 0;
+
+# Process the command line
+#
+while ($arg = shift @ARGV) {
+ if ($arg eq '-c') {
+ $cfile = 1;
+ } elsif ($arg eq '-h') {
+ $hfile = 1;
+ } elsif ($arg eq '-ch' || $arg eq '-hc') {
+ $cfile = 1;
+ $hfile = 1;
+ } elsif ($arg =~ m/\.src$/) {
+ $SRC = $arg;
+ } else {
+ print "usage: vnode_if.sh [-c] [-h] srcfile\n";
+ exit(1);
+ }
+}
+if (!$cfile and !$hfile) {
+ exit(0); # nothing asked for..
+}
+
+# Names of the created files.
+$CFILE='vnode_if.c';
+$HEADER='vnode_if.h';
+
+open(SRC, "<$SRC") || die "Unable to open input file";
+
+if ($hfile) {
+ open(HEADER, ">$HEADER") || die "Unable to create $HEADER";
+ # Print out header information for vnode_if.h.
+ print HEADER <<END_OF_LEADING_COMMENT
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
+ */
+
+extern struct vnodeop_desc vop_default_desc;
+END_OF_LEADING_COMMENT
+ ;
+}
+
+if ($cfile) {
+ open(CFILE, ">$CFILE") || die "Unable to create $CFILE";
+ # Print out header information for vnode_if.c.
+ print CFILE <<END_OF_LEADING_COMMENT
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/vnode.h>
+
+struct vnodeop_desc vop_default_desc = {
+ 1, /* special case, vop_default => 1 */
+ "default",
+ 0,
+ NULL,
+ VDESC_NO_OFFSET,
+ VDESC_NO_OFFSET,
+ VDESC_NO_OFFSET,
+ VDESC_NO_OFFSET,
+ NULL,
+};
+
+END_OF_LEADING_COMMENT
+ ;
+}
+
+line: while (<SRC>) {
+ chop; # strip record separator
+ @Fld = split ' ';
+ if (@Fld == 0) {
+ next line;
+ }
+ if (/^#/) {
+ if (!/^#%\s+([a-z]+)\s+([a-z]+)\s+(.)\s(.)\s(.)/) {
+ next;
+ }
+ if (!defined($lockdata{"vop_$1"})) {
+ $lockdata{"vop_$1"} = {};
+ }
+ $lockdata{"vop_$1"}->{$2} = {
+ 'Entry' => $3,
+ 'OK' => $4,
+ 'Error' => $5,
+ };
+ next;
+ }
+
+ # Get the function name.
+ $name = $Fld[0];
+ $uname = uc($name);
+
+ # Get the function arguments.
+ for ($numargs = 0; ; ++$numargs) {
+ if ($ln = <SRC>) {
+ chomp;
+ } else {
+ die "Unable to read through the arguments for \"$name\"";
+ }
+ if ($ln =~ /^\};/) {
+ last;
+ }
+ # For the header file
+ $a{$numargs} = $ln;
+
+ # The rest of this loop is for the C file
+ # Delete comments, if any.
+ $ln =~ s/\/\*.*\*\///g;
+
+ # Delete leading/trailing space.
+ $ln =~ s/^\s*(.*?)\s*$/$1/;
+
+ # Pick off direction.
+ if ($ln =~ s/^INOUT\s+//) {
+ $dir = 'INOUT';
+ } elsif ($ln =~ s/^IN\s+//) {
+ $dir = 'IN';
+ } elsif ($ln =~ s/^OUT\s+//) {
+ $dir = 'OUT';
+ } else {
+ die "No IN/OUT direction for \"$ln\".";
+ }
+ if ($ln =~ s/^WILLRELE\s+//) {
+ $rele = 'WILLRELE';
+ } else {
+ $rele = 'WONTRELE';
+ }
+
+ # kill trailing ;
+ if ($ln !~ s/;$//) {
+ &bail("Missing end-of-line ; in \"$ln\".");
+ }
+
+ # pick off variable name
+ if ($ln !~ s/([A-Za-z0-9_]+)$//) {
+ &bail("Missing var name \"a_foo\" in \"$ln\".");
+ }
+ $arg = $1;
+
+ # what is left must be type
+ # (put clean it up some)
+ $type = $ln;
+ # condense whitespace
+ $type =~ s/\s+/ /g;
+ $type =~ s/^\s*(.*?)\s*$/$1/;
+
+ $dirs{$numargs} = $dir;
+ $reles{$numargs} = $rele;
+ $types{$numargs} = $type;
+ $args{$numargs} = $arg;
+ }
+
+ if ($hfile) {
+ # Print out the vop_F_args structure.
+ print HEADER "struct ${name}_args {\n\tstruct vnodeop_desc *a_desc;\n";
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**)(\S*\;)/;
+ print HEADER "\t$3 $4a_$5\n",
+ }
+ print HEADER "};\n";
+
+ # Print out extern declaration.
+ print HEADER "extern struct vnodeop_desc ${name}_desc;\n";
+
+ # Print out prototype.
+ print HEADER "static __inline int ${uname} __P((\n";
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**\S*)\;/;
+ print HEADER "\t$3 $4" .
+ ($c2 < $numargs-1 ? "," : "));") . "\n";
+ }
+
+ # Print out function.
+ print HEADER "static __inline int ${uname}(";
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ $a{$c2} =~ /\**([^;\s]*)\;[^\s]*$/;
+ print HEADER "$1" . ($c2 < $numargs - 1 ? ', ' : ")\n");
+ }
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**\S*\;)/;
+ print HEADER "\t$3 $4\n";
+ }
+ print HEADER "{\n\tstruct ${name}_args a;\n";
+ print HEADER "\tint rc;\n";
+ print HEADER "\ta.a_desc = VDESC(${name});\n";
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ $a{$c2} =~ /(\**)([^;\s]*)([^\s]*)$/;
+ print HEADER "\ta.a_$2 = $2$3\n",
+ }
+ for ($c2 = 0; $c2 < $numargs; ++$c2) {
+ if (!exists($args{$c2})) {
+ die "Internal error";
+ }
+ if (exists($lockdata{$name}) &&
+ exists($lockdata{$name}->{$args{$c2}})) {
+ if ($ENV{'DEBUG_ALL_VFS_LOCKS'} =~ /yes/i) {
+ # Add assertions for locking
+ if ($lockdata{$name}->{$args{$c2}}->{Entry} eq "L") {
+ print HEADER
+ "\tASSERT_VOP_LOCKED($args{$c2}, \"$uname\");\n";
+ } elsif ($lockdata{$name}->{$args{$c2}}->{Entry} eq "U") {
+ print HEADER
+ "\tASSERT_VOP_UNLOCKED($args{$c2}, \"$uname\");\n";
+ } elsif (0) {
+ # XXX More checks!
+ }
+ }
+ }
+ }
+ $a{0} =~ /\s\**([^;\s]*);/;
+ print HEADER "\trc = VCALL($1, VOFFSET(${name}), &a);\n";
+ print HEADER "\treturn (rc);\n";
+ print HEADER "}\n";
+ }
+
+
+ if ($cfile) {
+ # Print out the vop_F_vp_offsets structure. This all depends
+ # on naming conventions and nothing else.
+ printf CFILE "static int %s_vp_offsets[] = {\n", $name;
+ # as a side effect, figure out the releflags
+ $releflags = '';
+ $vpnum = 0;
+ for ($i = 0; $i < $numargs; $i++) {
+ if ($types{$i} eq 'struct vnode *') {
+ printf CFILE "\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n",
+ $name, $args{$i};
+ if ($reles{$i} eq 'WILLRELE') {
+ $releflags = $releflags . '|VDESC_VP' . $vpnum . '_WILLRELE';
+ }
+
+ $vpnum++;
+ }
+ }
+
+ $releflags =~ s/^\|//;
+ print CFILE "\tVDESC_NO_OFFSET\n";
+ print CFILE "};\n";
+
+ # Print out the vnodeop_desc structure.
+ print CFILE "struct vnodeop_desc ${name}_desc = {\n";
+ # offset
+ print CFILE "\t0,\n";
+ # printable name
+ printf CFILE "\t\"%s\",\n", $name;
+ # flags
+ $vppwillrele = '';
+ for ($i = 0; $i < $numargs; $i++) {
+ if ($types{$i} eq 'struct vnode **' &&
+ ($reles{$i} eq 'WILLRELE')) {
+ $vppwillrele = '|VDESC_VPP_WILLRELE';
+ }
+ }
+
+ if ($releflags eq '') {
+ printf CFILE "\t0%s,\n", $vppwillrele;
+ }
+ else {
+ printf CFILE "\t%s%s,\n", $releflags, $vppwillrele;
+ }
+
+ # vp offsets
+ printf CFILE "\t%s_vp_offsets,\n", $name;
+ # vpp (if any)
+ printf CFILE "\t%s,\n", &find_arg_with_type('struct vnode **');
+ # cred (if any)
+ printf CFILE "\t%s,\n", &find_arg_with_type('struct ucred *');
+ # proc (if any)
+ printf CFILE "\t%s,\n", &find_arg_with_type('struct proc *');
+ # componentname
+ printf CFILE "\t%s,\n", &find_arg_with_type('struct componentname *');
+ # transport layer information
+ print CFILE "\tNULL,\n};\n\n";
+ }
+}
+
+if ($hfile) {
+ close(HEADER) || die "Unable to close $HEADER";
+}
+if ($cfile) {
+ close(CFILE) || die "Unable to close $CFILE";
+}
+close(SRC) || die;
+
+exit 0;
+
+sub find_arg_with_type {
+ my $type = shift;
+ my $i;
+
+ for ($i=0; $i < $numargs; $i++) {
+ if ($types{$i} eq $type) {
+ return "VOPARG_OFFSETOF(struct ${name}_args,a_" . $args{$i} . ")";
+ }
+ }
+
+ return "VDESC_NO_OFFSET";
+}
OpenPOWER on IntegriCloud