diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2009-04-23 04:21:10 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2009-04-23 04:21:10 +0000 |
commit | 7d9bd41111430c047b7a751ce6163d92afa9228a (patch) | |
tree | a139f4510ef47df56d7f04dbf07f0b96013a4c1d | |
parent | - reverted AC_PREREQ to 2.62 (diff) | |
download | libbsdport-7d9bd41111430c047b7a751ce6163d92afa9228a.tar.bz2 |
- added 'bootverbose' (in new 'misc.c' file)
- added rtems_mii_phy_probe(). This is a helper albeit RTEMS specific.
Porting the whole MII/media stuff is still too much ATM.
-rw-r--r-- | bsd_eth_drivers/libbsdport/Makefile.am | 2 | ||||
-rw-r--r-- | bsd_eth_drivers/libbsdport/miistuff.c | 58 | ||||
-rw-r--r-- | bsd_eth_drivers/libbsdport/misc.c | 1 |
3 files changed, 60 insertions, 1 deletions
diff --git a/bsd_eth_drivers/libbsdport/Makefile.am b/bsd_eth_drivers/libbsdport/Makefile.am index e6e31cd..2abfcfb 100644 --- a/bsd_eth_drivers/libbsdport/Makefile.am +++ b/bsd_eth_drivers/libbsdport/Makefile.am @@ -5,7 +5,7 @@ include $(top_srcdir)/rtems-pre.am libbsdport_a_SOURCES = rtems_callout.c rtems_taskqueue.c rtems_udelay.c libbsdport_a_SOURCES += ifstuff.c devicet.c alldrv.c contigmalloc.c -libbsdport_a_SOURCES += sysbus.c malloc.c ifmedia.c +libbsdport_a_SOURCES += sysbus.c malloc.c ifmedia.c misc.c miistuff.c libbsdport_a_SOURCES += rtems_verscheck.h bus.h callout.h devicet.h libbsdport_a_SOURCES += libbsdport.h libbsdport_post.h mutex.h diff --git a/bsd_eth_drivers/libbsdport/miistuff.c b/bsd_eth_drivers/libbsdport/miistuff.c new file mode 100644 index 0000000..b15545f --- /dev/null +++ b/bsd_eth_drivers/libbsdport/miistuff.c @@ -0,0 +1,58 @@ +#include <rtems.h> +#define _KERNEL +#include <rtems/rtems_bsdnet.h> +#include <rtems/rtems_bsdnet_internal.h> + +#include <bsp/rtems_verscheck.h> + +#include <sys/malloc.h> +#include <sys/errno.h> +#include <sys/socket.h> +#include <sys/sockio.h> +#include <net/if.h> +#include <net/if_media.h> +#include <rtems/rtems_mii_ioctl.h> + +#define PHY_MAX 32 + +#undef DEBUG + +/* A helper to find the active PHY. We really should port + * the entire BSD miibus/phy support but that's a bigger + * project... + */ +int +rtems_mii_phy_probe(struct rtems_mdio_info *mdio, void *softc) +{ +int phy; +uint32_t bmsr, bmcr; + for ( phy = 0; phy<PHY_MAX; phy++ ) { + if ( mdio->mdio_r(phy, softc, MII_BMSR, &bmsr) ) + continue; + + bmsr &= 0xffff; + + if ( 0 == bmsr || 0xffff == bmsr ) + continue; /* nothing here */ + + /* no media supported ? */ + if ( 0 == ((BMSR_EXTSTAT | 0xfe00) & bmsr ) ) + continue; /* probably nothing there */ + + if ( mdio->mdio_r(phy, softc, MII_BMCR, &bmcr) ) + continue; + + /* skip isolated or powered-down phys */ + if ( (BMCR_PDOWN | BMCR_ISO) & bmcr ) + continue; + +#ifdef DEBUG + printk("PHY #%u seems active; link status is %s\n", phy, BMSR_LINK & bmsr ? "UP" : "DOWN"); +#endif + + /* seems we found one */ + return phy; + } + + return -1; +} diff --git a/bsd_eth_drivers/libbsdport/misc.c b/bsd_eth_drivers/libbsdport/misc.c new file mode 100644 index 0000000..78f1fca --- /dev/null +++ b/bsd_eth_drivers/libbsdport/misc.c @@ -0,0 +1 @@ +int libbsdport_bootverbose = 0; |