Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/mii Allow a verbose description to be printed with t...



details:   https://anonhg.NetBSD.org/src/rev/45f3f73be9a1
branches:  trunk
changeset: 485885:45f3f73be9a1
user:      augustss <augustss%NetBSD.org@localhost>
date:      Mon May 08 13:25:34 2000 +0000

description:
Allow a verbose description to be printed with the option MIIVERBOSE.

diffstat:

 sys/dev/mii/Makefile.miidevs |   5 +++--
 sys/dev/mii/devlist2h.awk    |  28 +++++++++++++++++++++++++++-
 sys/dev/mii/ukphy.c          |  34 ++++++++++++++++++++++++++++++----
 3 files changed, 60 insertions(+), 7 deletions(-)

diffs (130 lines):

diff -r fbfc6bdfbbed -r 45f3f73be9a1 sys/dev/mii/Makefile.miidevs
--- a/sys/dev/mii/Makefile.miidevs      Mon May 08 13:23:21 2000 +0000
+++ b/sys/dev/mii/Makefile.miidevs      Mon May 08 13:25:34 2000 +0000
@@ -1,7 +1,8 @@
-#      $NetBSD: Makefile.miidevs,v 1.1 1998/08/10 23:55:17 thorpej Exp $
+#      $NetBSD: Makefile.miidevs,v 1.2 2000/05/08 13:25:34 augustss Exp $
 
+RM=    rm
 AWK=   awk
 
 miidevs.h: miidevs devlist2h.awk
-       /bin/rm -f miidevs.h
+       ${RM} -f miidevs.h miidevs_data.h
        ${AWK} -f devlist2h.awk miidevs
diff -r fbfc6bdfbbed -r 45f3f73be9a1 sys/dev/mii/devlist2h.awk
--- a/sys/dev/mii/devlist2h.awk Mon May 08 13:23:21 2000 +0000
+++ b/sys/dev/mii/devlist2h.awk Mon May 08 13:25:34 2000 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#      $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
+#      $NetBSD: devlist2h.awk,v 1.3 2000/05/08 13:25:35 augustss Exp $
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -93,6 +93,7 @@
 BEGIN {
        nmodels = nouis = 0
        hfile="miidevs.h"
+       dfile="miidevs_data.h"
 }
 NR == 1 {
        VERSION = $0
@@ -107,6 +108,15 @@
        printf(" *\t%s\n", VERSION) > hfile
        printf(" */\n") > hfile
 
+       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
+       printf(" *\t%s\n", VERSION) > dfile
+       printf(" */\n") > dfile
+
        next
 }
 $1 == "oui" {
@@ -138,8 +148,24 @@
            models[nmodels, 1], models[nmodels, 2],
            models[nmodels, 4]) > hfile
 
+       if (!firstdone) {
+               printf("struct mii_knowndev mii_knowndevs[] = {\n") > dfile
+               firstdone = 1
+       }
+
+       printf(" { MII_OUI_%s, MII_MODEL_%s_%s, MII_STR_%s_%s }, \n",
+              $2, $2, $3, $2, $3) > dfile
+
        next
 }
 {
+       if ($0 == "")
+               blanklines++
        print $0 > hfile
+       if (blanklines < 2)
+               print $0 > dfile
 }
+END {
+       printf(" { 0, 0, NULL }\n") > dfile
+       printf("};\n") > dfile
+}
diff -r fbfc6bdfbbed -r 45f3f73be9a1 sys/dev/mii/ukphy.c
--- a/sys/dev/mii/ukphy.c       Mon May 08 13:23:21 2000 +0000
+++ b/sys/dev/mii/ukphy.c       Mon May 08 13:25:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ukphy.c,v 1.10 2000/03/06 20:56:57 thorpej Exp $       */
+/*     $NetBSD: ukphy.c,v 1.11 2000/05/08 13:25:35 augustss Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -84,6 +84,16 @@
 #include <dev/mii/mii.h>
 #include <dev/mii/miivar.h>
 
+#ifdef MIIVERBOSE
+struct mii_knowndev {
+       int oui;
+       int model;
+       const char *descr;
+};
+#include <dev/mii/miidevs.h>
+#include <dev/mii/miidevs_data.h>
+#endif
+
 int    ukphymatch __P((struct device *, struct cfdata *, void *));
 void   ukphyattach __P((struct device *, struct device *, void *));
 
@@ -115,11 +125,27 @@
        struct mii_softc *sc = (struct mii_softc *)self;
        struct mii_attach_args *ma = aux;
        struct mii_data *mii = ma->mii_data;
+       int oui = MII_OUI(ma->mii_id1, ma->mii_id2);
+       int model = MII_MODEL(ma->mii_id2);
+       int rev = MII_REV(ma->mii_id2);
+#ifdef MIIVERBOSE
+       int i;
+#endif
 
        printf(": Generic IEEE 802.3u media interface\n");
-       printf("%s: OUI 0x%06x, model 0x%04x, rev. %d\n",
-           sc->mii_dev.dv_xname, MII_OUI(ma->mii_id1, ma->mii_id2),
-           MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
+#ifdef MIIVERBOSE
+       for (i = 0; mii_knowndevs[i].descr != NULL; i++)
+               if (mii_knowndevs[i].oui == oui &&
+                   mii_knowndevs[i].model == model)
+                       break;
+       if (mii_knowndevs[i].descr != NULL)
+               printf("%s: %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
+                      sc->mii_dev.dv_xname, mii_knowndevs[i].descr,
+                      oui, model, rev);
+       else
+#endif
+               printf("%s: OUI 0x%06x, model 0x%04x, rev. %d\n",
+                      sc->mii_dev.dv_xname, oui, model, rev);
 
        sc->mii_inst = mii->mii_instance;
        sc->mii_phy = ma->mii_phyno;



Home | Main Index | Thread Index | Old Index