summaryrefslogtreecommitdiffstats
path: root/bsd_eth_drivers/libbsdport/devicet.c
diff options
context:
space:
mode:
authorcvs2git <rtems-devel@rtems.org>2010-03-07 17:11:24 +0000
committercvs2git <rtems-devel@rtems.org>2010-03-07 17:11:24 +0000
commita9f34b79757de68cdd3f951077be0dd65da6354c (patch)
treef60c55f42307a08ebee35449d53e450e7f4a3321 /bsd_eth_drivers/libbsdport/devicet.c
parent - importing updated version from SLAC as of 20090422 (diff)
downloadlibbsdport-R_20100307_p0.tar.bz2
This commit was manufactured by cvs2svn to create tag 'R_20100307_p0'.R_20100307_p0
Sprout from base 2009-04-22 22:06:58 UTC Till Straumann <strauman@slac.stanford.edu> ' - importing updated version from SLAC as of 20090422' Cherrypick from master 2010-03-07 17:11:23 UTC Till Straumann <strauman@slac.stanford.edu> '2010-03-07 Till Straumann <Till.Straumann@TU-Berlin.de>': bsd_eth_drivers/.cvsignore bsd_eth_drivers/ChangeLog bsd_eth_drivers/Makefile.am bsd_eth_drivers/if_bge/.cvsignore bsd_eth_drivers/if_bge/Makefile.am bsd_eth_drivers/if_bge/if_bge.c bsd_eth_drivers/if_bge/if_bgereg.h bsd_eth_drivers/if_em/.cvsignore bsd_eth_drivers/if_em/Makefile.am bsd_eth_drivers/if_em/e1000_manage.c bsd_eth_drivers/if_em/e1000_manage.h bsd_eth_drivers/if_em/e1000_osdep.h bsd_eth_drivers/if_em/if_em.c bsd_eth_drivers/if_fxp/.cvsignore bsd_eth_drivers/if_fxp/Makefile.am bsd_eth_drivers/if_fxp/if_fxp.c bsd_eth_drivers/if_fxp/if_fxpvar.h bsd_eth_drivers/if_le/.cvsignore bsd_eth_drivers/if_pcn/.cvsignore bsd_eth_drivers/if_pcn/if_pcn.c bsd_eth_drivers/if_re/.cvsignore bsd_eth_drivers/if_re/Makefile.am bsd_eth_drivers/if_re/if_re.c bsd_eth_drivers/if_re/if_rl.c bsd_eth_drivers/if_re/if_rlreg.h bsd_eth_drivers/libbsdport/.cvsignore bsd_eth_drivers/libbsdport/Makefile.am bsd_eth_drivers/libbsdport/alldrv.c bsd_eth_drivers/libbsdport/bus.h bsd_eth_drivers/libbsdport/callout.h bsd_eth_drivers/libbsdport/devicet.c bsd_eth_drivers/libbsdport/ifmedia.c bsd_eth_drivers/libbsdport/libbsdport.h bsd_eth_drivers/libbsdport/libbsdport_api.h bsd_eth_drivers/libbsdport/libbsdport_post.h bsd_eth_drivers/libbsdport/miistuff.c bsd_eth_drivers/libbsdport/misc.c bsd_eth_drivers/libbsdport/mutex.h bsd_eth_drivers/libbsdport/rtems_callout.c bsd_eth_drivers/libbsdport/sysbus.c bsd_eth_drivers/libbsdport/taskqueue.h bsd_eth_drivers/links.am Cherrypick from freebsd_orig 2009-04-23 04:52:05 UTC Till Straumann <strauman@slac.stanford.edu> ' - importing original 'releng_7_1' version of FXP driver from FreeBSD.': bsd_eth_drivers/if_fxp/if_fxpreg.h bsd_eth_drivers/if_fxp/rcvbundl.h Delete: INSTALL Makefile.am bootstrap config.h.in configure.ac m4/acinclude.m4 m4/config-if-present.m4 m4/cvstag.m4 m4/multilib-fix.m4 m4/multilib-installdir.m4 m4/rtems-bsp-postlink.m4 m4/rtems-bsplist.m4 m4/rtems-check-libargs.m4 m4/rtems-checkprog.m4 m4/rtems-checktool.m4 m4/rtems-checktop.m4 m4/rtems-fixup-prefix.m4 m4/rtems-isml.m4 m4/rtems-ismultibsp.m4 m4/rtems-isrtems.m4 m4/rtems-makevars.m4 m4/rtems-multilib.m4 m4/rtems-options.m4 m4/rtems-setup-recurse.m4 m4/rtems-tools.m4 m4/rtems-trim-builddir.m4 m4/rtems-verscheck.m4 makefile.top.am makefile.top.in rtems-pre.am rtems.am ssrlApps.components.in
Diffstat (limited to 'bsd_eth_drivers/libbsdport/devicet.c')
-rw-r--r--bsd_eth_drivers/libbsdport/devicet.c73
1 files changed, 45 insertions, 28 deletions
diff --git a/bsd_eth_drivers/libbsdport/devicet.c b/bsd_eth_drivers/libbsdport/devicet.c
index f197da4..fde3975 100644
--- a/bsd_eth_drivers/libbsdport/devicet.c
+++ b/bsd_eth_drivers/libbsdport/devicet.c
@@ -12,7 +12,8 @@
#include <sys/bus.h>
#include "libbsdport_api.h"
-#undef DEBUG
+#define DEBUG 0
+int libbsdportAttachVerbose = DEBUG;
extern void real_libc_free(void*);
@@ -65,11 +66,11 @@ devattach(device_t dev, int unit, struct rtems_bsdnet_ifconfig *cfg)
{
int error;
-#ifdef DEBUG
- printf("Now attaching %s%d: (0x%x:%x.%x)\n",
- dev->name, unit,
- dev->bushdr.pci.bus, dev->bushdr.pci.dev, dev->bushdr.pci.fun);
-#endif
+ if ( libbsdportAttachVerbose ) {
+ printf("Now attaching %s%d: (0x%x:%x.%x)\n",
+ dev->name, unit,
+ dev->bushdr.pci.bus, dev->bushdr.pci.dev, dev->bushdr.pci.fun);
+ }
dev->unit = unit;
dev->ifconfig = cfg;
@@ -247,6 +248,8 @@ device_t tmpdev;
int error = 0;
int bdfunit;
+int n_bus;
+
if ( !attaching )
return ENOTSUP;
@@ -256,20 +259,33 @@ int bdfunit;
wantedunit |= 1<<31;
nm[0]=0;
}
-#ifdef DEBUG
- printf("Wanted unit is 0x%x, pattern '%s'\n", wantedunit, nm);
+ if ( libbsdportAttachVerbose )
+ printf("Wanted unit is 0x%x, pattern '%s'\n", wantedunit, nm);
+
+ n_bus = pci_bus_count();
+#ifdef __i386__
+ /* ugliest of all hacks -- RTEMS routine is currently (4.9)
+ * still broken; it reports the (0-based) highest bus number
+ * instead of the count.
+ */
+ n_bus++;
#endif
unit = 0;
for ( i=0; (dr=libbsdport_netdriver_table[i]); i++ ) {
+
+ /* unused slot ? */
+ if ( 0 == dr->name && 0 == dr->methods )
+ continue;
+
/* Find matching driver */
-#ifdef DEBUG
- printf("Trying driver '%s' ...", dr->name);
-#endif
+ if ( libbsdportAttachVerbose )
+ printf("Trying driver '%s' ...", dr->name);
+
if ( matches(dr, nm) ) {
-#ifdef DEBUG
- printf("MATCH\n");
-#endif
+
+ if ( libbsdportAttachVerbose )
+ printf("MATCH\n");
assert( dr->methods );
@@ -281,7 +297,7 @@ int bdfunit;
}
dev = devalloc(dr);
- for ( b=0; b<pci_bus_count(); b++)
+ for ( b=0; b<n_bus; b++ )
for ( d=0; d<PCI_MAX_DEVICES; d++ ) {
for ( f=0; f<pci_num_functions(b,d); f++ ) {
if ( ! pci_is_ether(b,d,f) )
@@ -293,10 +309,10 @@ int bdfunit;
bdfunit = (b<<8) | PCI_DEVFN(d,f);
-#ifdef DEBUG
- printf("Probing PCI 0x%x:%x.%x\n",
- bdfunit>>8, PCI_SLOT(bdfunit), PCI_FUNC(bdfunit));
-#endif
+ if ( libbsdportAttachVerbose ) {
+ printf("Probing PCI 0x%x:%x.%x\n",
+ bdfunit>>8, PCI_SLOT(bdfunit), PCI_FUNC(bdfunit));
+ }
/* has this device been attached already ? */
if ( (tmpdev = devattached(dev)) ) {
@@ -319,9 +335,9 @@ int bdfunit;
/* wanted unit == 0 means next avail.
* unit is acceptable.
*/
-#ifdef DEBUG
- printf("->SUCCESS\n");
-#endif
+ if ( libbsdportAttachVerbose )
+ printf("->SUCCESS\n");
+
if ( 0 == wantedunit || UNITMATCH(wantedunit, unit, bdfunit) ) {
error = devattach(dev, thisunit, cfg);
if ( !error )
@@ -331,9 +347,8 @@ int bdfunit;
break;
default:
-#ifdef DEBUG
- printf("->FAILED\n");
-#endif
+ if ( libbsdportAttachVerbose )
+ printf("->FAILED\n");
/* probe failed */
break;
}
@@ -343,9 +358,11 @@ int bdfunit;
} /* for all busses + slots */
devfree(dev); dev = 0;
} /* matching driver */
-#ifdef DEBUG
- else printf("NO MATCH\n");
-#endif
+ else
+ {
+ if ( libbsdportAttachVerbose )
+ printf("NO MATCH\n");
+ }
} /* for all drivers */
/* Nothing found */