Annotation of lucent/sys/src/9/pc/f002528, revision 1.1.1.1

1.1       root        1: #include "u.h"
                      2: #include "../port/lib.h"
                      3: #include "mem.h"
                      4: #include "dat.h"
                      5: #include "fns.h"
                      6: #include "../port/error.h"
                      7: #include "io.h"
                      8: #include "devtab.h"
                      9: 
                     10: #include "ether.h"
                     11: 
                     12: /*
                     13:  * Driver written for the 'national pcmcia ether adapter', NE 4100.
                     14:  * The manual says NE2000 compatible.
                     15:  * The interface appears to be pretty well described in the National
                     16:  * Semiconductor Local Area Network Databook (1992) as one of the
                     17:  * AT evaluation cards.
                     18:  *
                     19:  * The NE2000 is really just a DP8390[12] plus a data port
                     20:  * and a reset port.
                     21:  */
                     22: enum {
                     23:        Data            = 0x10,         /* offset from I/O base of data port */
                     24:        Misc            = 0x18,         /* offset from I/O base of miscellaneous port */
                     25:        Reset           = 0x1f,         /* offset from I/O base of reset port */
                     26: };
                     27: 
                     28: 
                     29: int
                     30: ne4100reset(Ctlr *ctlr)
                     31: {
                     32:        int i, slot;
                     33:        uchar x, *p;
                     34:        PCMmap *m;
                     35: 
                     36:        /*
                     37:         * Set up the software configuration.
                     38:         * Use defaults for port, irq, mem and size
                     39:         * if not specified.
                     40:         */
                     41:        if(ctlr->card.port == 0)
                     42:                ctlr->card.port = 0x320;
                     43:        if(ctlr->card.irq == 0)
                     44:                ctlr->card.irq = 10;
                     45:        if(ctlr->card.irq == 2)
                     46:                ctlr->card.irq = 9;
                     47:        if(ctlr->card.mem == 0)
                     48:                ctlr->card.mem = 0x4000;
                     49:        if(ctlr->card.size == 0)
                     50:                ctlr->card.size = 16*1024;
                     51: 
                     52:        ctlr->card.reset = ne4100reset;
                     53:        ctlr->card.attach = dp8390attach;
                     54:        ctlr->card.mode = dp8390mode;
                     55:        ctlr->card.read = dp8390read;
                     56:        ctlr->card.write = dp8390write;
                     57:        ctlr->card.receive = dp8390receive;
                     58:        ctlr->card.transmit = dp8390transmit;
                     59:        ctlr->card.intr = dp8390intr;
                     60:        ctlr->card.watch = dp8390watch;
                     61:        ctlr->card.overflow = dp8390overflow;
                     62: 
                     63:        ctlr->card.bit16 = 1;
                     64:        ctlr->card.dp8390 = ctlr->card.port;
                     65:        ctlr->card.data = ctlr->card.port+Data;
                     66: 
                     67:        ctlr->card.tstart = HOWMANY(ctlr->card.mem, Dp8390BufSz);
                     68:        ctlr->card.pstart = ctlr->card.tstart + HOWMANY(sizeof(Etherpkt), Dp8390BufSz);
                     69:        ctlr->card.pstop = ctlr->card.tstart + HOWMANY(ctlr->card.size, Dp8390BufSz);
                     70: 
                     71:        /* see if there's a pcmcia card that looks right */
                     72:        slot = pcmspecial("PC-NIC", &ctlr->card);
                     73:        if(slot < 0)
                     74:                return -1;
                     75: 
                     76:        /* reset ST-NIC */
                     77:        x = inb(ctlr->card.port+Reset);
                     78:        delay(2);
                     79:        outb(ctlr->card.port+Reset, x);
                     80: 
                     81:        /* enable interrupts */
                     82:        outb(ctlr->card.port + Misc, 1<<6);
                     83: 
                     84:        /* Init the (possible) chip. */
                     85:        dp8390reset(ctlr);
                     86: 
                     87:        /* set the ether address */
                     88:        m = pcmmap(slot, 0, 0x1000, 1);
                     89:        if(m == 0)
                     90:                return -1;
                     91:        p = (uchar*)(KZERO|m->isa);
                     92:        for(i = 0; i < sizeof(ctlr->ea); i++)
                     93:                ctlr->ea[i] = p[0xff0+2*i];
                     94:        pcmunmap(slot, m);
                     95:        dp8390setea(ctlr);
                     96: 
                     97:        return 0;
                     98: }
                     99: 
                    100: void
                    101: ether4100link(void)
                    102: {
                    103:        addethercard("NE4100", ne4100reset);
                    104: }

unix.superglobalmegacorp.com

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