Annotation of lucent/sys/src/boot/pc/ether.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * All the goo for PC ethernet cards.
        !             3:  */
        !             4: typedef struct Card Card;
        !             5: typedef struct RingBuf RingBuf;
        !             6: typedef struct Type Type;
        !             7: typedef struct Ctlr Ctlr;
        !             8: 
        !             9: /*
        !            10:  * Hardware interface.
        !            11:  */
        !            12: struct Card {
        !            13:        ISAConf;
        !            14: 
        !            15:        int     (*reset)(Ctlr*);
        !            16:        void    (*attach)(Ctlr*);
        !            17: 
        !            18:        void    *(*read)(Ctlr*, void*, ulong, ulong);
        !            19:        void    *(*write)(Ctlr*, ulong, void*, ulong);
        !            20: 
        !            21:        void    (*receive)(Ctlr*);
        !            22:        void    (*transmit)(Ctlr*);
        !            23:        void    (*intr)(Ureg*, Ctlr*);
        !            24:        void    (*overflow)(Ctlr*);
        !            25: 
        !            26:        uchar   bit16;                  /* true if a 16 bit interface */
        !            27:        uchar   ram;                    /* true if card has shared memory */
        !            28: 
        !            29:        ulong   dp8390;                 /* I/O address of 8390 (if any) */
        !            30:        ulong   data;                   /* I/O data port if no shared memory */
        !            31:        uchar   nxtpkt;                 /* software bndry */
        !            32:        uchar   tstart;                 /* 8390 ring addresses */
        !            33:        uchar   pstart;
        !            34:        uchar   pstop;
        !            35: };
        !            36: 
        !            37: /*
        !            38:  * Software ring buffer.
        !            39:  */
        !            40: struct RingBuf {
        !            41:        uchar   owner;
        !            42:        uchar   busy;                   /* unused */
        !            43:        ushort  len;
        !            44:        uchar   pkt[sizeof(Etherpkt)];
        !            45: };
        !            46: 
        !            47: enum {
        !            48:        Host            = 0,            /* buffer owned by host */
        !            49:        Interface       = 1,            /* buffer owned by card */
        !            50: 
        !            51:        Nrb             = 16,           /* default number of receive buffers */
        !            52:        Ntb             = 1,            /* default number of transmit buffers */
        !            53: };
        !            54: 
        !            55: /*
        !            56:  * Software controller.
        !            57:  */
        !            58: struct Ctlr {
        !            59:        Card    card;                   /* hardware info */
        !            60:        int     ctlrno;
        !            61:        char    iname[NAMELEN];
        !            62:        char    oname[NAMELEN];
        !            63:        int     present;
        !            64: 
        !            65:        ushort  nrb;                    /* number of software receive buffers */
        !            66:        ushort  ntb;                    /* number of software transmit buffers */
        !            67:        RingBuf *rb;                    /* software receive buffers */
        !            68:        RingBuf *tb;                    /* software transmit buffers */
        !            69: 
        !            70:        ushort  rh;                     /* first receive buffer belonging to host */
        !            71:        ushort  ri;                     /* first receive buffer belonging to card */    
        !            72: 
        !            73:        ushort  th;                     /* first transmit buffer belonging to host */   
        !            74:        ushort  ti;                     /* first transmit buffer belonging to card */
        !            75:        int     tbusy;                  /* transmitter is busy */       
        !            76: 
        !            77:        int     inpackets;
        !            78:        int     outpackets;
        !            79:        int     crcs;                   /* input crc errors */
        !            80:        int     oerrs;                  /* output errors */
        !            81:        int     frames;                 /* framing errors */
        !            82:        int     overflows;              /* packet overflows */
        !            83:        int     buffs;                  /* buffering errors */
        !            84: };
        !            85: 
        !            86: #define NEXT(x, l)     (((x)+1)%(l))
        !            87: #define        HOWMANY(x, y)   (((x)+((y)-1))/(y))
        !            88: #define ROUNDUP(x, y)  (HOWMANY((x), (y))*(y))
        !            89: 
        !            90: /*
        !            91:  * The Western Digital 8003 and 8013 series, the NE2000
        !            92:  * and the 3Com 503 all use the DP8390 Network Interface
        !            93:  * Chip.
        !            94:  */
        !            95: extern void dp8390reset(Ctlr*);
        !            96: extern void dp8390attach(Ctlr*);
        !            97: extern void dp8390mode(Ctlr*, int);
        !            98: extern void dp8390getea(Ctlr*);
        !            99: extern void dp8390setea(Ctlr*);
        !           100: extern void *dp8390read(Ctlr*, void*, ulong, ulong);
        !           101: extern void *dp8390write(Ctlr*, ulong, void*, ulong);
        !           102: extern void dp8390receive(Ctlr*);
        !           103: extern void dp8390transmit(Ctlr*);
        !           104: extern void dp8390intr(Ureg*, Ctlr*);
        !           105: extern void dp8390overflow(Ctlr*);
        !           106: 
        !           107: /*
        !           108:  * The DP8390 needs some time between successive 
        !           109:  * chip selects, so we need special I/O routines.
        !           110:  * See l.s.
        !           111:  * These routines only need to be used for accessing
        !           112:  * the chip registers. Data I/O, either through
        !           113:  * remote DMA or shared memory, can use the normal
        !           114:  * routines.
        !           115:  */
        !           116: extern int dp8390inb(ulong);
        !           117: extern void dp8390outb(ulong, uchar);
        !           118: 
        !           119: enum {
        !           120:        Dp8390BufSz     = 256,          /* hardware ring buffer size */
        !           121: };
        !           122: 
        !           123: extern int ne2000reset(Ctlr*);
        !           124: extern int ne3210reset(Ctlr*);
        !           125: extern int tcm509reset(Ctlr*);
        !           126: extern int wd8003reset(Ctlr*);

unix.superglobalmegacorp.com

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