Main Page | Directories | File List | Globals

rtl_8029.c File Reference

#include <agnix/agnix.h>
#include <agnix/init.h>
#include <agnix/adi/adi.h>
#include <agnix/ioport.h>
#include <agnix/console.h>
#include <agnix/irq.h>
#include <agnix/memory.h>
#include <agnix/net/net.h>
#include <agnix/counters.h>

Include dependency graph for rtl_8029.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "NET_RTL_8029: "
#define RTL_8029_MAX_RESET_TIME   10
#define RTL_8029_CR   0x00
#define RTL_8029_CLDA0   0x01
#define RTL_8029_CLDA1   0x02
#define RTL_8029_BNRY   0x03
#define RTL_8029_TSR   0x04
#define RTL_8029_NCR   0x05
#define RTL_8029_FIFO   0x06
#define RTL_8029_ISR   0x07
#define RTL_8029_CRDA0   0x08
#define RTL_8029_CRDA1   0x09
#define RTL_8029_RSR   0x0c
#define RTL_8029_CNTR0   0x0d
#define RTL_8029_CNTR1   0x0e
#define RTL_8029_CNTR2   0x0f
#define RTL_8029_DMADATA   0x10
#define RTL_8029_RESET   0x1f
#define RTL_8029_PSTART   0x01
#define RTL_8029_PSTOP   0x02
#define RTL_8029_TPSR   0x04
#define RTL_8029_TBCR0   0x05
#define RTL_8029_TBCR1   0x06
#define RTL_8029_RSAR0   0x08
#define RTL_8029_RSAR1   0x09
#define RTL_8029_RBCR0   0x0a
#define RTL_8029_RBCR1   0x0b
#define RTL_8029_RCR   0x0c
#define RTL_8029_TCR   0x0d
#define RTL_8029_DCR   0x0e
#define RTL_8029_IMR   0x0f
#define CR_STP   0x01
#define CR_STA   0x02
#define CR_TXP   0x04
#define CR_READ_DMA   0x08
#define CR_WRITE_DMA   0x10
#define CR_ABORT_DMA   0x20
#define CR_PAGE0   0x00
#define CR_PAGE1   0x40
#define CR_PAGE2   0x80
#define ISR_PRX   0x01
#define ISR_PTX   0x02
#define ISR_PRXE   0x04
#define ISR_PTXE   0x08
#define ISR_OVW   0x10
#define ISR_CNT   0x20
#define ISR_RDC   0x40
#define ISR_RESET   0x80
#define IMR_PRXE   0x01
#define IMR_PTXE   0x02
#define IMR_RXEE   0x04
#define IMR_TXEE   0x08
#define IMR_OVWE   0x10
#define IMR_CNTE   0x20
#define IMR_RDCE   0x40
#define RCR_BROADCAST   0x04
#define RCR_MULTICAST   0x08
#define RCR_PROMISC   0x10
#define RTL_8029_CURR   0x07
#define RTL_8029_CURR   0x07
#define RTL_8029_TX_PAGES   12
#define NET_RECV_MODE_BROADCAST   0x01
#define NET_RECV_MODE_MULTICAST   0x02
#define NET_RECV_MODE_PROMISC   0x04
#define RTL_8029_MIN_FRB_LEN   63
#define RTL_8029_DEBUG   0

Functions

int rtl_8029_reset (struct pcidev_s *pcidev)
int rtl_8029_set_recv_mode (struct adi_netdev_s *netdev, int recv_mode)
int rtl_8029_open (void)
int rtl_8029_send_frame (struct frb_s *frb)
int rtl_8029_receive_frame (struct frb_s *frb)
int rtl_8029_receive_frames (struct adi_netdev_s *netdev)
void rtl_8029_irq (u32 data)
int rtl_8029_open_driver (struct adi_netdev_s *netdev)
int rtl_8029_close_driver (struct adi_netdev_s *netdev)
int rtl_8029_probe (struct pcidev_s *pcidev, struct adi_driver_id_s *adi_driver_id)
int rtl_8029_remove (struct pcidev_s *pcidev)
int adi_netdrv_rtl_8029_init (void)

Variables

int counter_jiffies_desc
u32 rtl_iobase
u8 rtl_eprom [32]
adi_netdev_s rtl_8029_netdev
rtl_8029_param_s rtl_8029_netdev_param
adi_driver_id_s rtl_8029_driver_id []
irq_routine_s rtl_8029_irq_routine
adi_netdev_ops_s rtl_8029_netdev_ops
adi_driver_pci_s rtl_8029_driver_pci
adi_driver_s rtl_8029_driver


Define Documentation

#define CR_ABORT_DMA   0x20
 

Definition at line 79 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define CR_PAGE0   0x00
 

Definition at line 80 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define CR_PAGE1   0x40
 

Definition at line 81 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_receive_frame().

#define CR_PAGE2   0x80
 

Definition at line 82 of file rtl_8029.c.

#define CR_READ_DMA   0x08
 

Definition at line 77 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define CR_STA   0x02
 

Definition at line 75 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define CR_STP   0x01
 

Definition at line 74 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_receive_frame().

#define CR_TXP   0x04
 

Definition at line 76 of file rtl_8029.c.

Referenced by rtl_8029_send_frame().

#define CR_WRITE_DMA   0x10
 

Definition at line 78 of file rtl_8029.c.

Referenced by rtl_8029_send_frame().

#define IMR_CNTE   0x20
 

Definition at line 105 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define IMR_OVWE   0x10
 

Definition at line 104 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define IMR_PRXE   0x01
 

Definition at line 100 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define IMR_PTXE   0x02
 

Definition at line 101 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define IMR_RDCE   0x40
 

Definition at line 106 of file rtl_8029.c.

#define IMR_RXEE   0x04
 

Definition at line 102 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define IMR_TXEE   0x08
 

Definition at line 103 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define ISR_CNT   0x20
 

Definition at line 92 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_OVW   0x10
 

Definition at line 91 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_PRX   0x01
 

Definition at line 87 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_PRXE   0x04
 

Definition at line 89 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_PTX   0x02
 

Definition at line 88 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_PTXE   0x08
 

Definition at line 90 of file rtl_8029.c.

Referenced by rtl_8029_irq().

#define ISR_RDC   0x40
 

Definition at line 93 of file rtl_8029.c.

Referenced by rtl_8029_irq(), and rtl_8029_send_frame().

#define ISR_RESET   0x80
 

Definition at line 94 of file rtl_8029.c.

Referenced by rtl_8029_irq(), and rtl_8029_reset().

#define MOD_NAME   "NET_RTL_8029: "
 

Definition at line 29 of file rtl_8029.c.

#define NET_RECV_MODE_BROADCAST   0x01
 

Definition at line 138 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_set_recv_mode().

#define NET_RECV_MODE_MULTICAST   0x02
 

Definition at line 139 of file rtl_8029.c.

Referenced by rtl_8029_set_recv_mode().

#define NET_RECV_MODE_PROMISC   0x04
 

Definition at line 140 of file rtl_8029.c.

Referenced by rtl_8029_set_recv_mode().

#define RCR_BROADCAST   0x04
 

Definition at line 111 of file rtl_8029.c.

Referenced by rtl_8029_set_recv_mode().

#define RCR_MULTICAST   0x08
 

Definition at line 112 of file rtl_8029.c.

Referenced by rtl_8029_set_recv_mode().

#define RCR_PROMISC   0x10
 

Definition at line 113 of file rtl_8029.c.

Referenced by rtl_8029_set_recv_mode().

#define RTL_8029_BNRY   0x03
 

Definition at line 39 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_receive_frame().

#define RTL_8029_CLDA0   0x01
 

Definition at line 37 of file rtl_8029.c.

#define RTL_8029_CLDA1   0x02
 

Definition at line 38 of file rtl_8029.c.

#define RTL_8029_CNTR0   0x0d
 

Definition at line 47 of file rtl_8029.c.

#define RTL_8029_CNTR1   0x0e
 

Definition at line 48 of file rtl_8029.c.

#define RTL_8029_CNTR2   0x0f
 

Definition at line 49 of file rtl_8029.c.

#define RTL_8029_CR   0x00
 

Definition at line 36 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_CRDA0   0x08
 

Definition at line 44 of file rtl_8029.c.

#define RTL_8029_CRDA1   0x09
 

Definition at line 45 of file rtl_8029.c.

#define RTL_8029_CURR   0x07
 

Definition at line 126 of file rtl_8029.c.

#define RTL_8029_CURR   0x07
 

Definition at line 126 of file rtl_8029.c.

Referenced by rtl_8029_probe().

#define RTL_8029_DCR   0x0e
 

Definition at line 68 of file rtl_8029.c.

Referenced by rtl_8029_probe().

#define RTL_8029_DEBUG   0
 

Definition at line 142 of file rtl_8029.c.

#define RTL_8029_DMADATA   0x10
 

Definition at line 51 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_FIFO   0x06
 

Definition at line 42 of file rtl_8029.c.

#define RTL_8029_IMR   0x0f
 

Definition at line 69 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define RTL_8029_ISR   0x07
 

Definition at line 43 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), rtl_8029_reset(), and rtl_8029_send_frame().

#define RTL_8029_MAX_RESET_TIME   10
 

Definition at line 31 of file rtl_8029.c.

Referenced by rtl_8029_reset().

#define RTL_8029_MIN_FRB_LEN   63
 

Definition at line 141 of file rtl_8029.c.

Referenced by rtl_8029_send_frame().

#define RTL_8029_NCR   0x05
 

Definition at line 41 of file rtl_8029.c.

#define RTL_8029_PSTART   0x01
 

Definition at line 57 of file rtl_8029.c.

Referenced by rtl_8029_probe().

#define RTL_8029_PSTOP   0x02
 

Definition at line 58 of file rtl_8029.c.

Referenced by rtl_8029_probe().

#define RTL_8029_RBCR0   0x0a
 

Definition at line 64 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_RBCR1   0x0b
 

Definition at line 65 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_RCR   0x0c
 

Definition at line 66 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_set_recv_mode().

#define RTL_8029_RESET   0x1f
 

Definition at line 52 of file rtl_8029.c.

Referenced by rtl_8029_reset().

#define RTL_8029_RSAR0   0x08
 

Definition at line 62 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_RSAR1   0x09
 

Definition at line 63 of file rtl_8029.c.

Referenced by rtl_8029_probe(), rtl_8029_receive_frame(), and rtl_8029_send_frame().

#define RTL_8029_RSR   0x0c
 

Definition at line 46 of file rtl_8029.c.

#define RTL_8029_TBCR0   0x05
 

Definition at line 60 of file rtl_8029.c.

Referenced by rtl_8029_send_frame().

#define RTL_8029_TBCR1   0x06
 

Definition at line 61 of file rtl_8029.c.

Referenced by rtl_8029_send_frame().

#define RTL_8029_TCR   0x0d
 

Definition at line 67 of file rtl_8029.c.

Referenced by rtl_8029_probe().

#define RTL_8029_TPSR   0x04
 

Definition at line 59 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_send_frame().

#define RTL_8029_TSR   0x04
 

Definition at line 40 of file rtl_8029.c.

#define RTL_8029_TX_PAGES   12
 

Definition at line 133 of file rtl_8029.c.

Referenced by rtl_8029_probe(), and rtl_8029_receive_frame().


Function Documentation

int adi_netdrv_rtl_8029_init void   ) 
 

Definition at line 567 of file rtl_8029.c.

References adi_register_driver(), and rtl_8029_driver.

Referenced by adi_netdrv_init().

00568 {
00569     adi_register_driver(&rtl_8029_driver);
00570 
00571     return 0;
00572 }

Here is the call graph for this function:

int rtl_8029_close_driver struct adi_netdev_s *  netdev  ) 
 

Definition at line 428 of file rtl_8029.c.

00429 {
00430     return 0;
00431 }

void rtl_8029_irq u32  data  ) 
 

Definition at line 371 of file rtl_8029.c.

References CR_ABORT_DMA, CR_PAGE0, ISR_CNT, ISR_OVW, ISR_PRX, ISR_PRXE, ISR_PTX, ISR_PTXE, ISR_RDC, ISR_RESET, MOD_NAME, printk(), RTL_8029_CR, RTL_8029_ISR, rtl_8029_netdev, rtl_8029_netdev_param, rtl_8029_receive_frames(), and rtl_iobase.

00372 {
00373     int max_irq_services;
00374     u8 irq_status;
00375 
00376     spin_lock(&rtl_8029_netdev.if_lock);
00377 
00378     max_irq_services = 0;
00379     outb(CR_PAGE0 | CR_ABORT_DMA, rtl_iobase + RTL_8029_CR);
00380     while((max_irq_services++ < 16) && (irq_status = inb(rtl_iobase + RTL_8029_ISR))) {
00381 
00382         if (irq_status & ISR_PRX) {
00383 #if RTL_8029_DEBUG
00384             printk(MOD_NAME "PRX irq\n");
00385 #endif
00386             outb(ISR_PRX, rtl_iobase + RTL_8029_ISR);
00387             rtl_8029_receive_frames(&rtl_8029_netdev);
00388         } 
00389         
00390         if (irq_status & ISR_PTX) {
00391 #if RTL_8029_DEBUG
00392             printk(MOD_NAME "PTX irq\n");
00393 #endif
00394             outb(ISR_PTX, rtl_iobase + RTL_8029_ISR);
00395             rtl_8029_netdev_param.tx_busy[0] = 0;
00396         }
00397         
00398         if (irq_status & ISR_PTXE) {
00399 #if RTL_8029_DEBUG
00400             printk(MOD_NAME "PTXE irq\n");
00401 #endif
00402             outb(ISR_PTXE, rtl_iobase + RTL_8029_ISR);
00403         }
00404 
00405         if (irq_status & ISR_PRXE) {
00406 #if RTL_8029_DEBUG
00407             printk(MOD_NAME "PRXE irq\n");
00408 #endif
00409             outb(ISR_PRXE, rtl_iobase + RTL_8029_ISR);
00410         }
00411         
00412         if (irq_status & (ISR_OVW | ISR_CNT | ISR_RDC | ISR_RESET)) {
00413             outb(ISR_OVW | ISR_CNT | ISR_RDC | ISR_RESET, rtl_iobase + RTL_8029_ISR);
00414         }
00415     }
00416 
00417     outb(CR_PAGE0 | CR_ABORT_DMA, rtl_iobase + RTL_8029_CR);
00418     outb(0xff, rtl_iobase + RTL_8029_ISR);
00419     
00420     spin_unlock(&rtl_8029_netdev.if_lock);
00421 }

Here is the call graph for this function:

int rtl_8029_open void   ) 
 

Definition at line 201 of file rtl_8029.c.

00202 {
00203     return 0;
00204 }

int rtl_8029_open_driver struct adi_netdev_s *  netdev  ) 
 

Definition at line 423 of file rtl_8029.c.

00424 {
00425     return 0;
00426 }

int rtl_8029_probe struct pcidev_s *  pcidev,
struct adi_driver_id_s *  adi_driver_id
 

Definition at line 449 of file rtl_8029.c.

References adi_netdev_init(), adi_register_netdev(), CR_ABORT_DMA, CR_PAGE0, CR_PAGE1, CR_READ_DMA, CR_STA, CR_STP, IMR_CNTE, IMR_OVWE, IMR_PRXE, IMR_PTXE, IMR_RXEE, IMR_TXEE, install_irq(), MOD_NAME, NET_RECV_MODE_BROADCAST, pcibus_enable_device(), printk(), RTL_8029_BNRY, RTL_8029_CR, RTL_8029_CURR, RTL_8029_DCR, RTL_8029_DMADATA, RTL_8029_IMR, rtl_8029_irq_routine, RTL_8029_ISR, rtl_8029_netdev, rtl_8029_netdev_param, RTL_8029_PSTART, RTL_8029_PSTOP, RTL_8029_RBCR0, RTL_8029_RBCR1, RTL_8029_RCR, rtl_8029_reset(), RTL_8029_RSAR0, RTL_8029_RSAR1, rtl_8029_set_recv_mode(), RTL_8029_TCR, RTL_8029_TPSR, RTL_8029_TX_PAGES, rtl_eprom, and rtl_iobase.

00450 {
00451     int i;
00452 
00453     adi_netdev_init(&rtl_8029_netdev);
00454 
00455     pcibus_enable_device(pcidev);
00456 
00457     if (pcidev->dev_resources[0].res_flags & ADI_RES_FLAG_IO)
00458         rtl_iobase = pcidev->dev_resources[0].res_start;
00459     else {
00460         printk(MOD_NAME "device resource 0 is not IO\n");
00461         return -1;
00462     }
00463 
00464     rtl_8029_netdev_param.start_page = 0x40;
00465     rtl_8029_netdev_param.end_page   = 0x80;
00466     rtl_8029_netdev_param.tx_start_page = 0x40;
00467     rtl_8029_netdev_param.rx_start_page = 0x40 + RTL_8029_TX_PAGES;
00468     rtl_8029_netdev_param.tx_busy[0] = 0;
00469     rtl_8029_netdev_param.tx_busy[1] = 0;
00470 
00471     printk(MOD_NAME "dev_irq=%d ", pcidev->dev_irq);
00472     install_irq(pcidev->dev_irq, &rtl_8029_irq_routine);
00473     printk("iobase=%04x ", rtl_iobase);
00474 
00475     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STP, rtl_iobase + RTL_8029_CR);
00476     rtl_8029_reset(pcidev);
00477 
00478     outb(0x40 | 0x08 | 0x01, rtl_iobase + RTL_8029_DCR);        /* word-wide 4 Words */
00479     outb(0x00, rtl_iobase + RTL_8029_IMR);
00480     outb(0xff, rtl_iobase + RTL_8029_ISR);
00481 //      outb(0x20, rtl_iobase + RTL_8029_RCR);    
00482     outb(0x00, rtl_iobase + RTL_8029_RCR);    
00483     outb(0x00, rtl_iobase + RTL_8029_TCR);    
00484 //        outb(0x02, rtl_iobase + RTL_8029_TCR);    
00485     outb(0x20, rtl_iobase + RTL_8029_RBCR0);
00486     outb(0x00, rtl_iobase + RTL_8029_RBCR1);
00487     outb(0x00, rtl_iobase + RTL_8029_RSAR0);
00488     outb(0x00, rtl_iobase + RTL_8029_RSAR1);
00489     outb(CR_READ_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00490     
00491     for (i = 0; i < 32; i++) {
00492         rtl_eprom[i] = inb(rtl_iobase + RTL_8029_DMADATA);
00493     }
00494 
00495     outb(0x40 | 0x08 | 0x01, rtl_iobase + RTL_8029_DCR);
00496 
00497     outb(CR_PAGE1 | CR_ABORT_DMA | CR_STP, rtl_iobase + RTL_8029_CR);
00498     
00499     /* setting mac address in PAR */
00500     for (i = 0; i < 6; i++) {
00501         rtl_8029_netdev.if_layer_2.if_addr[i] = rtl_eprom[i];
00502         outb(rtl_eprom[i], rtl_iobase + 0x01 + i);
00503     }
00504     rtl_8029_netdev.if_layer_2.if_addr_len = NET_LAYER_2_ETH_MAC_LEN;
00505 
00506     outb(rtl_8029_netdev_param.rx_start_page, rtl_iobase + RTL_8029_CURR);
00507 
00508     printk("%s hwaddr=%02x:%02x:%02x:%02x:%02x:%02x\n", rtl_8029_netdev.if_name,
00509             rtl_eprom[0], rtl_eprom[1], rtl_eprom[2], rtl_eprom[3], rtl_eprom[4], rtl_eprom[5]);
00510 
00511     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STP, rtl_iobase + RTL_8029_CR);
00512     outb(0x40 | 0x08 | 0x01, rtl_iobase + RTL_8029_DCR);        /* word-wide 4 Words */
00513     outb(0x00, rtl_iobase + RTL_8029_RBCR0);
00514     outb(0x00, rtl_iobase + RTL_8029_RBCR1);
00515 //      outb(0x20, rtl_iobase + RTL_8029_RCR);    
00516     outb(0x00, rtl_iobase + RTL_8029_RCR);    
00517 //      outb(0x02, rtl_iobase + RTL_8029_TCR);   
00518     outb(0x00, rtl_iobase + RTL_8029_TCR);   
00519     outb(rtl_8029_netdev_param.tx_start_page, rtl_iobase + RTL_8029_TPSR); 
00520     outb(rtl_8029_netdev_param.rx_start_page, rtl_iobase + RTL_8029_PSTART);
00521     outb(rtl_8029_netdev_param.end_page, rtl_iobase + RTL_8029_PSTOP);
00522     outb(rtl_8029_netdev_param.end_page - 1, rtl_iobase + RTL_8029_BNRY);
00523     outb(0xff, rtl_iobase + RTL_8029_ISR);
00524     outb(0x00, rtl_iobase + RTL_8029_IMR);
00525 
00526     /*
00527      * enable packet receive irq, packet transmitted irq
00528      * receive error irq, transmit error irq, overwrite irq, counter overflow irq
00529      */   
00530     outb(IMR_PRXE | IMR_PTXE | IMR_RXEE | IMR_TXEE | IMR_OVWE | IMR_CNTE, rtl_iobase + RTL_8029_IMR);
00531     outb(0xff, rtl_iobase + RTL_8029_ISR);
00532 
00533     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00534 
00535     /*
00536      * normal transmit mode
00537      */
00538     outb(0x00, rtl_iobase + RTL_8029_TCR);
00539     
00540     /*
00541      * accept broadcasts
00542      */
00543     rtl_8029_set_recv_mode(&rtl_8029_netdev, NET_RECV_MODE_BROADCAST);
00544 
00545     adi_register_netdev(&rtl_8029_netdev);
00546 
00547     return 0;
00548 }

Here is the call graph for this function:

int rtl_8029_receive_frame struct frb_s *  frb  ) 
 

Definition at line 277 of file rtl_8029.c.

References CR_ABORT_DMA, CR_PAGE0, CR_PAGE1, CR_READ_DMA, CR_STA, CR_STP, printk(), RTL_8029_BNRY, RTL_8029_CR, RTL_8029_DMADATA, RTL_8029_RBCR0, RTL_8029_RBCR1, RTL_8029_RSAR0, RTL_8029_RSAR1, RTL_8029_TX_PAGES, and rtl_iobase.

Referenced by rtl_8029_receive_frames().

00278 {
00279     struct rtl_8029_rx_desc_s rx_desc;
00280     u8 *ptr;
00281     u8 current_page;
00282     u8 boundary_page;
00283     u8 next_page;
00284     u16 frame_len;
00285     int i;
00286 
00287     outb(CR_PAGE1 | CR_ABORT_DMA | CR_STP, rtl_iobase + RTL_8029_CR);    
00288     current_page  = inb(rtl_iobase + 0x07);
00289     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STP, rtl_iobase + RTL_8029_CR);    
00290 
00291     boundary_page = inb(rtl_iobase + RTL_8029_BNRY) + 1;
00292 
00293 #if RTL_8029_DEBUG
00294     printk("boundary = %02x\n", boundary_page);
00295 #endif
00296 
00297     if (boundary_page >= 0x80)
00298         boundary_page = 0x40 + RTL_8029_TX_PAGES;
00299 
00300     if (boundary_page == current_page) {
00301         return -1;
00302     }
00303 
00304     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00305     outb(sizeof(rx_desc), rtl_iobase + RTL_8029_RBCR0); // lo
00306     outb(0x00, rtl_iobase + RTL_8029_RBCR1);            // hi
00307     outb(0x00, rtl_iobase + RTL_8029_RSAR0);
00308     outb(boundary_page, rtl_iobase + RTL_8029_RSAR1);
00309     outb(CR_PAGE0 | CR_READ_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00310 
00311     ptr = (u8 *)&rx_desc;
00312     *(u32 *)ptr = inl(rtl_iobase + RTL_8029_DMADATA);
00313 
00314     frame_len = rx_desc.count - sizeof(rx_desc);
00315     frb->frb_len = frame_len;
00316 
00317 #if RTL_8029_DEBUG
00318     printk("frame_len = %d\n", frame_len);
00319 #endif
00320 
00321     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00322     outb(frame_len & 0xff, rtl_iobase + RTL_8029_RBCR0);        // lo
00323     outb(frame_len >> 8,   rtl_iobase + RTL_8029_RBCR1);        // hi
00324     outb(sizeof(rx_desc), rtl_iobase + RTL_8029_RSAR0);
00325     outb(boundary_page, rtl_iobase + RTL_8029_RSAR1);
00326     outb(CR_PAGE0 | CR_READ_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00327 
00328     ptr = frb->frb_data;
00329 
00330     for (i = 0; i < (frame_len >> 2); i++) {
00331         *(u32 *)ptr = inl(rtl_iobase + RTL_8029_DMADATA);
00332         ptr += 4;
00333     }
00334 
00335     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00336 
00337     next_page = rx_desc.next;
00338 
00339 #if RTL_8029_DEBUG
00340     printk("next_page = %02x\n\n", next_page);
00341 #endif
00342 
00343     outb(next_page - 1, rtl_iobase + RTL_8029_BNRY);
00344     
00345     return 0;
00346 }

Here is the call graph for this function:

int rtl_8029_receive_frames struct adi_netdev_s *  netdev  ) 
 

Definition at line 348 of file rtl_8029.c.

References get_free_pages(), net_layer_2_recv_pack(), put_free_pages(), and rtl_8029_receive_frame().

Referenced by rtl_8029_irq().

00349 {
00350     struct frb_s frame_buf;
00351     int max_frames;
00352 
00353     for (max_frames = 0; max_frames < 16; max_frames++) {
00354         frame_buf.frb_offset = 0;
00355         frame_buf.frb_data = (u8 *)get_free_pages(0);
00356     
00357         if (rtl_8029_receive_frame(&frame_buf) < 0) {
00358             put_free_pages((u32)frame_buf.frb_data, 0);
00359             break;
00360         }
00361             
00362         frame_buf.frb_dev = netdev;
00363         net_layer_2_recv_pack(&frame_buf);
00364 
00365         put_free_pages((u32)frame_buf.frb_data, 0);
00366     }
00367 
00368     return 0;
00369 }

Here is the call graph for this function:

int rtl_8029_remove struct pcidev_s *  pcidev  ) 
 

Definition at line 550 of file rtl_8029.c.

00551 {
00552     return 0;
00553 }

int rtl_8029_reset struct pcidev_s *  pcidev  ) 
 

Definition at line 157 of file rtl_8029.c.

References counter_jiffies_desc, ISR_RESET, MOD_NAME, printk(), RTL_8029_ISR, RTL_8029_MAX_RESET_TIME, RTL_8029_RESET, and rtl_iobase.

Referenced by rtl_8029_probe().

00158 {
00159     u32 start_jiffies;
00160     u32 jiffies_latch[2];
00161     
00162     counter_read(counter_jiffies_desc, jiffies_latch);
00163     start_jiffies = jiffies_latch[0];
00164     
00165     outb(inb(rtl_iobase + RTL_8029_RESET), rtl_iobase + RTL_8029_RESET);
00166     
00167     while(!(inb(rtl_iobase + RTL_8029_ISR) & ISR_RESET)) {
00168         counter_read(counter_jiffies_desc, jiffies_latch);
00169         if (jiffies_latch[0] - start_jiffies >= RTL_8029_MAX_RESET_TIME) {
00170             printk(MOD_NAME "reset failure\n");
00171             return -1;
00172         }
00173     }
00174     
00175     outb(0xff, rtl_iobase + RTL_8029_ISR);
00176     
00177     return 0;
00178 }

Here is the call graph for this function:

int rtl_8029_send_frame struct frb_s *  frb  ) 
 

Definition at line 206 of file rtl_8029.c.

References CR_ABORT_DMA, CR_PAGE0, CR_READ_DMA, CR_STA, CR_TXP, CR_WRITE_DMA, flags, frb_data(), IMR_CNTE, IMR_OVWE, IMR_PRXE, IMR_PTXE, IMR_RXEE, IMR_TXEE, ISR_RDC, RTL_8029_CR, RTL_8029_DMADATA, RTL_8029_IMR, RTL_8029_ISR, RTL_8029_MIN_FRB_LEN, rtl_8029_netdev, rtl_8029_netdev_param, RTL_8029_RBCR0, RTL_8029_RBCR1, RTL_8029_RSAR0, RTL_8029_RSAR1, RTL_8029_TBCR0, RTL_8029_TBCR1, RTL_8029_TPSR, and rtl_iobase.

00207 {
00208     u32 flags;
00209     u16 frame_len = frb->frb_len;    
00210     u8 *ptr;
00211     int i;
00212 
00213     if (frame_len < RTL_8029_MIN_FRB_LEN)
00214         frame_len = RTL_8029_MIN_FRB_LEN;
00215     
00216     if (rtl_8029_netdev_param.tx_busy[0])
00217         return -1;
00218         
00219     spin_lock_irqsave(&rtl_8029_netdev.if_lock, flags);
00220 
00221     rtl_8029_netdev_param.tx_busy[0] = 1;
00222 
00223     outb(0x00, rtl_iobase + RTL_8029_IMR);
00224 
00225     outb(CR_PAGE0 | CR_ABORT_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00226     outb(0x42, rtl_iobase + RTL_8029_RBCR0);
00227     outb(0x00, rtl_iobase + RTL_8029_RBCR1);
00228     outb(0x42, rtl_iobase + RTL_8029_RSAR0);
00229     outb(0x00, rtl_iobase + RTL_8029_RSAR1);
00230     outb(CR_READ_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00231     outb(ISR_RDC, rtl_iobase + RTL_8029_ISR);
00232     
00233     outb(frame_len & 0xff, rtl_iobase + RTL_8029_RBCR0);
00234     outb(frame_len >> 8,   rtl_iobase + RTL_8029_RBCR1);
00235     outb(0, rtl_iobase + RTL_8029_RSAR0);
00236     outb(rtl_8029_netdev_param.tx_start_page, rtl_iobase + RTL_8029_RSAR1);
00237     outb(CR_WRITE_DMA | CR_STA, rtl_iobase + RTL_8029_CR);
00238 
00239     ptr = frb_data(frb);
00240     for (i = 0; i < (frame_len >> 2); i++) {
00241         outl(*(u32 *)ptr, rtl_iobase + RTL_8029_DMADATA);
00242         ptr += 4;
00243     }
00244     
00245     if ((frame_len & 3) == 2) {
00246         outw(*(u16 *)ptr, rtl_iobase + RTL_8029_DMADATA);
00247         ptr += 2;
00248     }
00249 
00250     if ((frame_len & 3) == 1)
00251         outb(*(u8 *)ptr, rtl_iobase + RTL_8029_DMADATA);
00252 
00253 //    wait max 40 ms for remote DMA complete
00254 //    while((inb(rtl_iobase + RTL_8029_ISR) & ISR_RDC) == 0) {
00255 //        counter_read(counter_jiffies_desc, jiffies_latch);
00256 //      if (jiffies_latch[0] - start_jiffies >= 200) {
00257 //          printk(MOD_NAME "Timeout on waiting for ISR_RDC\n");
00258 //          break;
00259 //      }
00260 //    }
00261     
00262     outb(ISR_RDC, rtl_iobase + RTL_8029_ISR);
00263 
00264     /* send transmit triggers */
00265     outb(CR_PAGE0 | CR_ABORT_DMA, rtl_iobase + RTL_8029_CR);
00266     outb(frame_len & 0xff, rtl_iobase + RTL_8029_TBCR0);
00267     outb(frame_len >> 8,   rtl_iobase + RTL_8029_TBCR1);
00268     outb(rtl_8029_netdev_param.tx_start_page, rtl_iobase + RTL_8029_TPSR);
00269     outb(CR_PAGE0 | CR_TXP | CR_STA, rtl_iobase + RTL_8029_CR);
00270     outb(IMR_PRXE | IMR_PTXE | IMR_RXEE | IMR_TXEE | IMR_OVWE | IMR_CNTE, rtl_iobase + RTL_8029_IMR);
00271 
00272     spin_unlock_irqrestore(&rtl_8029_netdev.if_lock, flags);
00273     
00274     return 0;
00275 }

Here is the call graph for this function:

int rtl_8029_set_recv_mode struct adi_netdev_s *  netdev,
int  recv_mode
 

Definition at line 180 of file rtl_8029.c.

References NET_RECV_MODE_BROADCAST, NET_RECV_MODE_MULTICAST, NET_RECV_MODE_PROMISC, RCR_BROADCAST, RCR_MULTICAST, RCR_PROMISC, RTL_8029_RCR, and rtl_iobase.

Referenced by rtl_8029_probe().

00181 {
00182     u32 rtl_8029_rcr = 0;
00183 
00184     if (recv_mode & NET_RECV_MODE_BROADCAST) {
00185         rtl_8029_rcr |= RCR_BROADCAST;
00186     }
00187     
00188     if (recv_mode & NET_RECV_MODE_MULTICAST) {
00189         rtl_8029_rcr |= RCR_MULTICAST;
00190     }
00191     
00192     if (recv_mode & NET_RECV_MODE_PROMISC) {
00193         rtl_8029_rcr |= RCR_PROMISC;
00194     }
00195 
00196     outb(rtl_8029_rcr, rtl_iobase + RTL_8029_RCR);
00197 
00198     return 0;
00199 }


Variable Documentation

int counter_jiffies_desc
 

Definition at line 18 of file counters_sys.c.

struct adi_driver_s rtl_8029_driver
 

Initial value:

 {
    .adi_driver_name    = "rtl_8029 network card",
    .adi_driver_type    = ADI_DRIVER_TYPE_PCI,
    .adi_driver_id      = rtl_8029_driver_id,
    .adi_driver_union.adi_driver_pci = &rtl_8029_driver_pci
}

Definition at line 560 of file rtl_8029.c.

Referenced by adi_netdrv_rtl_8029_init().

struct adi_driver_id_s rtl_8029_driver_id[]
 

Initial value:

 {
    { PCIBUS_VENDOR_REALTEK_ID, PCIBUS_DEVICE_RTL_8029_AS__ID },
    { 0 }    
}

Definition at line 152 of file rtl_8029.c.

struct adi_driver_pci_s rtl_8029_driver_pci
 

Initial value:

 {
    .adi_driver_probe   = rtl_8029_probe,
    .adi_driver_remove  = rtl_8029_remove
}

Definition at line 555 of file rtl_8029.c.

struct irq_routine_s rtl_8029_irq_routine
 

Initial value:

 {
    .proc       = rtl_8029_irq,
    .flags      = IRQ_FLAG_RANDOM,
}

Definition at line 433 of file rtl_8029.c.

Referenced by rtl_8029_probe().

struct adi_netdev_s rtl_8029_netdev
 

Initial value:

 {
    .if_ops             = &rtl_8029_netdev_ops,
}

Definition at line 445 of file rtl_8029.c.

Referenced by agnix_console_arp_request(), rtl_8029_irq(), rtl_8029_probe(), and rtl_8029_send_frame().

struct adi_netdev_ops_s rtl_8029_netdev_ops
 

Initial value:

 {
    .driver_open        = rtl_8029_open_driver,
    .driver_close       = rtl_8029_close_driver,
    .set_recv_mode      = rtl_8029_set_recv_mode, 
    .transmit_frame     = rtl_8029_send_frame
}

Definition at line 438 of file rtl_8029.c.

struct rtl_8029_param_s rtl_8029_netdev_param
 

Definition at line 150 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), and rtl_8029_send_frame().

u8 rtl_eprom[32]
 

Definition at line 147 of file rtl_8029.c.

Referenced by rtl_8029_probe().

u32 rtl_iobase
 

Definition at line 146 of file rtl_8029.c.

Referenced by rtl_8029_irq(), rtl_8029_probe(), rtl_8029_receive_frame(), rtl_8029_reset(), rtl_8029_send_frame(), and rtl_8029_set_recv_mode().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix