# ne2k.h

    00001 /**************************************************************************************
    00002  Copyright (c) 2002 The UbixOS Project
    00003  All rights reserved.
    00004
    00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    00006
    00007 Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
    00008 Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
    00009 in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
    00010 contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    00011
    00012 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
    00013 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    00014 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    00015 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    00016 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    00017 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00018 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00019
    00020  $Id$
    00021
    00022 **************************************************************************************/
    00023
    00024 #ifndef _NE2K_H
    00025 #define _NE2K_H
    00026
    00027 #include <ubixos/types.h>
    00028 #include <sys/device.old.h>
    00029
    00030 #define ether_addr  ether_addr_t
    00031 typedef struct dp_rcvhdr
    00032 {
    00033         uInt8 dr_status;                 /* Copy of rsr                       */
    00034         uInt8 dr_next;                   /* Pointer to next packet            */
    00035         uInt8 dr_rbcl;                   /* Receive Byte Count Low            */
    00036         uInt8 dr_rbch;                   /* Receive Byte Count High           */
    00037 } dp_rcvhdr_t;
    00038
    00039 typedef union etheraddr {
    00040     unsigned char bytes[6];             /* byteorder safe initialization */
    00041     unsigned short shorts[3];           /* force 2-byte alignment */
    00042 } ether_addr;
    00043
    00044
    00045 struct nicBuffer {
    00046   struct nicBuffer *next;
    00047   int               length;
    00048   char             *buffer;
    00049   };
    00050
    00051 #define RSR_FO         0x08
    00052 #define RSR_PRX                0x01
    00053 #define DEF_ENABLED    0x200
    00054
    00055 #define OK      0
    00056
    00057
    00058 #define startPage 0x4C
    00059 #define stopPage  0x80
    00060
    00061
    00062 #define NE_CMD       0x00
    00063 #define NE_PSTART    0x01
    00064 #define NE_PSTOP     0x02
    00065 #define NE_BNRY      0x03
    00066 #define NE_TPSR      0x04
    00067 #define NE_ISR       0x07
    00068 #define NE_CURRENT   0x07
    00069 #define NE_RBCR0     0x0A
    00070 #define NE_RBCR1     0x0B
    00071 #define NE_RCR       0x0C
    00072 #define NE_TCR       0x0D
    00073 #define NE_DCR       0x0E
    00074 #define NE_IMR       0x0F
    00075
    00076
    00077 #define NE_DCR_WTS   0x01
    00078 #define NE_DCR_LS    0x08
    00079 #define NE_DCR_AR    0x10
    00080 #define NE_DCR_FT1   0x40
    00081 #define NE_DCR_FT0   0x20
    00082
    00083
    00084
    00085 #define E8390_STOP   0x01
    00086 #define E8390_NODMA  0x20
    00087 #define E8390_PAGE0  0x00
    00088 #define E8390_PAGE1  0x40
    00089 #define E8390_CMD    0x00
    00090 #define E8390_START  0x02
    00091 #define E8390_RREAD  0x08
    00092 #define E8390_RWRITE 0x10
    00093 #define E8390_RXOFF  0x20
    00094 #define E8390_TXOFF  0x00
    00095 #define E8390_RXCONFIG 0x04
    00096 #define E8390_TXCONFIG 0x00
    00097
    00098 #define EN0_COUNTER0 0x0d
    00099 #define EN0_DCFG     0x0e
    00100 #define EN0_RCNTLO   0x0a
    00101 #define EN0_RCNTHI   0x0b
    00102 #define EN0_ISR      0x07
    00103 #define EN0_IMR      0x0f
    00104 #define EN0_RSARLO   0x08
    00105 #define EN0_RSARHI   0x09
    00106 #define EN0_TPSR     0x04
    00107 #define EN0_RXCR     0x0c
    00108 #define EN0_TXCR     0x0D
    00109 #define EN0_STARTPG  0x01
    00110 #define EN0_STOPPG   0x02
    00111 #define EN0_BOUNDARY 0x03
    00112
    00113 #define EN1_PHYS     0x01
    00114 #define EN1_CURPAG   0x07
    00115 #define EN1_MULT     0x08
    00116
    00117 #define NE1SM_START_PG 0x20
    00118 #define NE1SM_STOP_PG 0x40
    00119 #define NESM_START_PG 0x40
    00120 #define NESM_STOP_PG  0x80
    00121
    00122 #define ENISR_ALL    0x3f
    00123
    00124 #define ENDCFG_WTS   0x01
    00125
    00126 #define NE_DATAPORT  0x10
    00127
    00128 #define TX_2X_PAGES 12
    00129 #define TX_1X_PAGES 6
    00130 #define TX_PAGES (dev->priv->pingPong ? TX_2X_PAGES : TX_1X_PAGES)
    00131
    00132
    00133 #define DP_CURR         0x7     /* Current Page Register             */
    00134 #define DP_MAR0         0x8     /* Multicast Address Register 0      */
    00135 #define DP_MAR1         0x9     /* Multicast Address Register 1      */
    00136 #define DP_MAR2         0xA     /* Multicast Address Register 2      */
    00137 #define DP_MAR3         0xB     /* Multicast Address Register 3      */
    00138 #define DP_MAR4         0xC     /* Multicast Address Register 4      */
    00139 #define DP_MAR5         0xD     /* Multicast Address Register 5      */
    00140 #define DP_MAR6         0xE     /* Multicast Address Register 6      */
    00141 #define DP_MAR7         0xF     /* Multicast Address Register 7      */
    00142
    00143 #define DP_CNTR0        0xD     /* Tally Counter 0                   */
    00144 #define DP_CNTR1        0xE     /* Tally Counter 1                   */
    00145 #define DP_CNTR2        0xF     /* Tally Counter 2                   */
    00146
    00147
    00148 #define DP_PAGESIZE     256
    00149
    00150 extern char *nicPacket;
    00151 extern uInt32 packetLength;
    00152
    00153
    00154 int ne2kInit(uInt32);
    00155 int ne2kProbe(int,struct device *);
    00156 int ne2kDevInit(struct device *);
    00157 void NS8390_init(struct device *dev,int startp);
    00158
    00159 void ne2kISR();
    00160 void ne2kHandler();
    00161
    00162 int NICtoPC(struct device *dev,void *packet,int length,int nic_addr);
    00163 int PCtoNIC(struct device *dev,void *packet,int length);
    00164
    00165 struct nicBuffer *ne2kAllocBuffer(int);
    00166 struct nicBuffer *ne2kGetBuffer();
    00167 void ne2kFreeBuffer(struct nicBuffer *);
    00168
    00169 #endif
    00170
    00171 /***
    00172  END
    00173  ***/
    00174