NE2000.h

Go to the documentation of this file.
00001 
00020 #ifndef _8390_h
00021 #define _8390_h
00022 
00023 /****************************************************************
00024 *                    COMMON DEFINITIONS
00025 ******************************************************************/
00026 
00027 // include project "DEFINE's"
00028 #include <config.h>
00029 // include NE2000 configuration parameters
00030 #include "NE2000_opt.h"
00031 
00034 
00035 // API
00038 void NICReset(void);
00039 
00044 void ei_init(void);
00045 
00062 void ei_transmit( unsigned char * buf, unsigned int send_length);
00063 
00068 unsigned int ei_poll(void);
00074 void ei_tx_intr(void);
00075 
00080 void ei_tx_err(void);
00081 
00099 unsigned int ei_receive(void);
00100 
00113 void ei_rx_overrun(void);
00114 
00131 void ei_nic_write(unsigned char *buf,unsigned int count,unsigned int start_page);
00132 
00147 void ei_nic_read(unsigned char *buf,unsigned int count,unsigned int ring_offset);
00148 
00153 unsigned char ne_probe(void);
00154 
00159 void nic_mem_test(void);
00160 
00161 
00165 unsigned char loopback_test(void);
00166 
00170 unsigned char pktTransmit(void);
00171 
00172 
00173 #define ETHER_ADDR_LEN 6          
00174 #define ETH_ZLEN        60    
00178 #define E8390_TX_IRQ_MASK 0xa   
00179 #define E8390_RX_IRQ_MASK  0x5
00180 #define E8390_RXCONFIG 0x4      
00181 #define E8390_RXOFF 0x20        
00182 #define E8390_TXCONFIG 0x00     
00183 #define E8390_TXOFF 0x02        
00185 
00186 
00188 #define E8390_STOP      0x01    
00189 #define E8390_START     0x02    
00190 #define E8390_TRANS     0x04    
00191 #define E8390_RREAD     0x08    
00192 #define E8390_RWRITE    0x10    
00193 #define E8390_NODMA     0x20    
00194 #define E8390_PAGE0     0x00    
00195 #define E8390_PAGE1     0x40
00196 #define E8390_PAGE2     0x80    
00198 
00199 #define E8390_CMD       0x00    
00203 #define EN0_CLDALO      0x01    
00204 #define EN0_STARTPG     0x01    
00205 #define EN0_CLDAHI      0x02    
00206 #define EN0_STOPPG      0x02    
00207 #define EN0_BOUNDARY    0x03    
00208 #define EN0_TSR         0x04    
00209 #define EN0_TPSR        0x04    
00210 #define EN0_NCR         0x05    
00211 #define EN0_TCNTLO      0x05    
00212 #define EN0_FIFO        0x06    
00213 #define EN0_TCNTHI      0x06    
00214 #define EN0_ISR         0x07    
00215 #define EN0_CRDALO      0x08    
00216 #define EN0_RSARLO      0x08    
00217 #define EN0_CRDAHI      0x09    
00218 #define EN0_RSARHI      0x09    
00219 #define EN0_RCNTLO      0x0a    
00220 #define EN0_RCNTHI      0x0b    
00221 #define EN0_RSR         0x0c    
00222 #define EN0_RXCR        0x0c    
00223 #define EN0_TXCR        0x0d    
00224 #define EN0_COUNTER0    0x0d    
00225 #define EN0_DCFG        0x0e    
00226 #define EN0_COUNTER1    0x0e    
00227 #define EN0_IMR         0x0f    
00228 #define EN0_COUNTER2    0x0f    
00230 
00231 
00233 #define EN1_PHYS   0x01 
00234 #define EN1_CURPAG 0x07 
00235 #define EN1_MULT   0x08 
00237 
00238 
00240 #define ENISR_RX        0x01    
00241 #define ENISR_TX        0x02    
00242 #define ENISR_RX_ERR    0x04    
00243 #define ENISR_TX_ERR    0x08    
00244 #define ENISR_OVER      0x10    
00245 #define ENISR_COUNTERS  0x20    
00246 #define ENISR_RDC       0x40    
00247 #define ENISR_RESET     0x80    
00248 #define ENISR_ALL       0x3f    
00250 
00251 
00253 #define ENDCFG_WTS      0x01    
00255 
00256 
00258 #define ENRSR_RXOK      0x01    
00259 #define ENRSR_CRC       0x02    
00260 #define ENRSR_FAE       0x04    
00261 #define ENRSR_FO        0x08    
00262 #define ENRSR_MPA       0x10    
00263 #define ENRSR_PHY       0x20    
00264 #define ENRSR_DIS       0x40    
00265 #define ENRSR_DEF       0x80    
00267 
00268 
00270 #define ENTSR_PTX 0x01  
00271 #define ENTSR_ND  0x02  
00272 #define ENTSR_COL 0x04  
00273 #define ENTSR_ABT 0x08  
00274 #define ENTSR_CRS 0x10  
00275 #define ENTSR_FU  0x20  
00276 #define ENTSR_CDH 0x40  
00277 #define ENTSR_OWC 0x80  
00279 
00280 
00284 struct net_device_stats
00285 {
00286         unsigned long   rx_packets;             
00287         unsigned long   tx_packets;             
00288         unsigned long   rx_bytes;               
00289         unsigned long   tx_bytes;               
00290         unsigned long   rx_errors;              
00291         unsigned long   tx_errors;              
00292 //        unsigned long   rx_dropped;             /* no space in linux buffers    */
00293 //        unsigned long   tx_dropped;             /* no space available in linux  */
00294         unsigned long   multicast;              
00295         unsigned long   collisions;                             
00296 // 
00297          /* detailed rx_errors: */
00298         unsigned long   rx_length_errors;
00299         unsigned long   rx_over_errors;         
00300         unsigned long   rx_crc_errors;          
00301         unsigned long   rx_frame_errors;        
00302         unsigned long   rx_fifo_errors;         
00303         unsigned long   rx_missed_errors;       
00305         /* detailed tx_errors */
00306         unsigned long   tx_aborted_errors;
00307         unsigned long   tx_carrier_errors;
00308         unsigned long   tx_fifo_errors;
00309         unsigned long   tx_heartbeat_errors;
00310         unsigned long   tx_window_errors;         
00311 };
00312 
00313 /*
00314 // Most of these entries should be in 'struct device' (or most of the
00315 //   things in there should be here!)
00316 // You have one of these per-board
00317 struct ei_device {
00318   unsigned char open:1;
00319   unsigned char word16:1;       // We have the 16-bit (vs 8-bit) version of the card.
00320   unsigned char txing:1;                        // Transmit Active
00321 //  int dmaing:2;                       // Remote DMA Active
00322 //  int irqlock:1;              // 8390's intrs disabled when '1'.
00323   int pingpong:1;               // Using the ping-pong driver
00324   unsigned char tx_start_page, rx_start_page, stop_page;
00325   unsigned char current_page;   // Read pointer in buffer
00326 //  unsigned char interface_num;        // Net port (AUI, 10bT.) to use.
00327 //  unsigned char txqueue;      // Tx Packet buffer queue length.
00328 //  unsigned char in_interrupt;
00329   struct net_device_stats stat;
00330 //  short tx1, tx2;             // Packet lengths for ping-pong tx.
00331   short lasttx;                 // Alpha version consistency check.
00332 //  unsigned char reg0;         // Register '0' in a WD8013
00333 //  unsigned char reg5;         // Register '5' in a WD8013
00334 //  unsigned char saved_irq;    // Original dev->irq value.
00335 };
00336 */
00337 
00341 struct e8390_pkt_hdr {
00342   unsigned char status; // status
00343   unsigned char next;   // pointer to next packet.
00344   unsigned short count; // header + packet lenght in bytes
00345 };
00346 
00347 /****************************************************************
00348 *                    LINUX DEFINITIONS
00349 ******************************************************************/
00350 #ifdef LINUX
00351 
00352 #include <stdio.h>
00353 #define TxStr(_str_) printf(_str_)
00354 #define TxUint(_uint_) printf("%d",_uint_)
00355 #define TxEol() printf("\n")
00356 #define TxHex(_uchar_)  printf("0x%.2x",_uchar_)
00357 #define TxChar(_char_) printf("%c",_char_)
00358 #define TxStr_P(_str_) printf(_str_)
00359 //
00360 // The debug stuff was import from util.h of avr_lib
00361 //
00362 
00363 #ifdef DEBUG
00364 
00365 #define TxStrk(_str_)   TxStr(_str_)
00366 #define TxStrk_P(_str_)   TxStr(_str_)
00367 #define TxUintk(_uchar_) TxUint(_uchar_)
00368 #define TxEolk()            TxEol()
00369 #define TxHexk(_uint_)  TxHex(_uint_)
00370 #define TxChark(_char_) TxChar(_char_)
00371 
00372 #else
00373 
00374 #define TxStrk(_str_)
00375 #define TxStrk_P(_str_)
00376 #define TxUintk(_uint_)
00377 #define TxEolk()
00378 #define TxHexk(_uint_)
00379 #define TxChark(_char_)
00380 
00381 #endif
00382 #endif
00383 
00386 #ifdef AVR
00387 #include <avr/io.h>
00388 #include <util.h> // Serial Port functions(for debugging)
00389 #include <isa_bus.h> // ISA bus acess
00390 // Low level functions in order to be able to use linux driver code
00391 #define outb(_data_out_, _address_outb_) rtl8019write(_data_out_,_address_outb_ )
00392 #define inb(_address_inb_)  rtl8019read(_address_inb_)
00393 #define outb_p              outb
00394 #define inb_p               inb
00395 #define usleep              delay_u
00396 
00397 #endif
00398 
00400 /* Statistics stuff */
00401 #ifdef NE_STATS
00402 #define UPDSTATS( _STAT_ ) _STAT_
00403 #else
00404 #define UPDSTATS( _STAT_ ) 
00405 #endif
00406 
00407 #endif /* _8390_h */
00408 

Generated on Fri Jan 6 22:23:16 2006 for EtherProgs by  doxygen 1.4.5