Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Merge the 3 copies of devlist2h.awk that deal with 1...
details: https://anonhg.NetBSD.org/src/rev/cb018b6d4b8d
branches: trunk
changeset: 332432:cb018b6d4b8d
user: christos <christos%NetBSD.org@localhost>
date: Sun Sep 21 14:30:22 2014 +0000
description:
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
diffstat:
sys/dev/dev_verbose.c | 94 +++++++++++
sys/dev/dev_verbose.h | 145 ++++++++++++++++++
sys/dev/devlist2h.awk | 245 +++++++++++++++++++++++++++++++
sys/dev/pci/Makefile.pcidevs | 6 +-
sys/dev/pci/azalia.c | 23 +-
sys/dev/pci/cs4280.c | 23 +-
sys/dev/pci/devlist2h.awk | 244 ------------------------------
sys/dev/pci/ehci_pci.c | 14 +-
sys/dev/pci/hdaudio/Makefile.hdaudiodevs | 24 +-
sys/dev/pci/hdaudio/devlist2h.awk | 227 ----------------------------
sys/dev/pci/hdaudio/hdafg.c | 12 +-
sys/dev/pci/hdaudio/hdaudio.c | 45 +-----
sys/dev/pci/hdaudio/hdaudio_verbose.c | 80 +---------
sys/dev/pci/hdaudio/hdaudio_verbose.h | 17 +-
sys/dev/pci/ohci_pci.c | 14 +-
sys/dev/pci/pci_subr.c | 97 ++----------
sys/dev/pci/pci_verbose.c | 139 ++---------------
sys/dev/pci/pci_verbose.h | 49 ++---
sys/dev/pci/uhci_pci.c | 14 +-
sys/dev/pci/xhci_pci.c | 12 +-
sys/dev/usb/Makefile.usbdevs | 24 +-
sys/dev/usb/devlist2h.awk | 227 ----------------------------
sys/dev/usb/usb_subr.c | 48 +-----
sys/dev/usb/usb_verbose.c | 83 +---------
sys/dev/usb/usb_verbose.h | 17 +-
25 files changed, 625 insertions(+), 1298 deletions(-)
diffs (truncated from 2429 to 300 lines):
diff -r 7cb0d55a5d63 -r cb018b6d4b8d sys/dev/dev_verbose.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/dev_verbose.c Sun Sep 21 14:30:22 2014 +0000
@@ -0,0 +1,94 @@
+/* $NetBSD: dev_verbose.c,v 1.1 2014/09/21 14:30:22 christos Exp $ */
+
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: dev_verbose.c,v 1.1 2014/09/21 14:30:22 christos Exp $");
+
+#include <sys/param.h>
+
+#ifdef _KERNEL
+#include <sys/systm.h>
+#else
+#include <stdio.h>
+#include <string.h>
+#endif
+
+#include <dev/dev_verbose.h>
+
+static const char *
+dev_untokenstring(const char *words, const uint16_t *token, char *buf,
+ size_t len)
+{
+ char *cp = buf;
+
+ buf[0] = '\0';
+ for (; *token != 0; token++) {
+ cp = buf + strlcat(buf, words + *token, len - 2);
+ cp[0] = ' ';
+ cp[1] = '\0';
+ }
+ *cp = '\0';
+ return cp != buf ? buf : NULL;
+}
+
+const char *
+dev_findvendor(char *buf, size_t len, const char *words, size_t nwords,
+ const uint16_t *vendors, size_t nvendors, uint16_t vendor)
+{
+ size_t n;
+
+ for (n = 0; n < nvendors; n++) {
+ if (vendors[n] == vendor)
+ return dev_untokenstring(words, &vendors[n + 1],
+ buf, len);
+
+ /* Skip Tokens */
+ n++;
+ while (vendors[n] != 0 && n < nvendors)
+ n++;
+ }
+ snprintf(buf, len, "vendor %4.4x", vendor);
+ return NULL;
+}
+
+const char *
+dev_findproduct(char *buf, size_t len, const char *words, size_t nwords,
+ const uint16_t *products, size_t nproducts, uint16_t vendor,
+ uint16_t product)
+{
+ size_t n;
+
+ for (n = 0; n < nproducts; n++) {
+ if (products[n] == vendor && products[n + 1] == product)
+ return dev_untokenstring(words, &products[n + 2],
+ buf, len);
+
+ /* Skip Tokens */
+ n += 2;
+ while (products[n] != 0 && n < nproducts)
+ n++;
+ }
+ snprintf(buf, len, "product %4.4x", product);
+ return NULL;
+}
diff -r 7cb0d55a5d63 -r cb018b6d4b8d sys/dev/dev_verbose.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/dev_verbose.h Sun Sep 21 14:30:22 2014 +0000
@@ -0,0 +1,145 @@
+/* $NetBSD: dev_verbose.h,v 1.1 2014/09/21 14:30:22 christos Exp $ */
+
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+#ifndef _DEV_DEV_VERBOSE_H_
+#define _DEV_DEV_VERBOSE_H_
+
+const char *dev_findvendor(char *, size_t, const char *, size_t,
+ const uint16_t *, size_t, uint16_t);
+const char *dev_findproduct(char *, size_t, const char *, size_t,
+ const uint16_t *, size_t, uint16_t, uint16_t);
+
+#define DEV_VERBOSE_COMMON_DEFINE(tag) \
+static const char * \
+tag ## _findvendor_real(char *buf, size_t len, uint16_t vendor) \
+{ \
+ return dev_findvendor(buf, len, tag ## _words, \
+ __arraycount(tag ## _words), tag ## _vendors, \
+ __arraycount(tag ## _vendors), vendor); \
+} \
+ \
+static const char * \
+tag ## _findproduct_real(char *buf, size_t len, uint16_t vendor, \
+ uint16_t product) \
+{ \
+ return dev_findproduct(buf, len, tag ## _words, \
+ __arraycount(tag ## _words), tag ## _products, \
+ __arraycount(tag ## _products), vendor, product); \
+} \
+
+#ifdef _KERNEL
+
+#define DEV_VERBOSE_MODULE_DEFINE(tag, deps) \
+DEV_VERBOSE_COMMON_DEFINE(tag) \
+extern int tag ## verbose_loaded; \
+ \
+static int \
+tag ## verbose_modcmd(modcmd_t cmd, void *arg) \
+{ \
+ static const char *(*saved_findvendor)(char *, size_t, \
+ uint16_t); \
+ static const char *(*saved_findproduct)(char *, size_t, \
+ uint16_t, uint16_t); \
+ \
+ switch (cmd) { \
+ case MODULE_CMD_INIT: \
+ saved_findvendor = tag ## _findvendor; \
+ saved_findproduct = tag ## _findproduct; \
+ tag ## _findvendor = tag ## _findvendor_real; \
+ tag ## _findproduct = tag ## _findproduct_real; \
+ tag ## verbose_loaded = 1; \
+ return 0; \
+ case MODULE_CMD_FINI: \
+ tag ## _findvendor = saved_findvendor; \
+ tag ## _findproduct = saved_findproduct; \
+ tag ## verbose_loaded = 0; \
+ return 0; \
+ default: \
+ return ENOTTY; \
+ } \
+} \
+MODULE(MODULE_CLASS_MISC, tag ## verbose, deps)
+
+#endif /* KERNEL */
+
+#define DEV_VERBOSE_DECLARE(tag) \
+extern const char * (*tag ## _findvendor)(char *, size_t, uint16_t); \
+extern const char * (*tag ## _findproduct)(char *, size_t, uint16_t, uint16_t)
+
+#if defined(_KERNEL)
+#define DEV_VERBOSE_DEFINE(tag) \
+int tag ## verbose_loaded = 0; \
+ \
+static void \
+tag ## _load_verbose(void) \
+{ \
+ \
+ if (tag ## verbose_loaded == 0) \
+ module_autoload(# tag "verbose", MODULE_CLASS_MISC); \
+} \
+ \
+static const char * \
+tag ## _findvendor_stub(char *buf, size_t len, uint16_t vendor) \
+{ \
+ \
+ tag ## _load_verbose(); \
+ if (tag ## verbose_loaded) \
+ return tag ## _findvendor(buf, len, vendor); \
+ else { \
+ snprintf(buf, len, "vendor %4.4x", vendor); \
+ return NULL; \
+ } \
+} \
+ \
+static const char * \
+tag ## _findproduct_stub(char *buf, size_t len, uint16_t vendor, \
+ uint16_t product) \
+{ \
+ \
+ tag ## _load_verbose(); \
+ if (tag ## verbose_loaded) \
+ return tag ## _findproduct(buf, len, vendor, product); \
+ else { \
+ snprintf(buf, len, "product %4.4x", product); \
+ return NULL; \
+ } \
+} \
+ \
+const char *(*tag ## _findvendor)(char *, size_t, uint16_t) = \
+ tag ## _findvendor_stub; \
+const char *(*tag ## _findproduct)(char *, size_t, uint16_t, uint16_t) =\
+ tag ## _findproduct_stub; \
+
+#else
+
+#define DEV_VERBOSE_DEFINE(tag) \
+DEV_VERBOSE_COMMON_DEFINE(tag) \
+const char *(*tag ## _findvendor)(char *, size_t, uint16_t) = \
+ tag ## _findvendor_real; \
+const char *(*tag ## _findproduct)(char *, size_t, uint16_t, uint16_t) =\
+ tag ## _findproduct_real; \
+
+#endif /* _KERNEL */
+
+#endif /* _DEV_DEV_VERBOSE_H_ */
diff -r 7cb0d55a5d63 -r cb018b6d4b8d sys/dev/devlist2h.awk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/devlist2h.awk Sun Sep 21 14:30:22 2014 +0000
@@ -0,0 +1,245 @@
+#! /usr/bin/awk -f
+# $NetBSD: devlist2h.awk,v 1.1 2014/09/21 14:30:22 christos Exp $
+#
+# 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.
+#
+NR == 1 {
+ nproducts = nvendors = blanklines = 0
+ nchars = 1
+ dfile= FILENAME "_data.h"
+ hfile= FILENAME ".h"
+ prefix = FILENAME
+ gsub("devs", "", prefix)
+ PREFIX = toupper(prefix)
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+ gsub(/ $/, "", VERSION)
+
+ printf("/*\t$NetBSD" "$\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
Home |
Main Index |
Thread Index |
Old Index