Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev From Onno van der Linden:
details: https://anonhg.NetBSD.org/src/rev/facd284bef85
branches: trunk
changeset: 472422:facd284bef85
user: bad <bad%NetBSD.org@localhost>
date: Thu Apr 29 15:47:02 1999 +0000
description:
>From Onno van der Linden:
Reorganise the driver some what.
Rename tr_reset() to the more appropriate tr_stop().
Create a common tropic reset routine and use it in the frontends.
Move the code in tr_config() which is only used in the card attachment
routines into a new tr_attach() function.
Take adapter off the ring through tr_shutdown() in a shutdown hook.
This simplifies the bus-specific frontend.
diffstat:
sys/dev/ic/tropic.c | 284 +++++++++++++++++++++++++++--------------
sys/dev/ic/tropicvar.h | 23 ++-
sys/dev/isa/if_tr_isa.c | 74 +---------
sys/dev/isapnp/if_tr_isapnp.c | 49 +------
4 files changed, 218 insertions(+), 212 deletions(-)
diffs (truncated from 733 to 300 lines):
diff -r 479ab696e263 -r facd284bef85 sys/dev/ic/tropic.c
--- a/sys/dev/ic/tropic.c Thu Apr 29 15:37:21 1999 +0000
+++ b/sys/dev/ic/tropic.c Thu Apr 29 15:47:02 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tropic.c,v 1.2 1999/03/22 23:01:37 bad Exp $ */
+/* $NetBSD: tropic.c,v 1.3 1999/04/29 15:47:02 bad Exp $ */
/*
* Ported to NetBSD by Onno van der Linden
@@ -80,6 +80,8 @@
#include <dev/ic/tropicreg.h>
#include <dev/ic/tropicvar.h>
+static void tr_shutdown __P((void *));
+
void tr_rint __P((struct tr_softc *));
void tr_xint __P((struct tr_softc *));
void tr_oldxint __P((struct tr_softc *));
@@ -127,25 +129,25 @@
case IFM_TOK_STP16:
case IFM_TOK_UTP16:
if ((sc->sc_init_status & RSP_16) == 0) {
- tr_reset(sc);
- if (tr_setspeed(sc, 16) == 0)
- sc->sc_init_status |= RSP_16;
- else
+ tr_stop(sc);
+ if (tr_setspeed(sc, 16))
return EINVAL;
- tr_init(sc);
- tr_sleep(sc);
+ if (tr_reset(sc))
+ return EINVAL;
+ if (tr_config(sc))
+ return EINVAL;
}
break;
case IFM_TOK_STP4:
case IFM_TOK_UTP4:
if ((sc->sc_init_status & RSP_16) != 0) {
- tr_reset(sc);
- if (tr_setspeed(sc, 4) == 0)
- sc->sc_init_status &= ~RSP_16;
- else
+ tr_stop(sc);
+ if (tr_setspeed(sc, 4))
return EINVAL;
- tr_init(sc);
- tr_sleep(sc);
+ if (tr_reset(sc))
+ return EINVAL;
+ if (tr_config(sc))
+ return EINVAL;
}
break;
}
@@ -169,41 +171,75 @@
tr_config(sc)
struct tr_softc *sc;
{
+ if (sc->sc_init_status & FAST_PATH_TRANSMIT) {
+ int i;
+
+ for (i=0; i < SRB_CFP_CMDSIZE; i++)
+ SRB_OUTB(sc, sc->sc_srb, i, 0);
+
+ SRB_OUTB(sc, sc->sc_srb, SRB_CMD, DIR_CONFIG_FAST_PATH_RAM);
+
+ SRB_OUTW(sc, sc->sc_srb, SRB_CFP_RAMSIZE,
+ (16 + (sc->sc_nbuf * FP_BUF_LEN) / 8));
+ SRB_OUTW(sc, sc->sc_srb, SRB_CFP_BUFSIZE, FP_BUF_LEN);
+
+ /* tell adapter: command in SRB */
+ ACA_SETB(sc, ACA_ISRA_o, CMD_IN_SRB);
+
+ for (i = 0; i < 30000; i++) {
+ if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
+ break;
+ delay(100);
+ }
+
+ if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
+ printf("No response for fast path cfg\n");
+ return 1;
+ }
+
+ ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
+
+
+ if ((SRB_INB(sc, sc->sc_srb, SRB_RETCODE) != 0)) {
+ printf("cfg fast path returned: %02x\n",
+ SRB_INB(sc, sc->sc_srb, SRB_RETCODE));
+ return 1;
+ }
+
+ sc->sc_txca = SRB_INW(sc, sc->sc_srb, SRB_CFPRESP_FPXMIT);
+ sc->sc_srb = SRB_INW(sc, sc->sc_srb, SRB_CFPRESP_SRBADDR);
+ }
+ else {
+ if (sc->sc_init_status & RSP_16)
+ sc->sc_maxmtu = sc->sc_dhb16maxsz;
+ else
+ sc->sc_maxmtu = sc->sc_dhb4maxsz;
+/*
+ * XXX Not completely true because Fast Path Transmit has 514 byte buffers
+ * XXX and TR_MAX_LINK_HDR is only correct when source-routing is used.
+ * XXX depending on wether source routing is used change the calculation
+ * XXX use IFM_TOK_SRCRT (IFF_LINK0)
+ * XXX recompute sc_minbuf !!
+ */
+ sc->sc_maxmtu -= TR_MAX_LINK_HDR;
+ }
+ return 0;
+}
+
+int
+tr_attach(sc)
+ struct tr_softc *sc;
+{
int nmedia, *mediaptr, *defmediaptr;
int i, temp;
u_int8_t myaddr[ISO88025_ADDR_LEN];
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- for (i = 0, temp = 0; i < ISO88025_ADDR_LEN; i++, temp += 4) {
- myaddr[i] = (MM_INB(sc, (TR_MAC_OFFSET + temp)) & 0xf) << 4;
- myaddr[i] |= MM_INB(sc, (TR_MAC_OFFSET + temp + 2)) & 0xf;
- }
-
- sc->sc_init_status = SRB_INB(sc, sc->sc_srb, SRB_INIT_STATUS);
-
-/*
- * MAX_MACFRAME_SIZE = DHB_SIZE - 6
- * IPMTU = MAX_MACFRAME_SIZE - (14 + 18 + 8)
- * (14 = header, 18 = sroute, 8 = llcsnap)
- */
-
- /* XXX should depend on sc_resvdmem. */
- if (MM_INB(sc, TR_RAM_OFFSET) == 0xB && sc->sc_memsize == 65536)
- for (i = 0; i < 512; i++)
- SR_OUTB(sc, 0xfe00 + i, 0);
-
if (sc->sc_init_status & FAST_PATH_TRANSMIT) {
- bus_size_t cfg_resp;
bus_size_t srb;
int nbuf = 0;
srb = sc->sc_srb;
- cfg_resp = sc->sc_srb;
-
- for (i=0; i < SRB_CFP_CMDSIZE; i++)
- SRB_OUTB(sc, sc->sc_srb, i, 0);
-
- SRB_OUTB(sc, srb, SRB_CMD, DIR_CONFIG_FAST_PATH_RAM);
switch (sc->sc_memsize) {
case 65536:
@@ -225,41 +261,18 @@
sc->sc_minbuf = ((sc->sc_maxmtu + 511) / 512) + 1;
sc->sc_nbuf = nbuf;
- sc->sc_xmit_head = sc->sc_xmit_tail = 0;
- SRB_OUTW(sc, srb, SRB_CFP_RAMSIZE,
- (16 + (nbuf * FP_BUF_LEN) / 8));
- SRB_OUTW(sc, srb, SRB_CFP_BUFSIZE, FP_BUF_LEN);
- /* tell adapter: command in SRB */
- ACA_SETB(sc, ACA_ISRA_o, CMD_IN_SRB);
-
- for (i = 0; i < 30000; i++) {
- if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
- break;
- delay(100);
- }
-
- if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
- printf("No response for fast path cfg\n");
- return 1;
- }
-
- ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
-
-
- if ((SRB_INB(sc, cfg_resp, SRB_RETCODE) != 0)) {
- printf("cfg fast path returned: %02x\n",
- SRB_INB(sc, cfg_resp, SRB_RETCODE));
- return 1;
- }
-
- sc->sc_txca = SRB_INW(sc, cfg_resp, SRB_CFPRESP_FPXMIT);
- sc->sc_srb = SRB_INW(sc, cfg_resp, SRB_CFPRESP_SRBADDR);
/*
* Create circular queues caching the buffer pointers ?
*/
}
else {
+/*
+ * MAX_MACFRAME_SIZE = DHB_SIZE - 6
+ * IPMTU = MAX_MACFRAME_SIZE - (14 + 18 + 8)
+ * (14 = header, 18 = sroute, 8 = llcsnap)
+ */
+
switch (sc->sc_memsize) {
case 8192:
sc->sc_dhb4maxsz = 2048;
@@ -315,20 +328,11 @@
sc->sc_dhb16maxsz = 8192;
break;
}
- if (sc->sc_init_status & RSP_16)
- sc->sc_maxmtu = sc->sc_dhb16maxsz;
- else
- sc->sc_maxmtu = sc->sc_dhb4maxsz;
-/*
- * XXX Not completely true because Fast Path Transmit has 514 byte buffers
- * XXX and TR_MAX_LINK_HDR is only correct when source-routing is used.
- * XXX depending on wether source routing is used change the calculation
- * XXX use IFM_TOK_SRCRT (IFF_LINK0)
- * XXX recompute sc_minbuf !!
- */
- sc->sc_maxmtu -= TR_MAX_LINK_HDR;
}
+ if (tr_config(sc))
+ return 1;
+
/*
* init network-visible interface
*/
@@ -419,7 +423,14 @@
ifmedia_add(&sc->sc_media, IFM_TOKEN | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_TOKEN | IFM_MANUAL);
}
+
if_attach(ifp);
+
+ for (i = 0, temp = 0; i < ISO88025_ADDR_LEN; i++, temp += 4) {
+ myaddr[i] = (MM_INB(sc, (TR_MAC_OFFSET + temp)) & 0xf) << 4;
+ myaddr[i] |= MM_INB(sc, (TR_MAC_OFFSET + temp + 2)) & 0xf;
+ }
+
token_ifattach(ifp, myaddr);
printf("\n%s: address %s ring speed %d Mbps\n",
@@ -429,6 +440,11 @@
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_IEEE802, sizeof(struct token_header));
#endif
+
+/*
+ * XXX rnd stuff
+ */
+ shutdownhook_establish(tr_shutdown, sc);
return 0;
}
@@ -477,26 +493,85 @@
(*sc->sc_mediastatus)(sc, ifmr);
}
+int
+tr_reset(sc)
+struct tr_softc *sc;
+{
+ int i;
+
+ tr_stop(sc);
+
+ /*
+ * Reset the card.
+ */
+ /* latch on an unconditional adapter reset */
+ bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RESET, 0);
+ delay(50000); /* delay 50ms */
+ /*
+ * XXX set paging if we have the right type of card
+ */
+ /* turn off adapter reset */
+ bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RELEASE, 0);
+
+ /* Enable interrupts. */
+
+ ACA_SETB(sc, ACA_ISRP_e, INT_ENABLE);
+
+ /* Wait for an answer from the adapter. */
+
+ for (i = 0; i < 35000; i++) {
+ if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
+ break;
+ delay(100);
+ }
+
+ if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
+ printf("No response from adapter after reset\n");
+ return 1;
+ }
+ ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
+
+ ACA_OUTB(sc, ACA_RRR_e, (sc->sc_maddr >> 12));
+ sc->sc_srb = ACA_RDW(sc, ACA_WRBR);
Home |
Main Index |
Thread Index |
Old Index