lnc.h

00001 #ifndef _LNC_H
00002 #define _LNC_H
00003 
00004 #include <ubixos/types.h>
00005 
00006 #define NDESC(len2) (1 << len2)
00007 #define NORMAL 0
00008 #define MEM_SLEW 8
00009 #define TRANSBUFSIZE 1518
00010 #define RECVBUFSIZE 1518
00011 #define NRDRE 3
00012 #define NTDRE 3
00013 #define    ETHER_ADDR_LEN          6
00014 #define NE2100_IOSIZE  24
00015 #define PCNET_RDP    0x10        /* Register Data Port */
00016 #define PCNET_RAP    0x12        /* Register Address Port */
00017 #define PCNET_RESET  0x14
00018 #define PCNET_BDP    0x16
00019 #define PCNET_VSW    0x18
00020 #define NE2100          2
00021 
00022 /* mem_mode values */
00023 #define DMA_FIXED       1
00024 #define DMA_MBUF        2
00025 #define SHMEM           4
00026 
00027 
00028 /********** Chip Types **********/
00029 #define UNKNOWN         0        /* Unknown  */
00030 #define LANCE           1        /* Am7990   */
00031 #define C_LANCE         2        /* Am79C90  */
00032 #define PCnet_ISA       3        /* Am79C960 */
00033 #define PCnet_ISAplus   4        /* Am79C961 */
00034 #define PCnet_ISA_II    5        /* Am79C961A */
00035 #define PCnet_32        6        /* Am79C965 */
00036 #define PCnet_PCI       7        /* Am79C970 */
00037 #define PCnet_PCI_II    8        /* Am79C970A */
00038 #define PCnet_FAST      9        /* Am79C971 */
00039 #define PCnet_FASTplus  10       /* Am79C972 */
00040 #define PCnet_Home      11       /* Am79C978 */
00041 
00042 /******** AM7990 Specifics **************/
00043 #define CSR0    0x0000
00044 #define CSR1    1
00045 #define CSR2    2
00046 #define CSR3    3
00047 #define CSR88   88
00048 #define CSR89   89
00049 
00050 #define ERR     0x8000
00051 #define BABL    0x4000
00052 #define CERR    0x2000
00053 #define MISS    0x1000
00054 #define MERR    0x0800
00055 #define RINT    0x0400
00056 #define TINT    0x0200
00057 #define IDON    0x0100
00058 #define INTR    0x0080
00059 #define INEA    0x0040
00060 #define RXON    0x0020
00061 #define TXON    0x0010
00062 #define TDMD    0x0008
00063 #define STOP    0x0004
00064 #define STRT    0x0002
00065 #define INIT    0x0001
00066 
00067 
00068 /* CSR88-89: Chip ID masks */
00069 #define AMD_MASK  0x003
00070 #define PART_MASK 0xffff
00071 #define Am79C960  0x0003
00072 #define Am79C961  0x2260
00073 #define Am79C961A 0x2261
00074 #define Am79C965  0x2430
00075 #define Am79C970  0x0242
00076 #define Am79C970A 0x2621
00077 #define Am79C971  0x2623
00078 #define Am79C972  0x2624
00079 #define Am79C973  0x2625
00080 #define Am79C978  0x2626
00081 
00082 /********** Structs **********/
00083 
00084 
00085 
00086 
00087 struct initBlock {
00088   uInt16 mode;           /* Mode register                        */
00089   uInt8  padr[6];        /* Ethernet address                     */
00090   uInt8  ladrf[8];       /* Logical address filter (multicast)   */
00091   uInt16 rdra;           /* Low order pointer to receive ring    */
00092   uInt16 rlen;           /* High order pointer and no. rings     */
00093   uInt16 tdra;           /* Low order pointer to transmit ring   */
00094   uInt16 tlen;           /* High order pointer and no rings      */
00095   };
00096 
00097 struct mds {
00098   uInt16 md0;
00099   uInt16 md1;
00100   short  md2;
00101   uInt16 md3;
00102   };
00103 
00104 struct hostRingEntry {
00105   struct mds *md;
00106   union {
00107     //struct mbuf *mbuf;
00108     char *data;
00109     }buff;
00110   };
00111 
00112 struct arpcom {
00113   //struct  ifnet ac_if;            /* network-visible interface */
00114   uInt8  ac_enaddr[6];           /* ethernet hardware address */
00115   int    ac_multicnt;            /* length of ac_multiaddrs list */
00116   void   *ac_netgraph;           /* ng_ether(4) netgraph node info */
00117   };
00118 
00119 struct nicInfo {
00120   int ident;         /* Type of card */
00121   int ic;            /* Type of ic, Am7990, Am79C960 etc. */
00122   int memMode;
00123   int iobase;
00124   int mode;          /* Mode setting at initialization */
00125   };
00126 
00127 struct lncInfo {
00128   struct arpcom        arpcom;
00129   struct nicInfo       nic;
00130   struct hostRingEntry *recvRing;
00131   struct hostRingEntry *transRings;
00132   struct initBlock     *initBloack;
00133   int                  rap;
00134   int                  rdp;
00135   int                  bdp;
00136   int                  nrdre;
00137   int                  ntdre;
00138   };
00139 
00140 extern struct lncInfo *lnc;
00141 
00142 void writeCsr(struct lncInfo *lnc, uInt16 port, uInt16 val);
00143 uInt16 readCsr(struct lncInfo *lnc, uInt16 port);
00144 void writeBcr(struct lncInfo *lnc, uInt16 port, uInt16 val);
00145 uInt16 readBcr(struct lncInfo *lnc, uInt16 port);
00146 
00147 void initLNC();
00148 int probe(struct lncInfo *lnc);
00149 int lanceProbe(struct lncInfo *lnc);
00150 int lncAttach(struct lncInfo *lnc,int unit);
00151 
00152 
00153 void lncInt();
00154 void _lncInt();
00155 
00156 #endif
00157 

Generated on Wed Apr 28 17:49:37 2004 for Ubixos by doxygen 1.3.3