Annotation of lucent/sys/src/9/pc/ether589.c, 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: enum {
                     13:        SelectWindow    = 0x01,         /* SelectWindow command */
                     14: 
                     15:        Command         = 0x0E,         /* all windows */
                     16:        Status          = 0x0E,
                     17: 
                     18:        ManufacturerID  = 0x00,         /* window 0 */
                     19:        ProductID       = 0x02,
                     20:        ConfigControl   = 0x04,
                     21:        AddressConfig   = 0x06,
                     22:        ResourceConfig  = 0x08,
                     23:        EEPROMcmd       = 0x0A,
                     24:        EEPROMdata      = 0x0C,
                     25: };
                     26: 
                     27: #define COMMAND(port, cmd, a)  outs(port+Command, ((cmd)<<11)|(a))
                     28: 
                     29: extern int ether509reset(Ctlr*);
                     30: 
                     31: static int
                     32: reset(Ctlr *ctlr)
                     33: {
                     34:        int slot;
                     35:        int port;
                     36:        ushort x;
                     37: 
                     38:        if(ctlr->card.irq == 0)
                     39:                ctlr->card.irq = 10;
                     40:        if(ctlr->card.port == 0)
                     41:                ctlr->card.port = 0x240;
                     42:        port = ctlr->card.port;
                     43: 
                     44:        slot = pcmspecial("3C589", &ctlr->card);
                     45:        if(slot < 0)
                     46:                return -1;
                     47: 
                     48:        /* set Window 0 configuration registers */
                     49:        COMMAND(port, SelectWindow, 0);
                     50: 
                     51:        /* ROM size & base - must be set before we can access ROM */
                     52:        /* transceiver type (for now always 10baseT) */
                     53:        x = ins(port + AddressConfig);
                     54:        outs(port + AddressConfig, x & 0x20);
                     55: 
                     56:        /* IRQ must be 3 on 3C589 */
                     57:        x = ins(port + ResourceConfig);
                     58:        outs(port + ResourceConfig, 0x3f00 | (x&0xfff));
                     59: 
                     60:        /* move product ID to register */
                     61:        while(ins(port+EEPROMcmd) & 0x8000)
                     62:                ;
                     63:        outs(port+EEPROMcmd, (2<<6)|3);
                     64:        while(ins(port+EEPROMcmd) & 0x8000)
                     65:                ;
                     66:        x = ins(port+EEPROMdata);
                     67:        outs(port + ProductID, x);
                     68: 
                     69:        if(ether509reset(ctlr) < 0){
                     70:                pcmspecialclose(slot);
                     71:                return -1;
                     72:        }
                     73:        return 0;
                     74: }
                     75: 
                     76: void
                     77: ether589link(void)
                     78: {
                     79:        addethercard("3C589", reset);
                     80: }

unix.superglobalmegacorp.com

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