mii_verbose.c revision 1.1
11.1Spgoyette/* $NetBSD: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $ */ 21.1Spgoyette 31.1Spgoyette/*- 41.1Spgoyette * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. 51.1Spgoyette * All rights reserved. 61.1Spgoyette * 71.1Spgoyette * This code is derived from software contributed to The NetBSD Foundation 81.1Spgoyette * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 91.1Spgoyette * NASA Ames Research Center, and by Frank van der Linden. 101.1Spgoyette * 111.1Spgoyette * Redistribution and use in source and binary forms, with or without 121.1Spgoyette * modification, are permitted provided that the following conditions 131.1Spgoyette * are met: 141.1Spgoyette * 1. Redistributions of source code must retain the above copyright 151.1Spgoyette * notice, this list of conditions and the following disclaimer. 161.1Spgoyette * 2. Redistributions in binary form must reproduce the above copyright 171.1Spgoyette * notice, this list of conditions and the following disclaimer in the 181.1Spgoyette * documentation and/or other materials provided with the distribution. 191.1Spgoyette * 201.1Spgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 211.1Spgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 221.1Spgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 231.1Spgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 241.1Spgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 251.1Spgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 261.1Spgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 271.1Spgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 281.1Spgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 291.1Spgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 301.1Spgoyette * POSSIBILITY OF SUCH DAMAGE. 311.1Spgoyette */ 321.1Spgoyette 331.1Spgoyette/* 341.1Spgoyette * Copyright (c) 1997 Manuel Bouyer. All rights reserved. 351.1Spgoyette * 361.1Spgoyette * Redistribution and use in source and binary forms, with or without 371.1Spgoyette * modification, are permitted provided that the following conditions 381.1Spgoyette * are met: 391.1Spgoyette * 1. Redistributions of source code must retain the above copyright 401.1Spgoyette * notice, this list of conditions and the following disclaimer. 411.1Spgoyette * 2. Redistributions in binary form must reproduce the above copyright 421.1Spgoyette * notice, this list of conditions and the following disclaimer in the 431.1Spgoyette * documentation and/or other materials provided with the distribution. 441.1Spgoyette * 451.1Spgoyette * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 461.1Spgoyette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 471.1Spgoyette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 481.1Spgoyette * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 491.1Spgoyette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 501.1Spgoyette * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 511.1Spgoyette * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 521.1Spgoyette * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 531.1Spgoyette * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 541.1Spgoyette * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 551.1Spgoyette */ 561.1Spgoyette 571.1Spgoyette#include <sys/cdefs.h> 581.1Spgoyette__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $"); 591.1Spgoyette 601.1Spgoyette#include <sys/module.h> 611.1Spgoyette#include <dev/mii/mii_verbose.h> 621.1Spgoyette 631.1Spgoyettestruct mii_knowndev { 641.1Spgoyette int oui; 651.1Spgoyette int model; 661.1Spgoyette const char *descr; 671.1Spgoyette}; 681.1Spgoyette#include <dev/mii/miidevs.h> 691.1Spgoyette#include <dev/mii/miidevs_data.h> 701.1Spgoyette 711.1Spgoyetteconst char * mii_get_descr_real(int, int); 721.1Spgoyette 731.1SpgoyetteMODULE(MODULE_CLASS_MISC, miiverbose, NULL); 741.1Spgoyette 751.1Spgoyettestatic int 761.1Spgoyettemiiverbose_modcmd(modcmd_t cmd, void *arg) 771.1Spgoyette{ 781.1Spgoyette switch (cmd) { 791.1Spgoyette case MODULE_CMD_INIT: 801.1Spgoyette mii_get_descr = mii_get_descr_real; 811.1Spgoyette return 0; 821.1Spgoyette case MODULE_CMD_FINI: 831.1Spgoyette mii_get_descr = mii_get_descr_stub; 841.1Spgoyette return 0; 851.1Spgoyette default: 861.1Spgoyette return ENOTTY; 871.1Spgoyette } 881.1Spgoyette} 891.1Spgoyette 901.1Spgoyetteconst char * 911.1Spgoyettemii_get_descr_real(int oui, int model) { 921.1Spgoyette int i; 931.1Spgoyette 941.1Spgoyette for (i = 0; mii_knowndevs[i].descr != NULL; i++) 951.1Spgoyette if (mii_knowndevs[i].oui == oui && 961.1Spgoyette mii_knowndevs[i].model == model) 971.1Spgoyette break; 981.1Spgoyette return (mii_knowndevs[i].descr); 991.1Spgoyette} 100