From a1b4eeff4d7ff8e6ccaf5821108b568e7d24ea3f Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 9 Sep 2025 16:59:21 -0400 Subject: [PATCH] freebsd_network: Overhaul MII attach code. * Move ukphy ("unknown phy") code into the compat layer rather than duplicating it across many drivers. * Move MIIbus related code to a separate static library. * Genericize most attach methods that touched the MII bus directly to not need the code that's now in the static library. Tested with rtl81xx, still works. --- .../kernel/drivers/network/ether/3com/Jamfile | 8 +- .../kernel/drivers/network/ether/3com/glue.c | 2 +- .../drivers/network/ether/atheros813x/Jamfile | 9 +- .../network/ether/atheros813x/dev/mii/ukphy.c | 156 ------------------ .../ether/atheros813x/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/atheros81xx/Jamfile | 9 +- .../network/ether/atheros81xx/dev/mii/ukphy.c | 156 ------------------ .../ether/atheros81xx/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/atheros81xx/glue.c | 2 +- .../drivers/network/ether/attansic_l1/Jamfile | 2 +- .../drivers/network/ether/attansic_l1/glue.c | 2 +- .../drivers/network/ether/attansic_l2/Jamfile | 9 +- .../network/ether/attansic_l2/dev/mii/ukphy.c | 156 ------------------ .../ether/attansic_l2/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/attansic_l2/glue.c | 2 +- .../network/ether/broadcom440x/Jamfile | 2 +- .../drivers/network/ether/broadcom440x/glue.c | 2 +- .../network/ether/broadcom570x/Jamfile | 8 +- .../ether/broadcom570x/dev/mii/ukphy.c | 156 ------------------ .../ether/broadcom570x/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/broadcom570x/glue.c | 2 +- .../drivers/network/ether/dec21xxx/Jamfile | 6 +- .../network/ether/dec21xxx/dev/mii/ukphy.c | 156 ------------------ .../ether/dec21xxx/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/dec21xxx/glue.c | 2 +- .../drivers/network/ether/ipro100/Jamfile | 2 +- .../drivers/network/ether/jmicron2x0/Jamfile | 2 +- .../network/ether/marvell_yukon/Jamfile | 8 +- .../ether/marvell_yukon/dev/mii/ukphy.c | 156 ------------------ .../ether/marvell_yukon/dev/mii/ukphy_subr.c | 129 --------------- .../network/ether/marvell_yukon/glue.c | 2 +- .../drivers/network/ether/nforce/Jamfile | 8 +- .../network/ether/nforce/dev/mii/ukphy.c | 156 ------------------ .../network/ether/nforce/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/nforce/glue.c | 2 +- .../drivers/network/ether/pcnet/Jamfile | 8 +- .../network/ether/pcnet/dev/mii/ukphy.c | 156 ------------------ .../network/ether/pcnet/dev/mii/ukphy_subr.c | 129 --------------- .../kernel/drivers/network/ether/pcnet/glue.c | 2 +- .../kernel/drivers/network/ether/rdc/Jamfile | 2 +- .../kernel/drivers/network/ether/rdc/glue.c | 2 +- .../drivers/network/ether/rtl8139/Jamfile | 2 +- .../drivers/network/ether/rtl81xx/Jamfile | 2 +- .../drivers/network/ether/rtl81xx/glue.c | 2 +- .../drivers/network/ether/sis19x/Jamfile | 9 +- .../network/ether/sis19x/dev/mii/ukphy.c | 156 ------------------ .../network/ether/sis19x/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/sis19x/glue.c | 2 +- .../drivers/network/ether/sis900/Jamfile | 8 +- .../network/ether/sis900/dev/mii/ukphy.c | 156 ------------------ .../network/ether/sis900/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/sis900/glue.c | 2 +- .../drivers/network/ether/syskonnect/Jamfile | 8 +- .../network/ether/syskonnect/dev/mii/ukphy.c | 156 ------------------ .../ether/syskonnect/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/syskonnect/glue.c | 2 +- .../drivers/network/ether/via_rhine/Jamfile | 8 +- .../network/ether/via_rhine/dev/mii/ukphy.c | 156 ------------------ .../ether/via_rhine/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/via_rhine/glue.c | 2 +- .../drivers/network/ether/vt612x/Jamfile | 8 +- .../network/ether/vt612x/dev/mii/ukphy.c | 156 ------------------ .../network/ether/vt612x/dev/mii/ukphy_subr.c | 129 --------------- .../drivers/network/ether/vt612x/glue.c | 2 +- src/libs/compat/freebsd_network/Jamfile | 17 +- .../compat/freebsd_network/compat/sys/bus.h | 2 - .../freebsd_network/compat/sys/haiku-module.h | 15 +- .../{fbsd_mii.c => dev/mii/mii.c} | 0 .../mii/mii_bitbang.c} | 0 .../mii/mii_physubr.c} | 0 .../compat/freebsd_network}/dev/mii/ukphy.c | 0 .../freebsd_network}/dev/mii/ukphy_subr.c | 0 src/libs/compat/freebsd_network/device.c | 92 +++++------ src/libs/compat/freebsd_network/driver.c | 6 +- .../freebsd_network/{mii.c => miibus.c} | 5 + src/libs/compat/freebsd_network/shared.h | 6 +- 76 files changed, 129 insertions(+), 3881 deletions(-) delete mode 100644 src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy_subr.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy.c delete mode 100644 src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy_subr.c rename src/libs/compat/freebsd_network/{fbsd_mii.c => dev/mii/mii.c} (100%) rename src/libs/compat/freebsd_network/{fbsd_mii_bitbang.c => dev/mii/mii_bitbang.c} (100%) rename src/libs/compat/freebsd_network/{fbsd_mii_physubr.c => dev/mii/mii_physubr.c} (100%) rename src/{add-ons/kernel/drivers/network/ether/3com => libs/compat/freebsd_network}/dev/mii/ukphy.c (100%) rename src/{add-ons/kernel/drivers/network/ether/3com => libs/compat/freebsd_network}/dev/mii/ukphy_subr.c (100%) rename src/libs/compat/freebsd_network/{mii.c => miibus.c} (86%) diff --git a/src/add-ons/kernel/drivers/network/ether/3com/Jamfile b/src/add-ons/kernel/drivers/network/ether/3com/Jamfile index 155fd0db9c..3e2bc885bf 100644 --- a/src/add-ons/kernel/drivers/network/ether/3com/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/3com/Jamfile @@ -17,12 +17,10 @@ KernelAddon 3com : if_xl.c xlphy.c bmtphy.c - ukphy.c - ukphy_subr.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles bmtphy$(SUFOBJ) ukphy$(SUFOBJ) xlphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles bmtphy$(SUFOBJ) xlphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles bmtphy.c ukphy.c xlphy.c ] +Includes [ FGristFiles bmtphy.c xlphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/3com/glue.c b/src/add-ons/kernel/drivers/network/ether/3com/glue.c index 40983bb22c..82976485ae 100644 --- a/src/add-ons/kernel/drivers/network/ether/3com/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/3com/glue.c @@ -33,7 +33,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/atheros813x/Jamfile b/src/add-ons/kernel/drivers/network/ether/atheros813x/Jamfile index e54764066a..af17745616 100644 --- a/src/add-ons/kernel/drivers/network/ether/atheros813x/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/atheros813x/Jamfile @@ -9,17 +9,10 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; UseHeaders [ FDirName $(SUBDIR) ] : true ; -SEARCH_SOURCE += [ FDirName $(SUBDIR) dev mii ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) dev alc ] ; KernelAddon atheros813x : glue.c - ukphy.c - ukphy_subr.c if_alc.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; - -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) ] - : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/atheros813x/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/atheros81xx/Jamfile b/src/add-ons/kernel/drivers/network/ether/atheros81xx/Jamfile index efa1e303e7..7b314e940d 100644 --- a/src/add-ons/kernel/drivers/network/ether/atheros81xx/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/atheros81xx/Jamfile @@ -9,17 +9,10 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; UseHeaders [ FDirName $(SUBDIR) ] : true ; -SEARCH_SOURCE += [ FDirName $(SUBDIR) dev mii ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) dev ale ] ; KernelAddon atheros81xx : glue.c - ukphy.c - ukphy_subr.c if_ale.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; - -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) ] - : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/atheros81xx/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/atheros81xx/glue.c b/src/add-ons/kernel/drivers/network/ether/atheros81xx/glue.c index 5989c837e7..29972ec823 100644 --- a/src/add-ons/kernel/drivers/network/ether/atheros81xx/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/atheros81xx/glue.c @@ -23,5 +23,5 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l1/Jamfile b/src/add-ons/kernel/drivers/network/ether/attansic_l1/Jamfile index ce9dd21586..5530c66b54 100644 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l1/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/attansic_l1/Jamfile @@ -16,7 +16,7 @@ KernelAddon attansic_l1 : glue.c atphy.c if_age.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles atphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l1/glue.c b/src/add-ons/kernel/drivers/network/ether/attansic_l1/glue.c index 45528ceb06..7c1d3a96fd 100644 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l1/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/attansic_l1/glue.c @@ -22,7 +22,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l2/Jamfile b/src/add-ons/kernel/drivers/network/ether/attansic_l2/Jamfile index 5fcebcb403..0e369e1e94 100644 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l2/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/attansic_l2/Jamfile @@ -9,17 +9,10 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; UseHeaders [ FDirName $(SUBDIR) ] : true ; -SEARCH_SOURCE += [ FDirName $(SUBDIR) dev mii ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) dev ae ] ; KernelAddon attansic_l2 : glue.c - ukphy.c - ukphy_subr.c if_ae.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; - -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) ] - : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l2/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/attansic_l2/glue.c b/src/add-ons/kernel/drivers/network/ether/attansic_l2/glue.c index 29133a4023..f6288070a2 100644 --- a/src/add-ons/kernel/drivers/network/ether/attansic_l2/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/attansic_l2/glue.c @@ -23,5 +23,5 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom440x/Jamfile b/src/add-ons/kernel/drivers/network/ether/broadcom440x/Jamfile index a04bdd17d8..ac577e6b0d 100644 --- a/src/add-ons/kernel/drivers/network/ether/broadcom440x/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/broadcom440x/Jamfile @@ -16,7 +16,7 @@ KernelAddon broadcom440x : glue.c bmtphy.c if_bfe.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles bmtphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom440x/glue.c b/src/add-ons/kernel/drivers/network/ether/broadcom440x/glue.c index cc12585520..e2ff7a1ba9 100644 --- a/src/add-ons/kernel/drivers/network/ether/broadcom440x/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/broadcom440x/glue.c @@ -28,7 +28,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom570x/Jamfile b/src/add-ons/kernel/drivers/network/ether/broadcom570x/Jamfile index 49aa0c69eb..b8898a97b3 100644 --- a/src/add-ons/kernel/drivers/network/ether/broadcom570x/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/broadcom570x/Jamfile @@ -16,12 +16,10 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev bge ] ; KernelAddon broadcom570x : glue.c brgphy.c - ukphy.c - ukphy_subr.c if_bge.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles brgphy$(SUFOBJ) ukphy$(SUFOBJ) if_bge$(SUFOBJ) ] +ObjectHdrs [ FGristFiles brgphy$(SUFOBJ) if_bge$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles brgphy.c ukphy.c if_bge.c ] : miidevs.h ; +Includes [ FGristFiles brgphy.c if_bge.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/broadcom570x/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/broadcom570x/glue.c b/src/add-ons/kernel/drivers/network/ether/broadcom570x/glue.c index 7936e0d8a4..6f3ea7a9cf 100644 --- a/src/add-ons/kernel/drivers/network/ether/broadcom570x/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/broadcom570x/glue.c @@ -34,7 +34,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/dec21xxx/Jamfile b/src/add-ons/kernel/drivers/network/ether/dec21xxx/Jamfile index 94a646af3b..6113ac8533 100644 --- a/src/add-ons/kernel/drivers/network/ether/dec21xxx/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/dec21xxx/Jamfile @@ -23,13 +23,11 @@ KernelAddon dec21xxx : if_de.c acphy.c amphy.c - ukphy.c - ukphy_subr.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles dcphy$(SUFOBJ) pnphy$(SUFOBJ) if_de$(SUFOBJ) - acphy$(SUFOBJ) amphy$(SUFOBJ) ukphy$(SUFOBJ) ] + acphy$(SUFOBJ) amphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; Includes [ FGristFiles dcphy.c pnphy.c acphy.c amphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/dec21xxx/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/dec21xxx/glue.c b/src/add-ons/kernel/drivers/network/ether/dec21xxx/glue.c index 1f6efd89e0..4b0503f609 100644 --- a/src/add-ons/kernel/drivers/network/ether/dec21xxx/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/dec21xxx/glue.c @@ -64,7 +64,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/ipro100/Jamfile b/src/add-ons/kernel/drivers/network/ether/ipro100/Jamfile index d58d28348b..3f07aabe9a 100644 --- a/src/add-ons/kernel/drivers/network/ether/ipro100/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/ipro100/Jamfile @@ -15,7 +15,7 @@ KernelAddon ipro100 : if_fxp.c glue.c inphy.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles inphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/jmicron2x0/Jamfile b/src/add-ons/kernel/drivers/network/ether/jmicron2x0/Jamfile index abbf6136de..6da95cdfe2 100644 --- a/src/add-ons/kernel/drivers/network/ether/jmicron2x0/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/jmicron2x0/Jamfile @@ -16,7 +16,7 @@ KernelAddon jmicron2x0 : glue.c if_jme.c jmphy.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles jmphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/Jamfile b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/Jamfile index 96068a59ed..af917476e2 100644 --- a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/Jamfile @@ -14,13 +14,11 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev msk ] ; KernelAddon marvell_yukon : glue.c - ukphy.c - ukphy_subr.c e1000phy.c if_msk.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) e1000phy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles e1000phy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c e1000phy.c ] : miidevs.h ; +Includes [ FGristFiles e1000phy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/glue.c b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/glue.c index 5c4af06129..9b8ff711a6 100644 --- a/src/add-ons/kernel/drivers/network/ether/marvell_yukon/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/marvell_yukon/glue.c @@ -33,7 +33,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/nforce/Jamfile b/src/add-ons/kernel/drivers/network/ether/nforce/Jamfile index 66276c3d05..78f88d08e2 100644 --- a/src/add-ons/kernel/drivers/network/ether/nforce/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/nforce/Jamfile @@ -14,13 +14,11 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev nfe ] ; KernelAddon nforce : glue.c - ukphy.c - ukphy_subr.c ciphy.c if_nfe.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) ciphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c ciphy.c ] : miidevs.h ; +Includes [ FGristFiles ciphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/nforce/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/nforce/glue.c b/src/add-ons/kernel/drivers/network/ether/nforce/glue.c index daf24340e2..9e6d028b66 100644 --- a/src/add-ons/kernel/drivers/network/ether/nforce/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/nforce/glue.c @@ -26,6 +26,6 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/pcnet/Jamfile b/src/add-ons/kernel/drivers/network/ether/pcnet/Jamfile index 9161947a77..ff9dbc6d4d 100644 --- a/src/add-ons/kernel/drivers/network/ether/pcnet/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/pcnet/Jamfile @@ -17,8 +17,6 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev le ] ; KernelAddon pcnet : glue.c glue_pcn.c - ukphy.c - ukphy_subr.c nsphy.c nsphyter.c if_pcn.c @@ -26,9 +24,9 @@ KernelAddon pcnet : am7990.c am79900.c lance.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) nsphy$(SUFOBJ) nsphyter$(SUFOBJ) ] +ObjectHdrs [ FGristFiles nsphy$(SUFOBJ) nsphyter$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c nsphy.c nsphyter.c ] : miidevs.h ; +Includes [ FGristFiles nsphy.c nsphyter.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/pcnet/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/pcnet/glue.c b/src/add-ons/kernel/drivers/network/ether/pcnet/glue.c index a49d3ca9a1..647ba38c11 100644 --- a/src/add-ons/kernel/drivers/network/ether/pcnet/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/pcnet/glue.c @@ -31,7 +31,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } int check_disable_interrupts_le(device_t dev); diff --git a/src/add-ons/kernel/drivers/network/ether/rdc/Jamfile b/src/add-ons/kernel/drivers/network/ether/rdc/Jamfile index 9068809f77..aa0632c0e6 100644 --- a/src/add-ons/kernel/drivers/network/ether/rdc/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/rdc/Jamfile @@ -16,7 +16,7 @@ KernelAddon rdc : glue.c rdcphy.c if_vte.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles rdcphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/rdc/glue.c b/src/add-ons/kernel/drivers/network/ether/rdc/glue.c index 11d0a4ab42..4e07e3600f 100644 --- a/src/add-ons/kernel/drivers/network/ether/rdc/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/rdc/glue.c @@ -30,6 +30,6 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/rtl8139/Jamfile b/src/add-ons/kernel/drivers/network/ether/rtl8139/Jamfile index eb7ba5023c..23c2a73f81 100644 --- a/src/add-ons/kernel/drivers/network/ether/rtl8139/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/rtl8139/Jamfile @@ -16,7 +16,7 @@ KernelAddon rtl8139 : glue.c rlphy.c if_rl.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles rlphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/rtl81xx/Jamfile b/src/add-ons/kernel/drivers/network/ether/rtl81xx/Jamfile index dc30f811d3..be7e0763e6 100644 --- a/src/add-ons/kernel/drivers/network/ether/rtl81xx/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/rtl81xx/Jamfile @@ -17,7 +17,7 @@ KernelAddon rtl81xx : rgephy.c rlphy.c if_re.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; ObjectHdrs [ FGristFiles rgephy$(SUFOBJ) rlphy$(SUFOBJ) ] diff --git a/src/add-ons/kernel/drivers/network/ether/rtl81xx/glue.c b/src/add-ons/kernel/drivers/network/ether/rtl81xx/glue.c index 77f7852c07..d4a8813e7c 100644 --- a/src/add-ons/kernel/drivers/network/ether/rtl81xx/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/rtl81xx/glue.c @@ -34,7 +34,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/sis19x/Jamfile b/src/add-ons/kernel/drivers/network/ether/sis19x/Jamfile index 1313158013..b2231e3f9c 100644 --- a/src/add-ons/kernel/drivers/network/ether/sis19x/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/sis19x/Jamfile @@ -9,17 +9,10 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; UseHeaders [ FDirName $(SUBDIR) ] : true ; -SEARCH_SOURCE += [ FDirName $(SUBDIR) dev mii ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) dev sge ] ; KernelAddon sis19x : glue.c - ukphy.c - ukphy_subr.c if_sge.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; - -ObjectHdrs [ FGristFiles icsphy$(SUFOBJ) nsphyter$(SUFOBJ) ukphy$(SUFOBJ) ] - : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles icsphy.c nsphyter.c ukphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/sis19x/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/sis19x/glue.c b/src/add-ons/kernel/drivers/network/ether/sis19x/glue.c index 6c53a1083c..1fa5811343 100644 --- a/src/add-ons/kernel/drivers/network/ether/sis19x/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/sis19x/glue.c @@ -39,7 +39,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/sis900/Jamfile b/src/add-ons/kernel/drivers/network/ether/sis900/Jamfile index 4e1fe867f7..b34dec5653 100644 --- a/src/add-ons/kernel/drivers/network/ether/sis900/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/sis900/Jamfile @@ -16,12 +16,10 @@ KernelAddon sis900 : glue.c icsphy.c nsphyter.c - ukphy.c - ukphy_subr.c if_sis.c - : libfreebsd_network.a + : freebsd_mii.a libfreebsd_network.a ; -ObjectHdrs [ FGristFiles icsphy$(SUFOBJ) nsphyter$(SUFOBJ) ukphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles icsphy$(SUFOBJ) nsphyter$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles icsphy.c nsphyter.c ukphy.c ] : miidevs.h ; +Includes [ FGristFiles icsphy.c nsphyter.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/sis900/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/sis900/glue.c b/src/add-ons/kernel/drivers/network/ether/sis900/glue.c index 027952ac3b..bd59091545 100644 --- a/src/add-ons/kernel/drivers/network/ether/sis900/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/sis900/glue.c @@ -36,7 +36,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/syskonnect/Jamfile b/src/add-ons/kernel/drivers/network/ether/syskonnect/Jamfile index 608e271d09..5b85d0f105 100644 --- a/src/add-ons/kernel/drivers/network/ether/syskonnect/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/syskonnect/Jamfile @@ -16,12 +16,10 @@ KernelAddon syskonnect : glue.c e1000phy.c xmphy.c - ukphy.c - ukphy_subr.c if_sk.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles e1000phy$(SUFOBJ) xmphy$(SUFOBJ) ukphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles e1000phy$(SUFOBJ) xmphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles e1000phy.c xmphy.c ukphy.c ] : miidevs.h ; +Includes [ FGristFiles e1000phy.c xmphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/syskonnect/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/syskonnect/glue.c b/src/add-ons/kernel/drivers/network/ether/syskonnect/glue.c index e0c1045cf0..a3488094ae 100644 --- a/src/add-ons/kernel/drivers/network/ether/syskonnect/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/syskonnect/glue.c @@ -36,7 +36,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/via_rhine/Jamfile b/src/add-ons/kernel/drivers/network/ether/via_rhine/Jamfile index 59150246c2..786a0f1f1c 100644 --- a/src/add-ons/kernel/drivers/network/ether/via_rhine/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/via_rhine/Jamfile @@ -15,12 +15,10 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev vr ] ; KernelAddon via_rhine : glue.c ciphy.c - ukphy.c - ukphy_subr.c if_vr.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ukphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ciphy.c ukphy.c ] : miidevs.h ; +Includes [ FGristFiles ciphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/via_rhine/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/via_rhine/glue.c b/src/add-ons/kernel/drivers/network/ether/via_rhine/glue.c index ad22dfe604..1d4ea3ef96 100644 --- a/src/add-ons/kernel/drivers/network/ether/via_rhine/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/via_rhine/glue.c @@ -26,5 +26,5 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/add-ons/kernel/drivers/network/ether/vt612x/Jamfile b/src/add-ons/kernel/drivers/network/ether/vt612x/Jamfile index d4c382c5fb..12cbe2f816 100644 --- a/src/add-ons/kernel/drivers/network/ether/vt612x/Jamfile +++ b/src/add-ons/kernel/drivers/network/ether/vt612x/Jamfile @@ -14,13 +14,11 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) dev vge ] ; KernelAddon vt612x : glue.c - ukphy.c - ukphy_subr.c ciphy.c if_vge.c - : libfreebsd_network.a + : libfreebsd_network.a freebsd_mii.a ; -ObjectHdrs [ FGristFiles ukphy$(SUFOBJ) ciphy$(SUFOBJ) ] +ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ] : [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ; -Includes [ FGristFiles ukphy.c ciphy.c ] : miidevs.h ; +Includes [ FGristFiles ciphy.c ] : miidevs.h ; diff --git a/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy.c b/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy.c deleted file mode 100644 index c0d2d94e4c..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998, 1999 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 -/* - * driver for generic unknown PHYs - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -static int ukphy_probe(device_t); -static int ukphy_attach(device_t); - -static device_method_t ukphy_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ukphy_probe), - DEVMETHOD(device_attach, ukphy_attach), - DEVMETHOD(device_detach, mii_phy_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD_END -}; - -static driver_t ukphy_driver = { - "ukphy", - ukphy_methods, - sizeof(struct mii_softc) -}; - -DRIVER_MODULE(ukphy, miibus, ukphy_driver, 0, 0); - -static int ukphy_service(struct mii_softc *, struct mii_data *, int); - -static const struct mii_phy_funcs ukphy_funcs = { - ukphy_service, - ukphy_status, - mii_phy_reset -}; - -static int -ukphy_probe(device_t dev) -{ - - /* - * We know something is here, so always match at a low priority. - */ - device_set_desc(dev, "Generic IEEE 802.3u media interface"); - return (BUS_PROBE_GENERIC); -} - -static int -ukphy_attach(device_t dev) -{ - struct mii_softc *sc; - - sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1); - mii_phy_setmedia(sc); - - return (0); -} - -static int -ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) -{ - - switch (cmd) { - case MII_POLLSTAT: - break; - - case MII_MEDIACHG: - mii_phy_setmedia(sc); - break; - - case MII_TICK: - if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); - break; - } - - /* Update the media status. */ - PHY_STATUS(sc); - - /* Callback if something changed. */ - mii_phy_update(sc, cmd); - return (0); -} diff --git a/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy_subr.c b/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy_subr.c deleted file mode 100644 index 37f1939701..0000000000 --- a/src/add-ons/kernel/drivers/network/ether/vt612x/dev/mii/ukphy_subr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 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. - */ - -#include -/* - * Subroutines shared by the ukphy driver and other PHY drivers. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "miibus_if.h" - -/* - * Media status subroutine. If a PHY driver does media detection simply - * by decoding the NWay autonegotiation, use this routine. - */ -void -ukphy_status(struct mii_softc *phy) -{ - struct mii_data *mii = phy->mii_pdata; - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int bmsr, bmcr, anlpar, gtcr, gtsr; - - mii->mii_media_status = IFM_AVALID; - mii->mii_media_active = IFM_ETHER; - - bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR); - if (bmsr & BMSR_LINK) - mii->mii_media_status |= IFM_ACTIVE; - - bmcr = PHY_READ(phy, MII_BMCR); - if (bmcr & BMCR_ISO) { - mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; - return; - } - - if (bmcr & BMCR_LOOP) - mii->mii_media_active |= IFM_LOOP; - - if (bmcr & BMCR_AUTOEN) { - /* - * NWay autonegotiation takes the highest-order common - * bit of the ANAR and ANLPAR (i.e. best media advertised - * both by us and our link partner). - */ - if ((bmsr & BMSR_ACOMP) == 0) { - /* Erg, still trying, I guess... */ - mii->mii_media_active |= IFM_NONE; - return; - } - - anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR); - if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 && - (phy->mii_extcapabilities & - (EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) { - gtcr = PHY_READ(phy, MII_100T2CR); - gtsr = PHY_READ(phy, MII_100T2SR); - } else - gtcr = gtsr = 0; - - if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; - else if ((gtcr & GTCR_ADV_1000THDX) && - (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; - else if (anlpar & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; - else if (anlpar & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; - else if (anlpar & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; - else if (anlpar & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; - else - mii->mii_media_active |= IFM_NONE; - - if ((mii->mii_media_active & IFM_1000_T) != 0 && - (gtsr & GTSR_MS_RES) != 0) - mii->mii_media_active |= IFM_ETH_MASTER; - - if ((mii->mii_media_active & IFM_FDX) != 0) - mii->mii_media_active |= mii_phy_flowstatus(phy); - } else - mii->mii_media_active = ife->ifm_media; -} diff --git a/src/add-ons/kernel/drivers/network/ether/vt612x/glue.c b/src/add-ons/kernel/drivers/network/ether/vt612x/glue.c index 9a76aadbdd..3dbbc75ee7 100644 --- a/src/add-ons/kernel/drivers/network/ether/vt612x/glue.c +++ b/src/add-ons/kernel/drivers/network/ether/vt612x/glue.c @@ -34,7 +34,7 @@ __haiku_select_miibus_driver(device_t dev) NULL }; - return __haiku_probe_miibus(dev, drivers); + return __haiku_probe_drivers(dev, drivers); } diff --git a/src/libs/compat/freebsd_network/Jamfile b/src/libs/compat/freebsd_network/Jamfile index 11251a6f8a..4d0a60a1a3 100644 --- a/src/libs/compat/freebsd_network/Jamfile +++ b/src/libs/compat/freebsd_network/Jamfile @@ -16,9 +16,6 @@ KernelStaticLibrary libfreebsd_network.a : fbsd_kern_mbuf.c fbsd_uipc_mbuf.c fbsd_uipc_mbuf2.c - fbsd_mii.c - fbsd_mii_bitbang.c - fbsd_mii_physubr.c fbsd_subr_bufring.c fbsd_subr_sbuf.c fbsd_time.c @@ -41,7 +38,6 @@ KernelStaticLibrary libfreebsd_network.a : libkern.cpp malloc.cpp mbuf.c - mii.c mutex.c pci.cpp priv.cpp @@ -56,6 +52,19 @@ KernelStaticLibrary libfreebsd_network.a : usb_util.c ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) dev mii ] ; + +KernelStaticLibrary freebsd_mii.a : + mii.c + mii_bitbang.c + mii_physubr.c + miibus.c + ukphy.c + ukphy_subr.c + ; + +Includes [ FGristFiles ukphy.c ] : miidevs.h ; + rule MIIHeaderGen { SEARCH on $(2) = [ FDirName $(SUBDIR) compat dev mii ] ; diff --git a/src/libs/compat/freebsd_network/compat/sys/bus.h b/src/libs/compat/freebsd_network/compat/sys/bus.h index e566c23caf..12745b2f31 100644 --- a/src/libs/compat/freebsd_network/compat/sys/bus.h +++ b/src/libs/compat/freebsd_network/compat/sys/bus.h @@ -115,8 +115,6 @@ void device_set_ivars(device_t dev, void *); void *device_get_ivars(device_t dev); device_t device_add_child(device_t dev, const char* name, int unit); -device_t device_add_child_driver(device_t dev, const char* name, driver_t* driver, - int unit); int device_delete_child(device_t dev, device_t child); int device_is_attached(device_t dev); int device_attach(device_t dev); diff --git a/src/libs/compat/freebsd_network/compat/sys/haiku-module.h b/src/libs/compat/freebsd_network/compat/sys/haiku-module.h index fe3d5f01c0..92036f2119 100644 --- a/src/libs/compat/freebsd_network/compat/sys/haiku-module.h +++ b/src/libs/compat/freebsd_network/compat/sys/haiku-module.h @@ -84,7 +84,7 @@ status_t _fbsd_uninit_drivers(); extern const char *gDriverName; driver_t *__haiku_select_miibus_driver(device_t dev); -driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[]); +driver_t *__haiku_probe_drivers(device_t dev, driver_t *drivers[]); status_t __haiku_handle_fbsd_drivers_list(status_t (*handler)(driver_t *[], driver_t *[])); status_t init_wlan_stack(void); @@ -161,12 +161,6 @@ status_t wlan_close(void*); } \ HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname); -#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers) \ - driver_t *__haiku_select_miibus_driver(device_t dev) \ - { \ - return __haiku_probe_miibus(dev, drivers); \ - } - #define HAIKU_FBSD_MII_DRIVER(name) \ extern driver_t *DRIVER_MODULE_NAME(name, miibus); \ driver_t *__haiku_select_miibus_driver(device_t dev) \ @@ -175,11 +169,14 @@ status_t wlan_close(void*); DRIVER_MODULE_NAME(name, miibus), \ NULL \ }; \ - return __haiku_probe_miibus(dev, drivers); \ + return __haiku_probe_drivers(dev, drivers); \ } #define NO_HAIKU_FBSD_MII_DRIVER() \ - HAIKU_FBSD_RETURN_MII_DRIVER(NULL) + driver_t *__haiku_select_miibus_driver(device_t dev) \ + { \ + return NULL; \ + } extern spinlock __haiku_intr_spinlock; extern int __haiku_disable_interrupts(device_t dev); diff --git a/src/libs/compat/freebsd_network/fbsd_mii.c b/src/libs/compat/freebsd_network/dev/mii/mii.c similarity index 100% rename from src/libs/compat/freebsd_network/fbsd_mii.c rename to src/libs/compat/freebsd_network/dev/mii/mii.c diff --git a/src/libs/compat/freebsd_network/fbsd_mii_bitbang.c b/src/libs/compat/freebsd_network/dev/mii/mii_bitbang.c similarity index 100% rename from src/libs/compat/freebsd_network/fbsd_mii_bitbang.c rename to src/libs/compat/freebsd_network/dev/mii/mii_bitbang.c diff --git a/src/libs/compat/freebsd_network/fbsd_mii_physubr.c b/src/libs/compat/freebsd_network/dev/mii/mii_physubr.c similarity index 100% rename from src/libs/compat/freebsd_network/fbsd_mii_physubr.c rename to src/libs/compat/freebsd_network/dev/mii/mii_physubr.c diff --git a/src/add-ons/kernel/drivers/network/ether/3com/dev/mii/ukphy.c b/src/libs/compat/freebsd_network/dev/mii/ukphy.c similarity index 100% rename from src/add-ons/kernel/drivers/network/ether/3com/dev/mii/ukphy.c rename to src/libs/compat/freebsd_network/dev/mii/ukphy.c diff --git a/src/add-ons/kernel/drivers/network/ether/3com/dev/mii/ukphy_subr.c b/src/libs/compat/freebsd_network/dev/mii/ukphy_subr.c similarity index 100% rename from src/add-ons/kernel/drivers/network/ether/3com/dev/mii/ukphy_subr.c rename to src/libs/compat/freebsd_network/dev/mii/ukphy_subr.c diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 16a2c646d1..c97ef4e489 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -16,12 +16,9 @@ #include #include -#include #include #include -#include - spinlock __haiku_intr_spinlock; @@ -344,29 +341,22 @@ device_is_alive(device_t device) device_t -device_add_child_driver(device_t parent, const char* name, driver_t* _driver, - int unit) +device_add_child(device_t parent, const char* name, int unit) { device_t child = NULL; - if (_driver == NULL && name != NULL) { - if (strcmp(name, "miibus") == 0) - child = new_device(&miibus_driver); - else { - // find matching driver structure - driver_t** driver; - char symbol[128]; + if (name != NULL) { + // find matching driver structure + driver_t** driver; + char symbol[128]; + snprintf(symbol, sizeof(symbol), "__fbsd_%s_%s", name, + parent->driver->name); - snprintf(symbol, sizeof(symbol), "__fbsd_%s_%s", name, - parent->driver->name); - if (get_image_symbol(find_own_image(), symbol, B_SYMBOL_TYPE_DATA, - (void**)&driver) == B_OK) { - child = new_device(*driver); - } else - device_printf(parent, "couldn't find symbol %s\n", symbol); - } - } else if (_driver != NULL) { - child = new_device(_driver); + if (get_image_symbol(find_own_image(), symbol, B_SYMBOL_TYPE_DATA, + (void**)&driver) == B_OK) { + child = new_device(*driver); + } else + device_printf(parent, "couldn't find symbol %s\n", symbol); } else child = new_device(NULL); @@ -391,13 +381,6 @@ device_add_child_driver(device_t parent, const char* name, driver_t* _driver, } -device_t -device_add_child(device_t parent, const char* name, int unit) -{ - return device_add_child_driver(parent, name, NULL, unit); -} - - /*! Delete the child and all of its children. Detach as necessary. */ int @@ -515,10 +498,14 @@ bus_generic_attach(device_t dev) if (child->driver == NULL) { driver_t *driver = __haiku_select_miibus_driver(child); if (driver == NULL) { - struct mii_attach_args *ma = device_get_ivars(child); - - device_printf(dev, "No PHY module found (%x/%x)!\n", - MII_OUI(ma->mii_id1, ma->mii_id2), MII_MODEL(ma->mii_id2)); + char childInfo[128]; + if (dev->methods.bus_child_pnpinfo_str != NULL + && dev->methods.bus_child_pnpinfo_str(dev, child, + childInfo, sizeof(childInfo)) == 0) { + device_printf(dev, "no driver for device \"%s\"\n", childInfo); + } else { + device_printf(dev, "failed to find driver for child device\n"); + } } else device_set_driver(child, driver); } else @@ -555,25 +542,8 @@ bus_generic_detach(device_t device) } -// #pragma mark - Misc, Malloc - - -device_t -find_root_device(int unit) -{ - device_t device = NULL; - - while ((device = list_get_next_item(&sRootDevices, device)) != NULL) { - if (device->unit <= unit) - return device; - } - - return NULL; -} - - driver_t * -__haiku_probe_miibus(device_t dev, driver_t *drivers[]) +__haiku_probe_drivers(device_t dev, driver_t *drivers[]) { driver_t *selected = NULL; int i, selectedResult = 0; @@ -592,7 +562,8 @@ __haiku_probe_miibus(device_t dev, driver_t *drivers[]) if (selected == NULL || result < selectedResult) { selected = drivers[i]; selectedResult = result; - device_printf(dev, "Found MII: %s\n", selected->name); + device_printf(dev, "found %s device driver: %s\n", + dev->parent->description, selected->name); } } } @@ -601,6 +572,23 @@ __haiku_probe_miibus(device_t dev, driver_t *drivers[]) } +// #pragma mark - Misc, Malloc + + +device_t +find_root_device(int unit) +{ + device_t device = NULL; + + while ((device = list_get_next_item(&sRootDevices, device)) != NULL) { + if (device->unit <= unit) + return device; + } + + return NULL; +} + + int printf(const char *format, ...) { diff --git a/src/libs/compat/freebsd_network/driver.c b/src/libs/compat/freebsd_network/driver.c index 88ef1fbf52..582f03becc 100644 --- a/src/libs/compat/freebsd_network/driver.c +++ b/src/libs/compat/freebsd_network/driver.c @@ -92,10 +92,14 @@ init_root_device(device_t *_root, int bus_type) static status_t add_child_device(driver_t* driver, device_t root, device_t* _child) { - device_t child = device_add_child_driver(root, driver->name, driver, 0); + device_t child = device_add_child(root, NULL, 0); if (child == NULL) return B_ERROR; + strlcpy(child->device_name, driver->name, sizeof(child->device_name)); + if (device_set_driver(child, driver) != 0) + return B_ERROR; + if (_child != NULL) *_child = child; diff --git a/src/libs/compat/freebsd_network/mii.c b/src/libs/compat/freebsd_network/miibus.c similarity index 86% rename from src/libs/compat/freebsd_network/mii.c rename to src/libs/compat/freebsd_network/miibus.c index 4721938e24..a533861ab7 100644 --- a/src/libs/compat/freebsd_network/mii.c +++ b/src/libs/compat/freebsd_network/miibus.c @@ -15,6 +15,11 @@ #include +// This symbol needs to be visible so that device_add_child can find it. +__attribute__ ((visibility ("default"))) +driver_t *DRIVER_MODULE_NAME(miibus, driver) = &miibus_driver; + + int __haiku_miibus_readreg(device_t device, int phy, int reg) { diff --git a/src/libs/compat/freebsd_network/shared.h b/src/libs/compat/freebsd_network/shared.h index 102dab6a0d..0293f23f44 100644 --- a/src/libs/compat/freebsd_network/shared.h +++ b/src/libs/compat/freebsd_network/shared.h @@ -48,13 +48,13 @@ struct device { void (*miibus_linkchg)(device_t); void (*miibus_mediainit)(device_t); - int (*bus_child_location_str)(device_t dev __unused, device_t child, + int (*bus_child_location_str)(device_t dev, device_t child, char *buf, size_t buflen); - int (*bus_child_pnpinfo_str)(device_t dev __unused, device_t child, + int (*bus_child_pnpinfo_str)(device_t dev, device_t child, char *buf, size_t buflen); void (*bus_hinted_child)(device_t dev, const char *name, int unit); int (*bus_print_child)(device_t dev, device_t child); - int (*bus_read_ivar)(device_t dev, device_t child __unused, int which, + int (*bus_read_ivar)(device_t dev, device_t child, int which, uintptr_t *result); bus_dma_tag_t (*bus_get_dma_tag)(device_t dev); } methods;