Annotation of researchv9/sys/boot/stand/if_ec.c, revision 1.1.1.1

1.1       root        1: #ifndef ECBOOT
                      2: #ifndef lint
                      3: static char sccsid[] = "@(#)if_ec.c    1.1 86/02/03    Copyr 1983 Sun Micro";
                      4: #endif
                      5: #endif
                      6: 
                      7: /*
                      8:  * Copyright (c) 1983 by Sun Microsystems, Inc.
                      9:  */
                     10: 
                     11: #include "saio.h"
                     12: #include "param.h"
                     13: #include "../h/socket.h"
                     14: #include "../net/if.h"
                     15: #include "../netinet/in.h"
                     16: #include "../netinet/if_ether.h"
                     17: #include "../sunif/if_ecreg.h"
                     18: #include "../mon/sunromvec.h"
                     19: 
                     20: #define millitime() (*romp->v_nmiclock)
                     21: 
                     22: int ecxmit(), ecpoll(), ecreset();
                     23: 
                     24: unsigned int ecstd[] = { 0xE0000, 0xE2000 };
                     25: #define NSTD   2
                     26: 
                     27: struct ec_softc {
                     28:        char    es_proto[PROTOSCRATCH]; /* for higher protocols */
                     29:        struct ecdevice *es_ec;
                     30:        struct  saioreq *es_sip;
                     31: };
                     32: 
                     33: struct devinfo ecinfo = {
                     34:        sizeof(struct ecdevice),        /* size */
                     35:        0,                              /* DMA */
                     36:        sizeof(struct ec_softc),        /* software */
                     37:        NSTD,
                     38:        ecstd,
                     39:        MAP_MBMEM,
                     40:        0,                              /* transfer size handled by ND */
                     41: };
                     42: 
                     43: int xxprobe(), xxboot(), ecopen(), nullsys(), etherstrategy();
                     44: int nullsys();
                     45: 
                     46: struct boottab ecdriver = {
                     47:        "ec", xxprobe, xxboot, ecopen, nullsys,
                     48:        etherstrategy, "ec: 3COM Ethernet", &ecinfo,
                     49: };
                     50: 
                     51: struct saif ecif = {
                     52:        ecxmit,
                     53:        ecpoll,
                     54:        ecreset,
                     55: };
                     56: 
                     57: #define CSRSET(v) ec->ec_csr = (ec->ec_csr & EC_INTPA) | (v)
                     58: #define CSRCLR(v) ec->ec_csr = ec->ec_csr & (EC_INTPA & ~(v))
                     59: 
                     60: ecopen(sip)
                     61:        struct saioreq *sip;
                     62: {
                     63:        register struct ec_softc *es;
                     64: 
                     65:        es = (struct ec_softc *)sip->si_devdata;
                     66:        es->es_ec = (struct ecdevice *)sip->si_devaddr;
                     67:        es->es_sip = sip;
                     68:        sip->si_sif = &ecif;
                     69:        ecreset(es);
                     70:        return (etheropen(sip));
                     71: }
                     72: 
                     73: 
                     74: ecreset(es)
                     75:        register struct ec_softc *es;
                     76: {
                     77:        register struct ecdevice *ec = es->es_ec;
                     78: 
                     79:        ec->ec_csr = EC_RESET;
                     80:        DELAY(20);
                     81:        myetheraddr(&ec->ec_aram);
                     82:        CSRSET(EC_AMSW);
                     83:        CSRSET(EC_PA | EC_ABSW | EC_BBSW);
                     84: }
                     85: 
                     86: ecxmit(es, buf, count)
                     87:        struct ec_softc *es;
                     88:        caddr_t buf;
                     89:        int count;
                     90: {
                     91:        register struct ecdevice *ec = es->es_ec;
                     92:        caddr_t cp;
                     93:        int time = millitime() + 500;   /* .5 seconds */
                     94:        short mask = -1, back;
                     95: 
                     96:        cp = (caddr_t)&ec->ec_abuf[-count];
                     97:        bcopy(buf, cp, count);
                     98:        *(short *)(ec->ec_tbuf) = cp - (caddr_t)ec->ec_tbuf;
                     99:        CSRSET(EC_TBSW);
                    100:        for (;;) {
                    101:                if (millitime() > time) {
                    102:                        ecreset(es);
                    103:                        return (-1);
                    104:                }
                    105:                if (ec->ec_csr & EC_JAM) {
                    106:                        mask <<= 1;
                    107:                        if (mask == 0) {
                    108:                                ecreset(es);
                    109:                                return (-1);
                    110:                        }
                    111:                        back = -(millitime() & ~mask);
                    112:                        if (back == 0)
                    113:                                back = -(0x5555 & ~mask);
                    114:                        ec->ec_back = back;
                    115:                        CSRSET(EC_JAM);
                    116:                }
                    117:                if ((ec->ec_csr & EC_TBSW) == 0)
                    118:                        return (0);
                    119:        }
                    120: }
                    121: 
                    122: ecpoll(es, buf)
                    123:        struct ec_softc *es;
                    124:        char *buf;
                    125: {
                    126:        register struct ecdevice *ec = es->es_ec;
                    127:        short len, *sp;
                    128:        int xbsw = 0;
                    129: 
                    130:        if ((ec->ec_csr & EC_ABSW) == 0) {
                    131:                sp = (short *)ec->ec_abuf;
                    132:                xbsw = EC_ABSW;
                    133:        } else if ((ec->ec_csr & EC_BBSW) == 0) {
                    134:                sp = (short *)ec->ec_bbuf;
                    135:                xbsw = EC_BBSW;
                    136:        } else
                    137:                return (0);
                    138:        len = *sp++ & EC_DOFF;
                    139:        bcopy((char *)sp, buf, len);
                    140:        CSRSET(xbsw);
                    141:        return (len);
                    142: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.