Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

rtl8139.h

Go to the documentation of this file.
00001 /*!     \file include/net/rtl8139.h
00002  *      \brief
00003  *              RTL8139C(L) single chip fast ethernet controller
00004  *              driver header.
00005  *      \author Andrea Righi <drizzt@inwind.it>
00006  *      \date Last update: 2003-11-09
00007  *      \note Copyright (&copy;) 2003 Andrea Righi
00008  *
00009  *      \image html rtl8139.jpg "How the RTL8139C controller works"
00010  */
00011 
00012 #ifndef RTL8139_H
00013 #define RTL8139_H
00014 
00015 #include <kernel/semaphore.h>
00016 
00017 //! Threshold is bytes transferred to chip before transmission starts
00018 //! (rounded down to 32 byte units).
00019 #define TX_FIFO_THRESH          256
00020 //! Rx buffer level before first PCI xfer.
00021 #define RX_FIFO_THRESH          4
00022 //! Maximum PCI burst, '4' is 256 bytes.
00023 #define RX_DMA_BURST            4
00024 //! Calculate as 16<<val.
00025 #define TX_DMA_BURST            4
00026 //! Number of Tx descriptor registers.
00027 #define NUM_TX_DESC             4
00028 //! Size of the Tx bounce buffers -- must be at least (dev->mtu+14+4).
00029 #define TX_BUF_SIZE     1536
00030 //! The receive buffer length code: 0, 1, 2 is allowed - 8, 16, 32KB.
00031 #define RX_BUF_LEN_IDX      0
00032 //! The receive buffer length in bytes.
00033 #define RX_BUF_LEN          (8192 << RX_BUF_LEN_IDX)
00034 
00035 // Serial EEPROM section                                                //
00036 #define EE_SHIFT_CLK    0x04    //!< EEPROM shift clock.
00037 #define EE_CS           0x08    //!< EEPROM chip select.
00038 #define EE_DATA_WRITE   0x02    //!< EEPROM chip data in.
00039 #define EE_WRITE_0      0x00    //!< EEPROM write 0.
00040 #define EE_WRITE_1      0x02    //!< EEPROM write 1.
00041 #define EE_DATA_READ    0x01    //!< EEPROM chip data out.
00042 #define EE_ENB          (0x80 | EE_CS)
00043 
00044 //! Delay between EEPROM clock transitions.
00045 //! No extra delay is needed with 33Mhz PCI,
00046 //! but 66Mhz may change this.
00047 #define eeprom_delay()  in32(ee_addr)
00048 
00049 //! EEPROM write command.
00050 #define EE_WRITE_CMD    (5 << 6)
00051 //! EEPROM read command.
00052 #define EE_READ_CMD     (6 << 6)
00053 //! EEPROM erase command.
00054 #define EE_ERASE_CMD    (7 << 6)
00055 
00056 /** \ingroup Drivers
00057  *  \defgroup RTL8139Driver RTL8139C(L) Fast Ethernet Controller
00058  *  The RTL8139C(L) sinle chip fast ethernt controller driver.
00059  *  @{
00060  */
00061 
00062 //! A receive packet structure.
00063 typedef struct rxpacket
00064 {
00065         size_t length;          //!< The packet size.
00066         uint16_t type;          //!< The packet type.
00067         uint8_t data[1];        //!< The packet contents.
00068 } rxpacket_t;
00069 
00070 //! A transmitted packet structure.
00071 typedef struct txpacket
00072 {
00073         //! The transmition buffer number.
00074         int buffer;
00075         //! A timeout for the transmitted packet.
00076         unsigned timeout;
00077 } txpacket_t;
00078 
00079 //! The RTL8139 device structure.
00080 typedef struct rtl8139
00081 {
00082         //! I/O port base address.
00083         uint16_t iobase;
00084         //! The IRQ line.
00085         uint8_t irq;
00086         //! The MAC address.
00087         uint8_t station_address[6];
00088         //! 1=10Mbps / 0=100Mbps.
00089         bool speed10;
00090         //! 1=full-duplex / 0=half-duplex.
00091         bool fullduplex;
00092         //! 1=promiscuous mode ON / 0=promiscuous mode OFF.
00093         bool promisc;
00094         //! Current Tx ring.
00095         unsigned cur_tx;
00096         //! Current Rx ring.
00097         unsigned cur_rx;
00098 
00099         //! Physical address of the Rx ring.
00100         //! Must be placed in the DMA memory area.
00101         addr_t  rx_phys,
00102         //! Physical address of the Tx ring.
00103         //! Must be placed in the DMA memory area.
00104                 tx_phys;
00105         //! The Rx ring buffer (virtual address).
00106         uint8_t *rx_ring,
00107         //! The Tx ring buffer (virtual address).
00108                 *tx_ring;
00109         //! A mutual exclusion semaphore for the RTL8139 device.
00110         semaphore_t mutex;
00111 } rtl8139_t;
00112 
00113 // --- Prototypes ----------------------------------------------------- //
00114 
00115 uint8_t *get_eth_mac_addr();
00116 rtl8139_t *get_rtl8139_device();
00117 int send_rtl8139_packet(rtl8139_t *rtl, const void *data, size_t len);
00118 int rtl8139_init(bool promisc);
00119 void rtl8139_close(rtl8139_t **rtl);
00120 void rtl8139_promisc(rtl8139_t *rtl, bool on);
00121 void rtl8139_dump_info(rtl8139_t *rtl);
00122 void rtl8139_handler();
00123 
00124 /** @} */ // end of RTL8139Driver
00125 
00126 #endif

Generated on Fri Feb 20 15:32:16 2004 for Minirighi by doxygen1.2.18