Module Name:    src
Committed By:   pgoyette
Date:           Sun May 30 17:44:08 UTC 2010

Modified Files:
        src/distrib/sets/lists/modules: mi
        src/sys/dev/mii: files.mii miivar.h ukphy.c
        src/sys/modules: Makefile
Added Files:
        src/sys/dev/mii: mii_verbose.c mii_verbose.h
        src/sys/modules/miiverbose: Makefile

Log Message:
Extract MIIVERBOSE into a kernel module.  The module can be builtin
by defining 'options MIIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/mii/files.mii
cvs rdiff -u -r0 -r1.1 src/sys/dev/mii/mii_verbose.c \
    src/sys/dev/mii/mii_verbose.h
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/mii/miivar.h
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/mii/ukphy.c
cvs rdiff -u -r1.44 -r1.45 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/miiverbose/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.16 src/distrib/sets/lists/modules/mi:1.17
--- src/distrib/sets/lists/modules/mi:1.16	Sun May 30 04:38:04 2010
+++ src/distrib/sets/lists/modules/mi	Sun May 30 17:44:07 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.16 2010/05/30 04:38:04 pgoyette Exp $
+# $NetBSD: mi,v 1.17 2010/05/30 17:44:07 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -62,6 +62,8 @@
 ./@MODULEDIR@/lfs/lfs.kmod			base-kernel-modules	kmod
 ./@MODULEDIR@/mfs				base-kernel-modules	kmod
 ./@MODULEDIR@/mfs/mfs.kmod			base-kernel-modules	kmod
+./@MODULEDIR@/miiverbose			base-kernel-modules	kmod
+./@MODULEDIR@/miiverbose/miiverbose.kmod	base-kernel-modules	kmod
 ./@MODULEDIR@/miniroot				base-kernel-modules	kmod
 ./@MODULEDIR@/miniroot/miniroot.kmod		base-kernel-modules	kmod
 ./@MODULEDIR@/mqueue				base-kernel-modules	kmod

Index: src/sys/dev/mii/files.mii
diff -u src/sys/dev/mii/files.mii:1.44 src/sys/dev/mii/files.mii:1.45
--- src/sys/dev/mii/files.mii:1.44	Sun Apr 19 11:17:46 2009
+++ src/sys/dev/mii/files.mii	Sun May 30 17:44:08 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mii,v 1.44 2009/04/19 11:17:46 msaitoh Exp $
+#	$NetBSD: files.mii,v 1.45 2010/05/30 17:44:08 pgoyette Exp $
 
 defflag	opt_mii.h	MIIVERBOSE
 
@@ -12,6 +12,7 @@
 file	dev/mii/mii_physubr.c			mii_phy
 
 file	dev/mii/mii_ethersubr.c			mii & ether
+file	dev/mii/mii_verbose.c			mii & miiverbose
 
 define	ukphy_subr
 file	dev/mii/ukphy_subr.c			ukphy_subr

Index: src/sys/dev/mii/miivar.h
diff -u src/sys/dev/mii/miivar.h:1.58 src/sys/dev/mii/miivar.h:1.59
--- src/sys/dev/mii/miivar.h:1.58	Wed Feb 24 22:37:59 2010
+++ src/sys/dev/mii/miivar.h	Sun May 30 17:44:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: miivar.h,v 1.58 2010/02/24 22:37:59 dyoung Exp $	*/
+/*	$NetBSD: miivar.h,v 1.59 2010/05/30 17:44:08 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -36,6 +36,8 @@
 #include <sys/queue.h>
 #include <sys/callout.h>
 
+#include <dev/mii/mii_verbose.h>
+
 /*
  * Media Independent Interface datat structure definitions.
  */

Index: src/sys/dev/mii/ukphy.c
diff -u src/sys/dev/mii/ukphy.c:1.40 src/sys/dev/mii/ukphy.c:1.41
--- src/sys/dev/mii/ukphy.c:1.40	Thu Mar 11 04:19:56 2010
+++ src/sys/dev/mii/ukphy.c	Sun May 30 17:44:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukphy.c,v 1.40 2010/03/11 04:19:56 mrg Exp $	*/
+/*	$NetBSD: ukphy.c,v 1.41 2010/05/30 17:44:08 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.40 2010/03/11 04:19:56 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.41 2010/05/30 17:44:08 pgoyette Exp $");
 
 #include "opt_mii.h"
 
@@ -69,6 +69,7 @@
 #include <sys/device.h>
 #include <sys/socket.h>
 #include <sys/errno.h>
+#include <sys/module.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
@@ -76,19 +77,11 @@
 #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
-
 static int	ukphymatch(device_t, cfdata_t, void *);
 static void	ukphyattach(device_t, device_t, void *);
 
+const char *(*mii_get_descr)(int, int) = mii_get_descr_stub;
+
 CFATTACH_DECL3_NEW(ukphy, sizeof(struct mii_softc),
     ukphymatch, ukphyattach, mii_phy_detach, mii_phy_activate, NULL, NULL,
     DVF_DETACH_SHUTDOWN);
@@ -99,6 +92,31 @@
 	ukphy_service, ukphy_status, mii_phy_reset,
 };
 
+const char *mii_get_descr_stub(int oui, int model)
+{
+	return NULL;
+}
+
+/*    
+ * Routine to load/unload the miiverbose kernel module as needed
+ */
+void mii_verbose_ctl(bool load)
+{
+	static int loaded = 0;
+ 
+	if (load) {
+		if (loaded++ == 0)
+			if (module_load("miiverbose", MODCTL_LOAD_FORCE,
+					NULL, MODULE_CLASS_MISC) !=0 )
+				loaded = 0;
+		return; 
+	}
+	if (loaded == 0)
+		return; 
+	if (--loaded == 0)
+		module_unload("miiverbose");
+}  
+
 static int
 ukphymatch(device_t parent, cfdata_t match, void *aux)
 {
@@ -118,21 +136,13 @@
 	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
-
-#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)
+	const char *descr;
+
+	mii_verbose_ctl(true);
+	if ((descr = mii_get_descr(oui, model)) != NULL)
 		aprint_normal(": %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
-		       mii_knowndevs[i].descr,
-		       oui, model, rev);
+		       descr, oui, model, rev);
 	else
-#endif
 		aprint_normal(": OUI 0x%06x, model 0x%04x, rev. %d\n",
 		       oui, model, rev);
 	aprint_naive(": Media interface\n");

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.44 src/sys/modules/Makefile:1.45
--- src/sys/modules/Makefile:1.44	Sun May 30 04:38:03 2010
+++ src/sys/modules/Makefile	Sun May 30 17:44:07 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.44 2010/05/30 04:38:03 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.45 2010/05/30 17:44:07 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -28,6 +28,8 @@
 SUBDIR+=	layerfs
 SUBDIR+=	lfs
 SUBDIR+=	mfs
+SUBDIR+=	miiverbose
+SUBDIR+=	miniroot
 SUBDIR+=	mqueue
 SUBDIR+=	msdos
 SUBDIR+=	nfs
@@ -44,7 +46,6 @@
 SUBDIR+=	ptyfs
 SUBDIR+=	puffs
 SUBDIR+=	putter
-SUBDIR+=	miniroot
 SUBDIR+=	scsiverbose
 SUBDIR+=	secmodel_bsd44
 SUBDIR+=	secmodel_overlay

Added files:

Index: src/sys/dev/mii/mii_verbose.c
diff -u /dev/null src/sys/dev/mii/mii_verbose.c:1.1
--- /dev/null	Sun May 30 17:44:08 2010
+++ src/sys/dev/mii/mii_verbose.c	Sun May 30 17:44:07 2010
@@ -0,0 +1,99 @@
+/*	$NetBSD: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Frank van der Linden.
+ *
+ * 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 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) 1997 Manuel Bouyer.  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.
+ *
+ * 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: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $");
+
+#include <sys/module.h>
+#include <dev/mii/mii_verbose.h>
+
+struct mii_knowndev {
+	int oui;
+	int model;
+	const char *descr;
+};
+#include <dev/mii/miidevs.h>
+#include <dev/mii/miidevs_data.h>
+
+const char * mii_get_descr_real(int, int);
+
+MODULE(MODULE_CLASS_MISC, miiverbose, NULL);
+
+static int
+miiverbose_modcmd(modcmd_t cmd, void *arg)
+{
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		mii_get_descr = mii_get_descr_real;
+		return 0;
+	case MODULE_CMD_FINI:
+		mii_get_descr = mii_get_descr_stub;
+		return 0;
+	default:
+		return ENOTTY;
+	}
+} 
+
+const char *
+mii_get_descr_real(int oui, int model) {
+	int i;
+
+	for (i = 0; mii_knowndevs[i].descr != NULL; i++)
+		if (mii_knowndevs[i].oui == oui &&
+		    mii_knowndevs[i].model == model)
+			break;
+	return (mii_knowndevs[i].descr);
+}
Index: src/sys/dev/mii/mii_verbose.h
diff -u /dev/null src/sys/dev/mii/mii_verbose.h:1.1
--- /dev/null	Sun May 30 17:44:08 2010
+++ src/sys/dev/mii/mii_verbose.h	Sun May 30 17:44:08 2010
@@ -0,0 +1,47 @@
+/*	$NetBSD: mii_verbose.h,v 1.1 2010/05/30 17:44:08 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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 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.
+ */
+
+#ifndef _DEV_MII_MII_VERBOSE_H_
+#define	_DEV_MII_MII_VERBOSE_H_
+
+#ifdef _KERNEL
+
+/* Misc. stuff for miiverbose module */
+
+extern const char *	(*mii_get_descr)(int, int);
+
+const char *	mii_get_descr_stub(int, int);
+void		mii_verbose_ctl(bool);
+
+#endif /* _KERNEL */
+
+#endif /* _DEV_MII_MII_VERBOSE_H_ */

Index: src/sys/modules/miiverbose/Makefile
diff -u /dev/null src/sys/modules/miiverbose/Makefile:1.1
--- /dev/null	Sun May 30 17:44:08 2010
+++ src/sys/modules/miiverbose/Makefile	Sun May 30 17:44:07 2010
@@ -0,0 +1,10 @@
+#	$NetBSD: Makefile,v 1.1 2010/05/30 17:44:07 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+KMOD=	miiverbose
+
+.PATH:	${S}/dev/mii
+SRCS=	mii_verbose.c
+
+.include <bsd.kmodule.mk>

Reply via email to