PERFORCE change 143033 for review

Paolo Pisati piso at FreeBSD.org
Fri Jun 6 16:02:00 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=143033

Change 143033 by piso at piso_ferret on 2008/06/06 16:01:08

	fix cs compilation.

Affected files ...

.. //depot/projects/soc2005/libalias/sys/dev/cs/if_cs.c#6 edit
.. //depot/projects/soc2005/libalias/sys/dev/cs/if_cs_isa.c#4 edit
.. //depot/projects/soc2005/libalias/sys/dev/cs/if_cs_pccard.c#4 edit
.. //depot/projects/soc2005/libalias/sys/dev/cs/if_csreg.h#3 edit
.. //depot/projects/soc2005/libalias/sys/dev/cs/if_csvar.h#4 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/dev/cs/if_cs.c#6 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs.c,v 1.51 2008/06/06 05:25:24 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs.c,v 1.45 2006/09/15 15:16:10 glebius Exp $");
 
 /*
  *
@@ -73,13 +73,11 @@
 #endif
 
 static void	cs_init(void *);
-static void	cs_init_locked(struct cs_softc *);
 static int	cs_ioctl(struct ifnet *, u_long, caddr_t);
 static void	cs_start(struct ifnet *);
-static void	cs_start_locked(struct ifnet *);
 static void	cs_stop(struct cs_softc *);
 static void	cs_reset(struct cs_softc *);
-static void	cs_watchdog(void *);
+static void	cs_watchdog(struct ifnet *);
 
 static int	cs_mediachange(struct ifnet *);
 static void	cs_mediastatus(struct ifnet *, struct ifmediareq *);
@@ -94,13 +92,13 @@
 static int	get_eeprom_cksum(int, int, uint16_t *);
 static int	wait_eeprom_ready( struct cs_softc *);
 static void	control_dc_dc( struct cs_softc *, int );
+static int	send_test_pkt( struct cs_softc * );
 static int	enable_tp(struct cs_softc *);
 static int	enable_aui(struct cs_softc *);
 static int	enable_bnc(struct cs_softc *);
 static int      cs_duplex_auto(struct cs_softc *);
 
 devclass_t cs_devclass;
-driver_intr_t	csintr;
 
 /* sysctl vars */
 SYSCTL_NODE(_hw, OID_AUTO, cs, CTLFLAG_RD, 0, "cs device parameters");
@@ -127,7 +125,7 @@
 	int i;
 
 #ifdef CS_DEBUG
-	device_printf(sc->sc_dev, "EEPROM data from %x for %x:\n", off, len);
+	printf(CS_NAME":EEPROM data from %x for %x:\n", off, len);
 #endif
 
 	for (i=0; i < len; i++) {
@@ -140,7 +138,8 @@
 		buffer[i] = cs_readreg(sc, PP_EEData);
 
 #ifdef CS_DEBUG
-		printf("%04x ",buffer[i]);
+		printf("%02x %02x ",(unsigned char)buffer[i],
+		    (unsigned char)buffer[i] >> 8);
 #endif
 	}
 
@@ -159,8 +158,12 @@
 	for (i = 0; i < len; i++)
 		cksum += buffer[i];
 	cksum &= 0xffff;
-	if (cksum == 0 || cs_ignore_cksum_failure)
+	if (cksum==0)
+		return (0);
+	if (cs_ignore_cksum_failure) {
+		printf(CS_NAME": checksum mismatch, ignoring\n");
 		return (0);
+	}
 	return (-1);
 }
 
@@ -181,6 +184,7 @@
 	else
 		self_control &= ~HCB1;
 	cs_writereg(sc, PP_SelfCTL, self_control);
+
 	DELAY(500000);
 }
 
@@ -193,7 +197,7 @@
 	cs_writereg(sc, PP_AutoNegCTL,
 	    RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE);
 	for (i=0; cs_readreg(sc, PP_AutoNegST) & AUTO_NEG_BUSY; i++) {
-		if (i > 4000) {
+		if (i > 40000) {
 			device_printf(sc->dev,
 			    "full/half duplex auto negotiation timeout\n");
 			error = ETIMEDOUT;
@@ -201,6 +205,7 @@
 		}
 		DELAY(1000);
 	}
+	DELAY(1000000);
 	return (error);
 }
 
@@ -210,26 +215,91 @@
 
 	cs_writereg(sc, PP_LineCTL, sc->line_ctl & ~AUI_ONLY);
 	control_dc_dc(sc, 0);
+	DELAY( 150000 );
+
+	if ((cs_readreg(sc, PP_LineST) & LINK_OK)==0) {
+		device_printf(sc->dev, "failed to enable TP\n");
+		return (EINVAL);
+	}
+
+	return (0);
+}
+
+/*
+ * XXX This was rewritten from Linux driver without any tests.
+ */
+static int
+send_test_pkt(struct cs_softc *sc)
+{
+	char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
+				0, 46,  /* A 46 in network order */
+				0, 0,   /* DSAP=0 & SSAP=0 fields */
+				0xf3, 0 /* Control (Test Req + P bit set) */ };
+	int i;
+	u_char ether_address_backup[ETHER_ADDR_LEN];
+
+	for (i = 0; i < ETHER_ADDR_LEN; i++)
+		ether_address_backup[i] = sc->enaddr[i];
+
+	cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) | SERIAL_TX_ON);
+	bcopy(test_packet, sc->enaddr, ETHER_ADDR_LEN);
+	bcopy(test_packet+ETHER_ADDR_LEN, 
+	    sc->enaddr, ETHER_ADDR_LEN);
+	cs_outw(sc, TX_CMD_PORT, sc->send_cmd);
+	cs_outw(sc, TX_LEN_PORT, sizeof(test_packet));
+
+	/* Wait for chip to allocate memory */
+	DELAY(50000);
+	if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
+		for (i = 0; i < ETHER_ADDR_LEN; i++)
+			sc->enaddr[i] = ether_address_backup[i];
+		return (0);
+	}
+
+	outsw(sc->nic_addr + TX_FRAME_PORT, test_packet, sizeof(test_packet));
+
+	DELAY(30000);
+
+	for (i = 0; i < ETHER_ADDR_LEN; i++)
+		sc->enaddr[i] = ether_address_backup[i];
+	if ((cs_readreg(sc, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK)
+		return (1);
 	return (0);
 }
 
+/*
+ * XXX This was rewritten from Linux driver without any tests.
+ */
 static int
 enable_aui(struct cs_softc *sc)
 {
 
+	control_dc_dc(sc, 0);
 	cs_writereg(sc, PP_LineCTL,
 	    (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-	control_dc_dc(sc, 0);
+
+	if (!send_test_pkt(sc)) {
+		device_printf(sc->dev, "failed to enable AUI\n");
+		return (EINVAL);
+	}
 	return (0);
 }
 
+/*
+ * XXX This was rewritten from Linux driver without any tests.
+ */
 static int
 enable_bnc(struct cs_softc *sc)
 {
 
+	control_dc_dc(sc, 1);
 	cs_writereg(sc, PP_LineCTL,
 	    (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-	control_dc_dc(sc, 1);
+
+	if (!send_test_pkt(sc)) {
+		device_printf(sc->dev, "failed to enable BNC\n");
+		return (EINVAL);
+	}
 	return (0);
 }
 
@@ -432,8 +502,7 @@
 /*
  * Allocate a port resource with the given resource id.
  */
-int
-cs_alloc_port(device_t dev, int rid, int size)
+int cs_alloc_port(device_t dev, int rid, int size)
 {
 	struct cs_softc *sc = device_get_softc(dev);
 	struct resource *res;
@@ -444,19 +513,38 @@
 		return (ENOENT);
 	sc->port_rid = rid;
 	sc->port_res = res;
+	sc->port_used = size;
+	return (0);
+}
+
+/*
+ * Allocate a memory resource with the given resource id.
+ */
+int cs_alloc_memory(device_t dev, int rid, int size)
+{
+	struct cs_softc *sc = device_get_softc(dev);
+	struct resource *res;
+
+	res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
+	    0ul, ~0ul, size, RF_ACTIVE);
+	if (res == NULL)
+		return (ENOENT);
+	sc->mem_rid = rid;
+	sc->mem_res = res;
+	sc->mem_used = size;
 	return (0);
 }
 
 /*
  * Allocate an irq resource with the given resource id.
  */
-int
-cs_alloc_irq(device_t dev, int rid)
+int cs_alloc_irq(device_t dev, int rid, int flags)
 {
 	struct cs_softc *sc = device_get_softc(dev);
 	struct resource *res;
 
-	res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+	res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+	    (RF_ACTIVE | flags));
 	if (res == NULL)
 		return (ENOENT);
 	sc->irq_rid = rid;
@@ -467,8 +555,7 @@
 /*
  * Release all resources
  */
-void
-cs_release_resources(device_t dev)
+void cs_release_resources(device_t dev)
 {
 	struct cs_softc *sc = device_get_softc(dev);
 
@@ -477,6 +564,11 @@
 		    sc->port_rid, sc->port_res);
 		sc->port_res = 0;
 	}
+	if (sc->mem_res) {
+		bus_release_resource(dev, SYS_RES_MEMORY,
+		    sc->mem_rid, sc->mem_res);
+		sc->mem_res = 0;
+	}
 	if (sc->irq_res) {
 		bus_release_resource(dev, SYS_RES_IRQ,
 		    sc->irq_rid, sc->irq_res);
@@ -490,7 +582,7 @@
 int
 cs_attach(device_t dev)
 {
-	int error, media=0;
+	int media=0;
 	struct cs_softc *sc = device_get_softc(dev);;
 	struct ifnet *ifp;
 
@@ -499,26 +591,28 @@
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
 	if (ifp == NULL) {
 		device_printf(dev, "can not if_alloc()\n");
-		cs_release_resources(dev);
-		return (ENOMEM);
+		return (0);
 	}
 
-	mtx_init(&sc->lock, device_get_nameunit(dev), MTX_NETWORK_LOCK,
-	    MTX_DEF);
-	callout_init_mtx(&sc->timer, &sc->lock, 0);
-
-	CS_LOCK(sc);
-	cs_stop(sc);
-	CS_UNLOCK(sc);
+	cs_stop( sc );
 
 	ifp->if_softc=sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_start=cs_start;
 	ifp->if_ioctl=cs_ioctl;
+	ifp->if_watchdog=cs_watchdog;
 	ifp->if_init=cs_init;
-	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
+	ifp->if_snd.ifq_maxlen= IFQ_MAXLEN;
+	/*
+	 *  MIB DATA
+	 */
+	/*
+	ifp->if_linkmib=&sc->mibdata;
+	ifp->if_linkmiblen=sizeof sc->mibdata;
+	*/
 
-	ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+	ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+	    IFF_NEEDSGIANT);
 
 	/*
 	 * this code still in progress (DMA support)
@@ -539,10 +633,7 @@
 	sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT);
 	if (sc->buffer == NULL) {
 		device_printf(sc->dev, "Couldn't allocate memory for NIC\n");
-		if_free(ifp);
-		mtx_destroy(&sc->lock);
-		cs_release_resources(dev);
-		return(ENOMEM);
+		return(0);
 	}
 
 	/*
@@ -593,17 +684,6 @@
 
 	ether_ifattach(ifp, sc->enaddr);
 
-  	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
-	    NULL, csintr, sc, &sc->irq_handle);
-	if (error) {
-		ether_ifdetach(ifp);
-		free(sc->buffer, M_DEVBUF);
-		if_free(ifp);
-		mtx_destroy(&sc->lock);
-		cs_release_resources(dev);
-		return (error);
-	}
-
 	return (0);
 }
 
@@ -616,16 +696,11 @@
 	sc = device_get_softc(dev);
 	ifp = sc->ifp;
 
-	CS_LOCK(sc);
 	cs_stop(sc);
-	CS_UNLOCK(sc);
-	callout_drain(&sc->timer);
+	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 	ether_ifdetach(ifp);
-	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
 	cs_release_resources(dev);
-	free(sc->buffer, M_DEVBUF);
 	if_free(ifp);
-	mtx_destroy(&sc->lock);
 	return (0);
 }
 
@@ -636,24 +711,17 @@
 cs_init(void *xsc)
 {
 	struct cs_softc *sc=(struct cs_softc *)xsc;
-
-	CS_LOCK(sc);
-	cs_init_locked(sc);
-	CS_UNLOCK(sc);
-}
-
-static void
-cs_init_locked(struct cs_softc *sc)
-{
 	struct ifnet *ifp = sc->ifp;
-	int i, rx_cfg;
+	int i, s, rx_cfg;
 
 	/*
-	 * reset watchdog timer
+	 * reset whatchdog timer
 	 */
-	sc->tx_timeout = 0;
+	ifp->if_timer=0;
 	sc->buf_len = 0;
 	
+	s=splimp();
+
 	/*
 	 * Hardware initialization of cs
 	 */
@@ -705,12 +773,13 @@
 	 */
 	sc->ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-	callout_reset(&sc->timer, hz, cs_watchdog, sc);
 
 	/*
 	 * Start sending process
 	 */
-	cs_start_locked(ifp);
+	cs_start(ifp);
+
+	(void) splx(s);
 }
 
 /*
@@ -800,7 +869,6 @@
 	device_printf(sc->dev, "Interrupt.\n");
 #endif
 
-	CS_LOCK(sc);
 	while ((status=cs_inw(sc, ISQ_PORT))) {
 
 #ifdef CS_DEBUG
@@ -818,18 +886,18 @@
 			else
 				ifp->if_oerrors++;
 			ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-			sc->tx_timeout = 0;
+			ifp->if_timer = 0;
 			break;
 
 		case ISQ_BUFFER_EVENT:
 			if (status & READY_FOR_TX) {
 				ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-				sc->tx_timeout = 0;
+				ifp->if_timer = 0;
 			}
 
 			if (status & TX_UNDERRUN) {
 				ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-				sc->tx_timeout = 0;
+				ifp->if_timer = 0;
 				ifp->if_oerrors++;
 			}
 			break;
@@ -845,9 +913,8 @@
 	}
 
 	if (!(ifp->if_drv_flags & IFF_DRV_OACTIVE)) {
-		cs_start_locked(ifp);
+		cs_start(ifp);
 	}
-	CS_UNLOCK(sc);
 }
 
 /*
@@ -892,20 +959,12 @@
 static void
 cs_start(struct ifnet *ifp)
 {
+	int s, length;
+	struct mbuf *m, *mp;
 	struct cs_softc *sc = ifp->if_softc;
 
-	CS_LOCK(sc);
-	cs_start_locked(ifp);
-	CS_UNLOCK(sc);
-}
+	s = splimp();
 
-static void
-cs_start_locked(struct ifnet *ifp)
-{
-	int length;
-	struct mbuf *m, *mp;
-	struct cs_softc *sc = ifp->if_softc;
-
 	for (;;) {
 		if (sc->buf_len)
 			length = sc->buf_len;
@@ -913,6 +972,7 @@
 			IF_DEQUEUE( &ifp->if_snd, m );
 
 			if (m==NULL) {
+				(void) splx(s);
 				return;
 			}
 
@@ -944,7 +1004,8 @@
 		 * and return.
 		 */
 		if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
-			sc->tx_timeout = sc->buf_len;
+			ifp->if_timer = sc->buf_len;
+			(void) splx(s);
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 			return;
 		}
@@ -956,8 +1017,9 @@
 		 * from board again. (I don't know about correct
 		 * value for this timeout)
 		 */
-		sc->tx_timeout = length;
+		ifp->if_timer = length;
 
+		(void) splx(s);
 		ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 		return;
 	}
@@ -969,16 +1031,17 @@
 static void
 cs_stop(struct cs_softc *sc)
 {
+	int s = splimp();
 
-	CS_ASSERT_LOCKED(sc);
 	cs_writereg(sc, PP_RxCFG, 0);
 	cs_writereg(sc, PP_TxCFG, 0);
 	cs_writereg(sc, PP_BufCFG, 0);
 	cs_writereg(sc, PP_BusCTL, 0);
 
 	sc->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
-	sc->tx_timeout = 0;
-	callout_stop(&sc->timer);
+	sc->ifp->if_timer = 0;
+
+	(void) splx(s);
 }
 
 /*
@@ -987,10 +1050,8 @@
 static void
 cs_reset(struct cs_softc *sc)
 {
-
-	CS_ASSERT_LOCKED(sc);
 	cs_stop(sc);
-	cs_init_locked(sc);
+	cs_init(sc);
 }
 
 static uint16_t
@@ -1076,28 +1137,29 @@
 {
 	struct cs_softc *sc=ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
-	int error=0;
+	int s,error=0;
 
 #ifdef CS_DEBUG
 	if_printf(ifp, "%s command=%lx\n", __func__, command);
 #endif
 
+	s=splimp();
+
 	switch (command) {
 	case SIOCSIFFLAGS:
 		/*
 		 * Switch interface state between "running" and
 		 * "stopped", reflecting the UP flag.
 		 */
-		CS_LOCK(sc);
 		if (sc->ifp->if_flags & IFF_UP) {
 			if ((sc->ifp->if_drv_flags & IFF_DRV_RUNNING)==0) {
-				cs_init_locked(sc);
+				cs_init(sc);
 			}
 		} else {
 			if ((sc->ifp->if_drv_flags & IFF_DRV_RUNNING)!=0) {
 				cs_stop(sc);
 			}
-		}		
+		}
 		/*
 		 * Promiscuous and/or multicast flags may have changed,
 		 * so reprogram the multicast filter and/or receive mode.
@@ -1105,7 +1167,6 @@
 		 * See note about multicasts in cs_setmode
 		 */
 		cs_setmode(sc);
-		CS_UNLOCK(sc);
 		break;
 
 	case SIOCADDMULTI:
@@ -1116,9 +1177,7 @@
 	     *
 	     * See note about multicasts in cs_setmode
 	     */
-	    CS_LOCK(sc);
 	    cs_setmode(sc);
-	    CS_UNLOCK(sc);
 	    error = 0;
 	    break;
 
@@ -1132,6 +1191,7 @@
 		break;
 	}
 
+	(void) splx(s);
 	return (error);
 }
 
@@ -1140,23 +1200,18 @@
  * generate an interrupt after a transmit has been started on it.
  */
 static void
-cs_watchdog(void *arg)
+cs_watchdog(struct ifnet *ifp)
 {
-	struct cs_softc *sc = arg;
-	struct ifnet *ifp = sc->ifp;
+	struct cs_softc *sc = ifp->if_softc;
 
-	CS_ASSERT_LOCKED(sc);
-	if (sc->tx_timeout && --sc->tx_timeout == 0) {
-		ifp->if_oerrors++;
-		log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
+	ifp->if_oerrors++;
+	log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
 
-		/* Reset the interface */
-		if (ifp->if_flags & IFF_UP)
-			cs_reset(sc);
-		else
-			cs_stop(sc);
-	}
-	callout_reset(&sc->timer, hz, cs_watchdog, sc);
+	/* Reset the interface */
+	if (ifp->if_flags & IFF_UP)
+		cs_reset(sc);
+	else
+		cs_stop(sc);
 }
 
 static int
@@ -1164,15 +1219,11 @@
 {
 	struct cs_softc *sc = ifp->if_softc;
 	struct ifmedia *ifm = &sc->media;
-	int error;
 
 	if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
 		return (EINVAL);
 
-	CS_LOCK(sc);
-	error = cs_mediaset(sc, ifm->ifm_media);
-	CS_UNLOCK(sc);
-	return (error);
+	return (cs_mediaset(sc, ifm->ifm_media));
 }
 
 static void
@@ -1181,7 +1232,6 @@
 	int line_status;
 	struct cs_softc *sc = ifp->if_softc;
 
-	CS_LOCK(sc);
 	ifmr->ifm_active = IFM_ETHER;
 	line_status = cs_readreg(sc, PP_LineST);
 	if (line_status & TENBASET_ON) {
@@ -1206,7 +1256,6 @@
 				ifmr->ifm_active |= IFM_10_5;
 		}
 	}
-	CS_UNLOCK(sc);
 }
 
 static int
@@ -1225,12 +1274,10 @@
 	switch (IFM_SUBTYPE(media)) {
 	default:
 	case IFM_AUTO:
-		/*
-		 * This chip makes it a little hard to support this, so treat
-		 * it as IFM_10_T, auto duplex.
-		 */
-		enable_tp(sc);
-		cs_duplex_auto(sc);
+		if ((error=enable_tp(sc))==0)
+			error = cs_duplex_auto(sc);
+		else if ((error=enable_bnc(sc)) != 0)
+			error = enable_aui(sc);
 		break;
 	case IFM_10_T:
 		if ((error=enable_tp(sc)) != 0)

==== //depot/projects/soc2005/libalias/sys/dev/cs/if_cs_isa.c#4 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs_isa.c,v 1.11 2008/06/06 05:25:24 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs_isa.c,v 1.7 2007/02/23 12:18:36 piso Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -48,8 +48,8 @@
 #include <dev/cs/if_csvar.h>
 #include <dev/cs/if_csreg.h>
 
-static int		cs_isa_probe(device_t);
-static int		cs_isa_attach(device_t);
+static int		cs_isa_probe	(device_t);
+static int		cs_isa_attach	(device_t);
 
 static struct isa_pnp_id cs_ids[] = {
 	{ 0x4060630e, NULL },		/* CSC6040 */
@@ -63,7 +63,7 @@
 static int
 cs_isa_probe(device_t dev)
 {
-	int error;
+	int error = 0;
 
 	/* Check isapnp ids */
 	error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_ids);
@@ -72,9 +72,11 @@
 	if (error == ENXIO)
                 goto end;
 
-        /* If we've matched, or there's no PNP ID, probe chip */
-	if (error == 0 || error == ENOENT)
-		error = cs_cs89x0_probe(dev);
+        /* If we had some other problem. */
+        if (!(error == 0 || error == ENOENT))
+                goto end;
+
+	error = cs_cs89x0_probe(dev);
 end:
 	/* Make sure IRQ is assigned for probe message and available */
 	if (error == 0)
@@ -88,10 +90,21 @@
 cs_isa_attach(device_t dev)
 {
         struct cs_softc *sc = device_get_softc(dev);
+        int error;
         
 	cs_alloc_port(dev, 0, CS_89x0_IO_PORTS);
+	/* XXX mem appears to not be used at all */
+        if (sc->mem_used)
+                cs_alloc_memory(dev, sc->mem_rid, sc->mem_used);
         cs_alloc_irq(dev, sc->irq_rid, 0);
                 
+        error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
+	    NULL, csintr, sc, &sc->irq_handle);
+        if (error) {
+                cs_release_resources(dev);
+                return (error);
+        }              
+
         return (cs_attach(dev));
 }
 
@@ -99,7 +112,9 @@
 	/* Device interface */
 	DEVMETHOD(device_probe,		cs_isa_probe),
 	DEVMETHOD(device_attach,	cs_isa_attach),
+#ifdef CS_HAS_DETACH
 	DEVMETHOD(device_detach,	cs_detach),
+#endif
 
 	{ 0, 0 }
 };

==== //depot/projects/soc2005/libalias/sys/dev/cs/if_cs_pccard.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs_pccard.c,v 1.23 2008/06/06 05:25:24 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cs/if_cs_pccard.c,v 1.19 2007/02/23 12:18:36 piso Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,10 +58,13 @@
 cs_pccard_probe(device_t dev)
 {
 	const struct pccard_product *pp;
+	int		error;
 	uint32_t	fcn = PCCARD_FUNCTION_UNSPEC;
 
 	/* Make sure we're a network function */
-	pccard_get_function(dev, &fcn);
+	error = pccard_get_function(dev, &fcn);
+	if (error != 0)
+		return (error);
 	if (fcn != PCCARD_FUNCTION_NETWORK)
 		return (ENXIO);
 
@@ -87,6 +90,10 @@
 	error = cs_alloc_irq(dev, sc->irq_rid, 0);
 	if (error != 0)
 		goto bad;
+	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
+	    NULL, csintr, sc, &sc->irq_handle);
+	if (error != 0)
+		goto bad;
 
 	return (cs_attach(dev));
 bad:

==== //depot/projects/soc2005/libalias/sys/dev/cs/if_csreg.h#3 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 /*
- * $FreeBSD: src/sys/dev/cs/if_csreg.h,v 1.7 2008/06/06 04:56:27 imp Exp $
+ * $FreeBSD: src/sys/dev/cs/if_csreg.h,v 1.6 2005/01/06 01:42:32 imp Exp $
  */
 
 #define CS_89x0_IO_PORTS	0x0020
@@ -518,6 +518,9 @@
 #define CS_DUPLEX_FULL		1
 #define CS_DUPLEX_HALF		2
 
+/* Device name */
+#define CS_NAME			"cs"
+
 /*
  * It would appear that for pccards (well, the IBM EtherJet PCMCIA card) that
  * are connected to card bus bridges there's a problem.  For reading the

==== //depot/projects/soc2005/libalias/sys/dev/cs/if_csvar.h#4 (text+ko) ====

@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/cs/if_csvar.h,v 1.12 2008/06/06 05:25:24 imp Exp $
+ * $FreeBSD: src/sys/dev/cs/if_csvar.h,v 1.9 2006/09/15 15:16:10 glebius Exp $
  */
 
 #ifndef _IF_CSVAR_H
@@ -50,7 +50,11 @@
 	struct ifmedia media;		/* Media information */
 
 	int     port_rid;		/* resource id for port range */
+	int     port_used;		/* nonzero if ports used */
 	struct resource* port_res;	/* resource for port range */
+	int     mem_rid;  		/* resource id for memory range */
+	int     mem_used;  		/* nonzero if memory used */
+	struct resource* mem_res;	/* resource for memory range */
 	int     irq_rid;		/* resource id for irq */
 	struct resource* irq_res;	/* resource for irq */
 	void*   irq_handle;		/* handle for irq handler */
@@ -65,20 +69,15 @@
 
 	unsigned char *buffer;
 	int buf_len;
-	struct mtx lock;
-	struct callout timer;
-	int	tx_timeout;
 };
 
-#define	CS_LOCK(sc)		mtx_lock(&(sc)->lock)
-#define	CS_UNLOCK(sc)		mtx_unlock(&(sc)->lock)
-#define	CS_ASSERT_LOCKED(sc)	mtx_assert(&(sc)->lock, MA_OWNED)
-
 int	cs_alloc_port(device_t dev, int rid, int size);
-int	cs_alloc_irq(device_t dev, int rid);
+int	cs_alloc_memory(device_t dev, int rid, int size);
+int	cs_alloc_irq(device_t dev, int rid, int flags);
 int	cs_attach(device_t dev);
 int	cs_cs89x0_probe(device_t dev);
 int	cs_detach(device_t dev);
 void	cs_release_resources(device_t dev);
+driver_intr_t	csintr;
 
 #endif /* _IF_CSVAR_H */


More information about the p4-projects mailing list